aboutsummaryrefslogtreecommitdiff
path: root/compiler.d
diff options
context:
space:
mode:
authormryouse2023-05-25 20:27:36 +0000
committermryouse2023-05-25 20:27:36 +0000
commitd95e4f6f988b16bbd95a9c78c0355d190390f003 (patch)
tree88c47ec85d16ebc3654ebae64c5e9905702d3c49 /compiler.d
parentf90b882fe50d982293be5427457efea565173261 (diff)
make list creation simpler (and allow nesting)
Diffstat (limited to 'compiler.d')
-rw-r--r--compiler.d20
1 files changed, 4 insertions, 16 deletions
diff --git a/compiler.d b/compiler.d
index 1c9e507..6a1424d 100644
--- a/compiler.d
+++ b/compiler.d
@@ -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) {