]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ast-macros: MKCONSTSTRING, added sHello hello world string
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Wed, 4 Jul 2012 12:20:54 +0000 (14:20 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Wed, 4 Jul 2012 12:20:54 +0000 (14:20 +0200)
ast.c
test/ast-macros.h
test/ast-test.c

diff --git a/ast.c b/ast.c
index 17c63413cc7de19fa8cc5123150b02a9c9f08afb..21e43b3933ad188e425f7b496155001bb3382360 100644 (file)
--- 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;
index 6f52bdfceae491d968ae4ed7ae284de37da6730b..8c6d6c62c3243c1c5408811941f9782dde4dcc25 100644 (file)
@@ -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);  \
index 44a9c0daf3487448d1e422eac2f4da0385005a81..e0cf69d6795a506b9ac68c7373bf3cf617751282 100644 (file)
@@ -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);