Strings 19

This commit is contained in:
nazrin 2025-06-05 20:12:29 +00:00
parent 10c44eab2e
commit eec0a94aac
15 changed files with 358 additions and 55 deletions

View file

@ -12,10 +12,10 @@ struct Emitter{
Compiler* compiler;
Chunk* chunk;
private uint line = 1;
Chunk* currentChunk(){
Chunk* currentChunk() @nogc nothrow {
return chunk;
}
void emit(Args...)(Args args){
void emit(Args...)(Args args) @nogc nothrow {
static foreach(v; args){{
static if(is(typeof(v) == OpCode)){
auto bytes = v;
@ -27,10 +27,10 @@ struct Emitter{
currentChunk.write(bytes, line);
}}
}
void emitConstant(Value value){
void emitConstant(Value value) @nogc nothrow {
emit(OpCode.Constant, makeConstant(value));
}
void emitReturn(){
void emitReturn() @nogc nothrow {
emit(OpCode.Return);
}
void endCompiler(){
@ -40,11 +40,11 @@ struct Emitter{
disassembleChunk(currentChunk());
}
}
uint makeConstant(Value value){
uint makeConstant(Value value) @nogc nothrow {
uint constant = chunk.addConstant(value);
return constant;
}
void setLine(uint l){
void setLine(uint l) @nogc nothrow {
this.line = l;
}
}