From e9844d9abf44dfd3df591768fcc66ac40499f5e9 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Tue, 14 Aug 2012 20:00:11 +0200 Subject: [PATCH] vector fields now get _x, _y and _z too --- parser.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/parser.c b/parser.c index eedea46..673a624 100644 --- a/parser.c +++ b/parser.c @@ -1838,16 +1838,34 @@ static bool parser_do(parser_t *parser) fld->expression.next = (ast_expression*)var; varent.var = (ast_expression*)fld; + varent.name = util_strdup(fld->name); + (void)!parser_t_fields_add(parser, varent); + if (var->expression.vtype == TYPE_VECTOR) { /* create _x, _y and _z fields as well */ - parseerror(parser, "TODO: vector field members (_x,_y,_z)"); - ast_delete(fld); - return false; - } + size_t len; + varentry_t vx, vy, vz; - varent.name = util_strdup(fld->name); - (void)!parser_t_fields_add(parser, varent); + len = strlen(varent.name); + vx.var = (ast_expression*)ast_member_new(ast_ctx(fld), (ast_expression*)fld, 0); + vy.var = (ast_expression*)ast_member_new(ast_ctx(fld), (ast_expression*)fld, 1); + vz.var = (ast_expression*)ast_member_new(ast_ctx(fld), (ast_expression*)fld, 2); + vx.name = mem_a(len+3); + vy.name = mem_a(len+3); + vz.name = mem_a(len+3); + strcpy(vx.name, varent.name); + strcpy(vy.name, varent.name); + strcpy(vz.name, varent.name); + vx.name[len] = vy.name[len] = vz.name[len] = '_'; + vx.name[len+1] = 'x'; + vy.name[len+1] = 'y'; + vz.name[len+1] = 'z'; + vx.name[len+2] = vy.name[len+2] = vz.name[len+2] = 0; + (void)!parser_t_fields_add(parser, vx); + (void)!parser_t_fields_add(parser, vy); + (void)!parser_t_fields_add(parser, vz); + } /* end with a semicolon */ if (!parser_next(parser) || parser->tok != ';') { -- 2.39.2