diff options
| author | mryouse | 2023-05-25 20:27:36 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-25 20:27:36 +0000 |
| commit | d95e4f6f988b16bbd95a9c78c0355d190390f003 (patch) | |
| tree | 88c47ec85d16ebc3654ebae64c5e9905702d3c49 /compiler.d | |
| parent | f90b882fe50d982293be5427457efea565173261 (diff) | |
make list creation simpler (and allow nesting)
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -510,24 +510,12 @@ class Compiler { } void compileList(Form[] args) { - List lst = new List(); - ValueType vt; - int addr; + int length = to!int(args.length); foreach (Form arg ; args) { - vt = this.resolve(arg, ValueType.ANY); - // how do we get at the address? - addr = to!int(this.func.chunk.constants.length) - 1; // this is probably often wrong - lst.addItem(addr); - this.func.chunk.writeOp(OpCode.OP_POP, arg.line); // shouldn't use the stack for this (but how?) + resolve(arg, ValueType.ANY); // resolve everything onto the stack } - - this.func.chunk.writeOp(OpCode.OP_CONSTANT, args[0].line); - int idx = this.func.chunk.addConstant(makeObjValue(lst)); - this.func.chunk.writeOp(to!ubyte(idx), args[0].line); - //return ValueType.OBJ; - - - //advance(); // ?? + this.func.chunk.writeOp(OpCode.OP_LIST, args[0].line); + this.func.chunk.writeOp(to!ubyte(length), args[0].line); } void compileFirst(Form[] args) { |
