From 75372ee13252737304dde5473384b6e47d30b056 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sat, 22 Jul 2023 00:30:32 +0200 Subject: [PATCH] CodeEmitter - Added a new parameter to `transform(Instruction)` (now `transform(Instruction, Object)`. `customRules` is an `Object` to be interpreted by the underlying emitter which can change how certain transformations are done when it is in a certain state DGen - Uses new `CodeEmitter` API --- source/tlang/compiler/codegen/emit/core.d | 6 +++++- source/tlang/compiler/codegen/emit/dgen.d | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/tlang/compiler/codegen/emit/core.d b/source/tlang/compiler/codegen/emit/core.d index 047cd0b..5dda416 100644 --- a/source/tlang/compiler/codegen/emit/core.d +++ b/source/tlang/compiler/codegen/emit/core.d @@ -165,7 +165,11 @@ public abstract class CodeEmitter * * Params: * instruction = The Instruction to transform/emit + * customRules = an `Object` to be interpreted by + * the underlying emitter which can change how certain + * transformations are done when it is in a certain state + * * Returns: The Instruction emit as a string */ - public abstract string transform(Instruction instruction); + public abstract string transform(Instruction instruction, Object customRules = null); } \ No newline at end of file diff --git a/source/tlang/compiler/codegen/emit/dgen.d b/source/tlang/compiler/codegen/emit/dgen.d index 4a9a719..196b3c7 100644 --- a/source/tlang/compiler/codegen/emit/dgen.d +++ b/source/tlang/compiler/codegen/emit/dgen.d @@ -110,7 +110,7 @@ public final class DCodeEmitter : CodeEmitter } - public override string transform(const Instruction instruction) + public override string transform(const Instruction instruction, Object customRules = null) { writeln("\n"); gprintln("transform(): "~to!(string)(instruction));