From 913b9f52e0450f17bdc73c813a13e9e9105c66b6 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 10 Jun 2019 18:13:28 +0900 Subject: [PATCH] Add an offset alias expression This should make dealing with def elements (vector etc) easier. --- tools/qfcc/include/expr.h | 1 + tools/qfcc/source/expr.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index 486af55be..5109b364e 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -558,6 +558,7 @@ expr_t *new_this_expr (void); expr_t *new_ret_expr (struct type_s *type); expr_t *new_alias_expr (struct type_s *type, expr_t *expr); +expr_t *new_offset_alias_expr (struct type_s *type, expr_t *expr, int offset); /** Create an expression of the correct type that references the specified parameter slot. diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index aa530c04c..3353521b6 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1025,6 +1025,18 @@ new_alias_expr (type_t *type, expr_t *expr) return alias; } +expr_t * +new_offset_alias_expr (type_t *type, expr_t *expr, int offset) +{ + expr_t *alias; + + alias = new_binary_expr ('A', expr, new_integer_expr (offset)); + alias->e.expr.type = type; + alias->file = expr->file; + alias->line = expr->line; + return alias; +} + static expr_t * param_expr (const char *name, type_t *type) {