This commit is contained in:
Michael Sippel 2024-12-24 12:51:36 +01:00
parent 4bc7fd1788
commit 12c0a008df
Signed by: senvas
GPG key ID: F96CF119C34B64A6
19 changed files with 220 additions and 534 deletions

View file

@ -13,8 +13,8 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"dup",
vec!["T"],
vec!["T~machine.Word"],
vec!["T~machine.Word", "T~machine.Word"],
vec!["machine.Word"],
vec!["machine.Word", "machine.Word"],
);
/* drop topmost element
@ -30,7 +30,7 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"emit",
vec![],
vec!["Char~Unicode~_2^32~_2^64~machine.UInt64~machine.Word"],
vec!["Char~Unicode~_2^32~machine.Int64~machine.Word"],
vec![],
);
symbols.write().unwrap().declare_proc_parse(
@ -53,49 +53,54 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"i+",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64","machine.Int64"],
vec!["machine.Int64"],
);
symbols.write().unwrap().declare_proc_parse(
"u+",
vec![],
vec!["machine.UInt64","machine.UInt64"],
vec!["machine.UInt64"],
);
symbols.write().unwrap().declare_proc_parse(
"i-",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
],
vec!["_2^64~machine::UInt64~machine.Word"],
vec!["machine.Int64","machine.Int64"],
vec!["machine.Int64"],
);
symbols.write().unwrap().declare_proc_parse(
"u-",
vec![],
vec!["machine.UInt64","machine.UInt64"],
vec!["machine.UInt64"],
);
symbols.write().unwrap().declare_proc_parse(
"i*",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"i/",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"i%",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"f+",
vec![],
@ -146,6 +151,9 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
vec!["~machine.f64~machine.Word"],
);
linker.add_procedure("u+", tisc::Assembler::new().inst(tisc::VM_Instruction::IntAdd).build());
linker.add_procedure("u-", tisc::Assembler::new().inst(tisc::VM_Instruction::IntSub).build());
linker.add_procedure("i+", tisc::Assembler::new().inst(tisc::VM_Instruction::IntAdd).build());
linker.add_procedure("i-", tisc::Assembler::new().inst(tisc::VM_Instruction::IntSub).build());
linker.add_procedure("i*", tisc::Assembler::new().inst(tisc::VM_Instruction::IntMul).build());
@ -162,24 +170,24 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"bit-neg",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
vec![], vec!["machine.Word"], vec!["machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"bit-and",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-or",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-xor",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
symbols.write().unwrap().declare_proc_parse(
"bit-shl",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-shr",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
@ -217,12 +225,11 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
linker.add_procedure("!", tisc::Assembler::new().inst(tisc::VM_Instruction::Store).build());
let section_id = linker.add_static("data-frame-ptr", vec![0x1000]);
symbols.write().unwrap().declare_static_parse(
"data-frame-ptr",
"<MutRef <Seq machine.Word>>~machine.Address~machine.Word",
);
linker.add_static("data-frame-ptr", vec![0x1000]);
symbols.write().unwrap().declare_proc_parse(
"data-frame-set",

View file

@ -324,7 +324,6 @@ impl Scope {
}
pub fn declare_static(&mut self, name: String, typ: laddertypes::TypeTerm, export: bool) {
eprintln!("add {} export {}", name, export);
self.symbols.insert(
name,
SymbolDef::StaticRef {

View file

@ -163,7 +163,7 @@ impl LTExpr {
);
// todo examine stack ..
return
if errors.len() == 0 {
result_type = sugared_result_type.desugar(&mut *super_scope.write().unwrap());
@ -355,7 +355,7 @@ impl Statement {
Statement::Expr(expr) => {
let t = expr.infer_type(scope)?;
let symb = expr.export_symbols();
// let symb = expr.export_symbols();
// eprintln!("expr statement: import symbols from expr {:?}", symb);
// scope.write().unwrap().import( symb );
@ -384,4 +384,3 @@ impl Statement {
}
}
}