size_t *_blocklocals;
ast_value **_typedefs;
size_t *_blocktypedefs;
- lex_ctx *_block_ctx;
+ lex_ctx_t *_block_ctx;
/* we store the '=' operator info */
const oper_info *assign_op;
* some maths used for constant folding
*/
-vector vec3_add(vector a, vector b)
+vec3_t vec3_add(vec3_t a, vec3_t b)
{
- vector out;
+ vec3_t out;
out.x = a.x + b.x;
out.y = a.y + b.y;
out.z = a.z + b.z;
return out;
}
-vector vec3_sub(vector a, vector b)
+vec3_t vec3_sub(vec3_t a, vec3_t b)
{
- vector out;
+ vec3_t out;
out.x = a.x - b.x;
out.y = a.y - b.y;
out.z = a.z - b.z;
return out;
}
-qcfloat vec3_mulvv(vector a, vector b)
+qcfloat_t vec3_mulvv(vec3_t a, vec3_t b)
{
return (a.x * b.x + a.y * b.y + a.z * b.z);
}
-vector vec3_mulvf(vector a, float b)
+vec3_t vec3_mulvf(vec3_t a, float b)
{
- vector out;
+ vec3_t out;
out.x = a.x * b;
out.y = a.y * b;
out.z = a.z * b;
{
size_t i;
ast_value *out;
- lex_ctx ctx;
+ lex_ctx_t ctx;
for (i = 0; i < vec_size(parser->imm_float); ++i) {
const double compare = parser->imm_float[i]->constval.vfloat;
if (memcmp((const void*)&compare, (const void *)&d, sizeof(double)) == 0)
return out;
}
-static ast_value* parser_const_vector(parser_t *parser, vector v)
+static ast_value* parser_const_vector(parser_t *parser, vec3_t v)
{
size_t i;
ast_value *out;
static ast_value* parser_const_vector_f(parser_t *parser, float x, float y, float z)
{
- vector v;
+ vec3_t v;
v.x = x;
v.y = y;
v.z = z;
size_t off;
ast_expression *out;
ast_block *block; /* for commas and function calls */
- lex_ctx ctx;
+ lex_ctx_t ctx;
} sy_elem;
enum {
unsigned int *paren;
} shunt;
-static sy_elem syexp(lex_ctx ctx, ast_expression *v) {
+static sy_elem syexp(lex_ctx_t ctx, ast_expression *v) {
sy_elem e;
e.etype = 0;
e.off = 0;
return e;
}
-static sy_elem syblock(lex_ctx ctx, ast_block *v) {
+static sy_elem syblock(lex_ctx_t ctx, ast_block *v) {
sy_elem e;
e.etype = 0;
e.off = 0;
return e;
}
-static sy_elem syop(lex_ctx ctx, const oper_info *op) {
+static sy_elem syop(lex_ctx_t ctx, const oper_info *op) {
sy_elem e;
e.etype = 1 + (op - operators);
e.off = 0;
return e;
}
-static sy_elem syparen(lex_ctx ctx, size_t off) {
+static sy_elem syparen(lex_ctx_t ctx, size_t off) {
sy_elem e;
e.etype = 0;
e.off = off;
ast_expression *sub;
ast_expression *entity;
- lex_ctx ctx = ast_ctx(*out);
+ lex_ctx_t ctx = ast_ctx(*out);
if (!ast_istype(*out, ast_array_index))
return false;
return true;
}
-static bool immediate_is_true(lex_ctx ctx, ast_value *v)
+static bool immediate_is_true(lex_ctx_t ctx, ast_value *v)
{
switch (v->expression.vtype) {
case TYPE_FLOAT:
static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
{
const oper_info *op;
- lex_ctx ctx;
+ lex_ctx_t ctx;
ast_expression *out = NULL;
ast_expression *exprs[3];
ast_block *blocks[3];
ast_value *asvalue[3];
ast_binstore *asbinstore;
size_t i, assignop, addop, subop;
- qcint generated_op = 0;
+ qcint_t generated_op = 0;
char ty1[1024];
char ty2[1024];
if (CanConstFold(exprs[0], exprs[1]))
out = (ast_expression*)parser_const_float(parser, vec3_mulvv(ConstV(0), ConstV(1)));
else if (OPTS_OPTIMIZATION(OPTIM_VECTOR_COMPONENTS) && CanConstFold1(exprs[0])) {
- vector vec = ConstV(0);
+ vec3_t vec = ConstV(0);
if (!vec.y && !vec.z) { /* 'n 0 0' * v */
++opts_optimizationcount[OPTIM_VECTOR_COMPONENTS];
out = (ast_expression*)ast_member_new(ctx, exprs[1], 0, NULL);
out = (ast_expression*)ast_binary_new(ctx, INSTR_MUL_V, exprs[0], exprs[1]);
}
else if (OPTS_OPTIMIZATION(OPTIM_VECTOR_COMPONENTS) && CanConstFold1(exprs[1])) {
- vector vec = ConstV(1);
+ vec3_t vec = ConstV(1);
if (!vec.y && !vec.z) { /* v * 'n 0 0' */
++opts_optimizationcount[OPTIM_VECTOR_COMPONENTS];
out = (ast_expression*)ast_member_new(ctx, exprs[0], 0, NULL);
}
if (CanConstFold(exprs[0], exprs[1])) {
out = (ast_expression*)parser_const_float(parser,
- (float)(((qcint)ConstF(0)) % ((qcint)ConstF(1))));
+ (float)(((qcint_t)ConstF(0)) % ((qcint_t)ConstF(1))));
} else {
/* generate a call to __builtin_mod */
ast_expression *mod = intrin_func(parser, "mod");
}
if (CanConstFold(exprs[0], exprs[1]))
out = (ast_expression*)parser_const_float(parser,
- (op->id == opid1('|') ? (float)( ((qcint)ConstF(0)) | ((qcint)ConstF(1)) ) :
- (float)( ((qcint)ConstF(0)) & ((qcint)ConstF(1)) ) ));
+ (op->id == opid1('|') ? (float)( ((qcint_t)ConstF(0)) | ((qcint_t)ConstF(1)) ) :
+ (float)( ((qcint_t)ConstF(0)) & ((qcint_t)ConstF(1)) ) ));
else
out = (ast_expression*)ast_binary_new(ctx,
(op->id == opid1('|') ? INSTR_BITOR : INSTR_BITAND),
*/
if (exprs[0]->vtype == TYPE_FLOAT) {
if(CanConstFold(exprs[0], exprs[1])) {
- out = (ast_expression*)parser_const_float(parser, (float)((qcint)(ConstF(0)) ^ ((qcint)(ConstF(1)))));
+ out = (ast_expression*)parser_const_float(parser, (float)((qcint_t)(ConstF(0)) ^ ((qcint_t)(ConstF(1)))));
} else {
ast_binary *expr = ast_binary_new(
ctx,
if (CanConstFold(exprs[0], exprs[1])) {
out = (ast_expression*)parser_const_vector_f(
parser,
- (float)(((qcint)(ConstV(0).x)) ^ ((qcint)(ConstV(1).x))),
- (float)(((qcint)(ConstV(0).y)) ^ ((qcint)(ConstV(1).y))),
- (float)(((qcint)(ConstV(0).z)) ^ ((qcint)(ConstV(1).z)))
+ (float)(((qcint_t)(ConstV(0).x)) ^ ((qcint_t)(ConstV(1).x))),
+ (float)(((qcint_t)(ConstV(0).y)) ^ ((qcint_t)(ConstV(1).y))),
+ (float)(((qcint_t)(ConstV(0).z)) ^ ((qcint_t)(ConstV(1).z)))
);
} else {
compile_error(ast_ctx(exprs[0]), "Not Yet Implemented: bit-xor for vector against vector");
if (CanConstFold(exprs[0], exprs[1])) {
out = (ast_expression*)parser_const_vector_f(
parser,
- (float)(((qcint)(ConstV(0).x)) ^ ((qcint)(ConstF(1)))),
- (float)(((qcint)(ConstV(0).y)) ^ ((qcint)(ConstF(1)))),
- (float)(((qcint)(ConstV(0).z)) ^ ((qcint)(ConstF(1))))
+ (float)(((qcint_t)(ConstV(0).x)) ^ ((qcint_t)(ConstF(1)))),
+ (float)(((qcint_t)(ConstV(0).y)) ^ ((qcint_t)(ConstF(1)))),
+ (float)(((qcint_t)(ConstV(0).z)) ^ ((qcint_t)(ConstF(1))))
);
} else {
compile_error(ast_ctx(exprs[0]), "Not Yet Implemented: bit-xor for vector against float");
}
if(CanConstFold1(exprs[0]))
- out = (ast_expression*)parser_const_float(parser, ~(qcint)ConstF(0));
+ out = (ast_expression*)parser_const_float(parser, ~(qcint_t)ConstF(0));
else
out = (ast_expression*)
ast_binary_new(ctx, INSTR_SUB_F, (ast_expression*)parser_const_float_neg1(parser), exprs[0]);
ast_expression *idx, *out;
ast_value *typevar;
ast_value *funtype = parser->function->vtype;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
if (!parser->function->varargs) {
parseerror(parser, "function has no variable argument list");
ast_expression *cond, *ontrue = NULL, *onfalse = NULL;
bool ifnot = false;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
(void)block; /* not touching */
bool ifnot = false;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
(void)block; /* not touching */
bool ifnot = false;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
(void)block; /* not touching */
bool ifnot = false;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
parser_enterblock(parser);
/* parse the incrementor */
if (parser->tok != ')') {
- lex_ctx condctx = parser_ctx(parser);
+ lex_ctx_t condctx = parser_ctx(parser);
increment = parse_expression_leave(parser, false, false, false);
if (!increment)
goto onerr;
ast_value *retval = parser->function->return_value;
ast_value *expected = parser->function->vtype;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
(void)block; /* not touching */
{
size_t i;
unsigned int levels = 0;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
const char **loops = (is_continue ? parser->continues : parser->breaks);
(void)block; /* not touching */
bool noref, is_static;
uint32_t qflags = 0;
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
(void)block; /* not touching */
(void)opval;
}
else
{
- lex_ctx ctx = parser_ctx(parser);
+ lex_ctx_t ctx = parser_ctx(parser);
ast_expression *exp = parse_expression(parser, false, false);
if (!exp)
return false;
{
bool flag = false;
bool reverse = false;
- qcfloat num = 0;
+ qcfloat_t num = 0;
ast_value **values = NULL;
ast_value *var = NULL;
ast_value *asvalue;
}
if (has_frame_think) {
- lex_ctx ctx;
+ lex_ctx_t ctx;
ast_expression *self_frame;
ast_expression *self_nextthink;
ast_expression *self_think;
ast_ifthen *ifthen;
ast_binary *cmp;
- lex_ctx ctx = ast_ctx(array);
+ lex_ctx_t ctx = ast_ctx(array);
if (!left || !right) {
if (left) ast_delete(left);
static ast_expression *array_setter_node(parser_t *parser, ast_value *array, ast_value *index, ast_value *value, size_t from, size_t afterend)
{
- lex_ctx ctx = ast_ctx(array);
+ lex_ctx_t ctx = ast_ctx(array);
if (from+1 == afterend) {
/* set this value */
size_t from,
size_t afterend)
{
- lex_ctx ctx = ast_ctx(array);
+ lex_ctx_t ctx = ast_ctx(array);
if (from+1 == afterend) {
/* set this value */
static ast_expression *array_getter_node(parser_t *parser, ast_value *array, ast_value *index, size_t from, size_t afterend)
{
- lex_ctx ctx = ast_ctx(array);
+ lex_ctx_t ctx = ast_ctx(array);
if (from+1 == afterend) {
ast_return *ret;
static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_value *cached_typedef);
static ast_value *parse_parameter_list(parser_t *parser, ast_value *var)
{
- lex_ctx ctx;
+ lex_ctx_t ctx;
size_t i;
ast_value **params;
ast_value *param;
{
ast_expression *cexp;
ast_value *cval, *tmp;
- lex_ctx ctx;
+ lex_ctx_t ctx;
ctx = parser_ctx(parser);
static ast_value *parse_typename(parser_t *parser, ast_value **storebase, ast_value *cached_typedef)
{
ast_value *var, *tmp;
- lex_ctx ctx;
+ lex_ctx_t ctx;
const char *name = NULL;
bool isfield = false;
parser_t *parser_create()
{
parser_t *parser;
- lex_ctx empty_ctx;
+ lex_ctx_t empty_ctx;
size_t i;
parser = (parser_t*)mem_a(sizeof(parser_t));