testing writing to multiple fields, including a vector field

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-08-11 21:18:46 +02:00
parent b36fabe4d7
commit c94c36d68b
2 changed files with 35 additions and 8 deletions

View file

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

View file

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