From 1349ebd2fc2a08a45c8e138002c5254ee6978540 Mon Sep 17 00:00:00 2001 From: Cody Date: Wed, 28 Jun 2023 22:10:31 -0500 Subject: String lists --- sloth/src/codegen/mod.rs | 11 +++++++++++ sloth/src/main.rs | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/sloth/src/codegen/mod.rs b/sloth/src/codegen/mod.rs index f484d52..fbf3d5f 100644 --- a/sloth/src/codegen/mod.rs +++ b/sloth/src/codegen/mod.rs @@ -53,6 +53,7 @@ impl<'ctx> Codegen<'ctx> { ("i", Type::Integer), ("f", Type::Float), ("b", Type::Boolean), + ("s", Type::String), ] { this.INTRINSIC_vpush(c, t.clone()); this.INTRINSIC_vpop(c, t.clone()); @@ -745,6 +746,11 @@ impl<'ctx> Codegen<'ctx> { Type::Integer => self.context.i32_type().fn_type(inputs, false), Type::Float => self.context.f32_type().fn_type(inputs, false), Type::Boolean => self.context.bool_type().fn_type(inputs, false), + Type::String => self + .context + .i8_type() + .ptr_type(AddressSpace::default()) + .fn_type(inputs, false), _ => panic!(), }; self._setup(&format!("vpop{name}"), func_type); @@ -791,6 +797,11 @@ impl<'ctx> Codegen<'ctx> { Type::Integer => self.context.i32_type().fn_type(inputs, false), Type::Float => self.context.f32_type().fn_type(inputs, false), Type::Boolean => self.context.bool_type().fn_type(inputs, false), + Type::String => self + .context + .i8_type() + .ptr_type(AddressSpace::default()) + .fn_type(inputs, false), _ => panic!(), }; self._setup(&format!("vget{name}"), func_type); diff --git a/sloth/src/main.rs b/sloth/src/main.rs index a1a4756..b34dd4f 100644 --- a/sloth/src/main.rs +++ b/sloth/src/main.rs @@ -119,23 +119,35 @@ fn mk_symtable() -> SymbolTable { id: 0, }); + let dummys = Symbol::Value(ValueSymbol { + typ: Type::Function { + inputs: vec![], + output: Box::new(Type::Boolean), + }, + id: 0, + }); + global_symtable.insert("vlen".into(), dummyi.clone()); global_symtable.insert("vpushi".into(), dummyi.clone()); global_symtable.insert("vpushf".into(), dummyf.clone()); global_symtable.insert("vpushb".into(), dummyb.clone()); + global_symtable.insert("vpushs".into(), dummys.clone()); global_symtable.insert("vpopi".into(), dummyi.clone()); global_symtable.insert("vpopf".into(), dummyf.clone()); global_symtable.insert("vpopb".into(), dummyb.clone()); + global_symtable.insert("vpops".into(), dummys.clone()); global_symtable.insert("vgeti".into(), dummyi.clone()); global_symtable.insert("vgetf".into(), dummyf.clone()); global_symtable.insert("vgetb".into(), dummyb.clone()); + global_symtable.insert("vgets".into(), dummys.clone()); global_symtable.insert("vseti".into(), dummyi); global_symtable.insert("vsetf".into(), dummyf); global_symtable.insert("vsetb".into(), dummyb); + global_symtable.insert("vsets".into(), dummys); global_symtable } -- cgit v1.2.3