From 23482358cbccbf61550b0cfdc86a6d541e07eee6 Mon Sep 17 00:00:00 2001 From: Larry Xue Date: Thu, 27 Aug 2020 16:38:45 -0400 Subject: [PATCH] misc --- c2logic/compiler.py | 5 ++++- include/io.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 include/io.h diff --git a/c2logic/compiler.py b/c2logic/compiler.py index 5d684ff..aa8ffd5 100644 --- a/c2logic/compiler.py +++ b/c2logic/compiler.py @@ -415,7 +415,10 @@ class Compiler(c_ast.NodeVisitor): self.push(RelativeJump(self.loops[-1].start, JumpCondition.always)) def visit_Return(self, node): - self.visit(node.expr) + if node.expr is None: + self.push(Set("__rax","null")) + else: + self.visit(node.expr) self.push_ret() def visit_Label(self, node): diff --git a/include/io.h b/include/io.h new file mode 100644 index 0000000..1caa69d --- /dev/null +++ b/include/io.h @@ -0,0 +1,11 @@ +#ifndef IO_H +#define IO_H +void println(char* s) { + print(s); + print("\n"); +} +void printdln(double s) { + printd(s); + print("\n"); +} +#endif \ No newline at end of file