From 9a9e753a9a67343d3081ff8cd39ce14c19a1ce4a Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Wed, 19 May 2021 20:52:26 -0500 Subject: [PATCH] Print needs to be special --- c2logic/compiler.py | 9 ++++++++- c2logic/instruction_definition.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/c2logic/compiler.py b/c2logic/compiler.py index 51fecd8..03153ef 100644 --- a/c2logic/compiler.py +++ b/c2logic/compiler.py @@ -449,7 +449,14 @@ class Compiler(c_ast.NodeVisitor): else: args = [] #TODO avoid duplication in builtin calls - if name == "asm": + if name == "print": + argnames = self.get_multiple_builtin_args(args, name) + self.push(PARSED_INSTRUCTIONS[name](*argnames)) + for argname in argnames: + if argname.startswith(f"__{name}_arg"): + self.delete_special_var(argname) + + elif name == "asm": arg = args[0] if not isinstance(arg, Constant) or arg.type != "string": raise TypeError("Non-string argument to asm", node) diff --git a/c2logic/instruction_definition.c b/c2logic/instruction_definition.c index f71b484..5e85af3 100644 --- a/c2logic/instruction_definition.c +++ b/c2logic/instruction_definition.c @@ -1,7 +1,7 @@ struct MindustryObject {}; // builtin instructions void print(char* s) { - asm("print \"{s}\""); + asm("print {s}"); } void printd(double s) { asm("print {s}");