diff options
| author | mryouse | 2023-05-26 01:36:49 +0000 |
|---|---|---|
| committer | mryouse | 2023-05-26 01:36:49 +0000 |
| commit | 6b7b9d96fb26ba9d4616d2b839098b7c75f39c3f (patch) | |
| tree | f8fbfc86d0ff65cc55d30e30361664c8a10998dd /compiler.d | |
| parent | 9b97f36c3d57459c4de1e7da52e882c9d88142ae (diff) | |
strings as seqs
Diffstat (limited to 'compiler.d')
| -rw-r--r-- | compiler.d | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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; |
