ast-macros: MKCONSTSTRING, added sHello hello world string

This commit is contained in:
Wolfgang Bumiller 2012-07-04 14:20:54 +02:00
parent 2c1f08a209
commit 6bbcd5a343
3 changed files with 10 additions and 1 deletions

1
ast.c
View file

@ -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;

View 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); \

View 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);