stage0 新增内存复制指令 重构vm交互
This commit is contained in:
1 parent
0b8f649818
commit
40cffa9cb5
22 files changed
+626
-158
No files matched your search
@@ -1283,7 +1283,6 @@ fn run(self: *Ir2C) {
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
emit_ct_table(self);
|
||||
var m = find_main(self);
|
||||
if m != 0 {
|
||||
var f = IrM.func(self.ir, m);
|
||||
@@ -1311,34 +1310,6 @@ fn run(self: *Ir2C) {
|
||||
}
|
||||
}
|
||||
|
||||
// compiler function(`ct_` 前缀)回调表:供 native 端 vm_set_foreign 按名分发。
|
||||
fn emit_ct_table(self: *Ir2C) {
|
||||
put(self, "static const struct { const char *name; void *fn; } spl_ct_tab[] = {\n");
|
||||
var n: usize = 0;
|
||||
var i: usize = 1;
|
||||
while i < self.ir.funcs.len {
|
||||
var f = IrM.func(self.ir, i);
|
||||
if f != null && !fn_is_extern(self, f) &&
|
||||
ByteView.starts_with(f.name, ByteView.from_slice("ct_")) {
|
||||
put(self, " {\"");
|
||||
put_bv(self, f.name);
|
||||
put(self, "\", (void*)f");
|
||||
put_u(self, i);
|
||||
put(self, "},\n");
|
||||
n = n + 1;
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
if n == 0 { put(self, " {0, 0},\n"); }
|
||||
put(self, "};\n");
|
||||
put(self, "void *spl_ct_lookup(const char *name) {\n");
|
||||
put(self, " unsigned long i;\n");
|
||||
put(self, " for (i = 0; i < sizeof(spl_ct_tab)/sizeof(spl_ct_tab[0]); i++)\n");
|
||||
put(self, " if (spl_ct_tab[i].name && strcmp(spl_ct_tab[i].name, name) == 0) return spl_ct_tab[i].fn;\n");
|
||||
put(self, " return 0;\n");
|
||||
put(self, "}\n");
|
||||
}
|
||||
|
||||
fn new(ir: *Ir, ty: *TypeTable, layout: *Layout, attr: *Attr, out: *ByteBuffer): Ir2C {
|
||||
ret Ir2C {
|
||||
.ir = ir,
|
||||
|
||||
Reference in new issue
Block a user