From: Wolfgang Bumiller Date: Wed, 4 Jul 2012 12:20:54 +0000 (+0200) Subject: ast-macros: MKCONSTSTRING, added sHello hello world string X-Git-Tag: 0.1-rc1~454 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6bbcd5a343e4a88ee53d616a41823ac6b5dccee5;p=xonotic%2Fgmqcc.git ast-macros: MKCONSTSTRING, added sHello hello world string --- diff --git a/ast.c b/ast.c index 17c6341..21e43b3 100644 --- a/ast.c +++ b/ast.c @@ -1194,7 +1194,6 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value **out) { - /* TODO: call ir codegen */ ast_expression_codegen *cgen; ir_value_vector params; ir_instr *callinstr; diff --git a/test/ast-macros.h b/test/ast-macros.h index 6f52bdf..8c6d6c6 100644 --- a/test/ast-macros.h +++ b/test/ast-macros.h @@ -28,6 +28,13 @@ do { \ MKGLOBAL(name); \ } while(0) +#define MKCONSTSTRING(name, value) \ +do { \ + name->isconst = true; \ + name->constval.vstring = util_strdup(value); \ + MKGLOBAL(name); \ +} while(0) + #define STATE(a) \ do { \ ast_expression *exp = (ast_expression*)(a); \ diff --git a/test/ast-test.c b/test/ast-test.c index 44a9c0d..e0cf69d 100644 --- a/test/ast-test.c +++ b/test/ast-test.c @@ -27,6 +27,7 @@ int main() DEFVAR(f0); DEFVAR(f1); DEFVAR(f5); + DEFVAR(sHello); DEFVAR(print); /* opts_debug = true; */ @@ -39,9 +40,11 @@ ENDBUILTIN(); VAR(TYPE_FLOAT, f0); VAR(TYPE_FLOAT, f1); VAR(TYPE_FLOAT, f5); +VAR(TYPE_STRING, sHello); MKCONSTFLOAT(f0, 0.0); MKCONSTFLOAT(f1, 1.0); MKCONSTFLOAT(f5, 5.0); +MKCONSTSTRING(sHello, "Hello, World\n"); FUNCTION(foo, TYPE_VOID); ENDFUNCTION(foo);