aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-06-28 22:10:31 -0500
committerCody <cody@codyq.dev>2023-06-28 22:10:31 -0500
commit1349ebd2fc2a08a45c8e138002c5254ee6978540 (patch)
tree22de4fbe1d716aadf67f0b902d92648013c500cd
parent73843fa284968b4efb0ae51858cb37d0189c4b83 (diff)
downloadsloth-1349ebd2fc2a08a45c8e138002c5254ee6978540.tar.gz
String lists
-rw-r--r--sloth/src/codegen/mod.rs11
-rw-r--r--sloth/src/main.rs12
2 files changed, 23 insertions, 0 deletions
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
}