From c94c36d68b107037970ad3e0026cd0d9610a2f53 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sat, 11 Aug 2012 21:18:46 +0200 Subject: [PATCH] testing writing to multiple fields, including a vector field --- test/ast-macros.h | 9 +++++++++ test/ast-test.c | 34 ++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/test/ast-macros.h b/test/ast-macros.h index e11bd8d..16130ef 100644 --- a/test/ast-macros.h +++ b/test/ast-macros.h @@ -46,6 +46,15 @@ do { \ MKGLOBAL(name); \ } while(0) +#define MKCONSTVECTOR(name, valx, valy, valz) \ +do { \ + name->isconst = true; \ + name->constval.vvec.x = (valx); \ + name->constval.vvec.y = (valy); \ + name->constval.vvec.z = (valz); \ + 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 2fb587e..0cb0101 100644 --- a/test/ast-test.c +++ b/test/ast-test.c @@ -37,12 +37,17 @@ int main() DEFVAR(f0); DEFVAR(f1); DEFVAR(f5); + DEFVAR(cv3x4x5); + DEFVAR(cv1x1x1); DEFVAR(sHello); + DEFVAR(sNL); DEFVAR(print); DEFVAR(ftos); DEFVAR(spawn); DEFVAR(mema); + DEFVAR(memb); + DEFVAR(memv); DEFVAR(pawn); /* opts_debug = true; */ @@ -63,17 +68,27 @@ VAR(TYPE_FLOAT, f0); VAR(TYPE_FLOAT, f1); VAR(TYPE_FLOAT, f5); VAR(TYPE_STRING, sHello); +VAR(TYPE_STRING, sNL); +VAR(TYPE_VECTOR, cv3x4x5); +VAR(TYPE_VECTOR, cv1x1x1); FIELD(TYPE_FLOAT, mema); +FIELD(TYPE_FLOAT, memb); +FIELD(TYPE_VECTOR, memv); MKCONSTFLOAT(f0, 0.0); MKCONSTFLOAT(f1, 1.0); MKCONSTFLOAT(f5, 5.0); MKCONSTSTRING(sHello, "Hello, World\n"); +MKCONSTSTRING(sNL, "\n"); +MKCONSTVECTOR(cv3x4x5, 3, 4, 5); +MKCONSTVECTOR(cv1x1x1, 1, 1, 1); FUNCTION(foo, TYPE_VOID); ENDFUNCTION(foo); +#define PRINTNL() do { CALL(print) CALLPARAM(sNL) ENDCALL(); } while(0) + FUNCTION(main, TYPE_VOID); VAR(TYPE_FLOAT, vi); @@ -98,21 +113,24 @@ FUNCTION(main, TYPE_VOID); ENDCALLWITH(newent, STATE(ASSIGN(STORE_ENT, pawn, newent))); STATE(ASSIGN(STOREP_F, ENTFIELD(pawn, mema), f5)); + STATE(ASSIGN(STOREP_F, ENTFIELD(pawn, memb), f1)); + STATE(ASSIGN(STOREP_V, ENTFIELD(pawn, memv), cv3x4x5)); CALL(ftos) CALLPARAM(ENTFIELD(pawn, mema)) -#if 0 - ENDCALLWITH(output, STATE(ASSIGN(STORE_F, vi, output))); - - CALL(print) - CALLPARAM(vi) - ENDCALL(); -#else ENDCALLWITH(output, CALL(print) CALLPARAM(output) + CALLPARAM(sNL) + ENDCALL(); + ); + CALL(ftos) + CALLPARAM(ENTFIELD(pawn, memb)) + ENDCALLWITH(output, + CALL(print) + CALLPARAM(output) + CALLPARAM(sNL) ENDCALL(); ); -#endif ENDFUNCTION(main);