From 6b7b9d96fb26ba9d4616d2b839098b7c75f39c3f Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 26 May 2023 01:36:49 +0000 Subject: strings as seqs --- compiler.d | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'compiler.d') diff --git a/compiler.d b/compiler.d index 66ee664..ecd7785 100644 --- a/compiler.d +++ b/compiler.d @@ -99,6 +99,17 @@ class Compiler { */ } + void compileString(Form form, ValueType expecting) { + LiteralString ls = cast(LiteralString)form; + + this.func.chunk.writeOp(OpCode.OP_CONSTANT, ls.line); + String str = new String(ls.value); + int idx = this.func.chunk.addConstant(makeSeqValue(str)); + this.func.chunk.writeOp(to!ubyte(idx), ls.line); + + this.advance(); + } + void compileAtom(Form form, const ValueType expecting) { Atom atom = cast(Atom)form; /* @@ -719,6 +730,9 @@ class Compiler { case FormType.ATOM: this.compileAtom(form, expecting); break; + case FormType.LITERALSTRING: + this.compileString(form, expecting); + break; case FormType.CONS: return this.compileCons(form, expecting); break; -- cgit v1.2.3