size_t i;
ast_value *out;
for (i = 0; i < vec_size(parser->imm_float); ++i) {
- if ((double)(parser->imm_float[i]->constval.vfloat) == d)
+ const double compare = parser->imm_float[i]->constval.vfloat;
+ if (memcmp((const void*)&compare, (const void *)&d, sizeof(double)) == 0)
return parser->imm_float[i];
}
out = ast_value_new(parser_ctx(parser), "#IMMEDIATE", TYPE_FLOAT);
ast_expression *exprs[3];
ast_block *blocks[3];
ast_value *asvalue[3];
- size_t i, assignop;
+ size_t i, assignop, addop;
qcint generated_op = 0;
char ty1[1024];
}
out = (ast_expression*)ast_store_new(ctx, assignop, exprs[0], exprs[1]);
break;
+ case opid3('+','+','P'):
+ case opid3('-','-','P'):
+ /* prefix ++ */
+ if (exprs[0]->expression.vtype != TYPE_FLOAT) {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ parseerror(parser, "invalid type for prefix increment: %s", ty1);
+ return false;
+ }
+ if (op->id == opid3('+','+','P'))
+ addop = INSTR_ADD_F;
+ else
+ addop = INSTR_SUB_F;
+ if (ast_istype(exprs[0], ast_entfield)) {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STOREP_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ } else {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STORE_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ }
+ break;
+ case opid3('S','+','+'):
+ case opid3('S','-','-'):
+ /* prefix ++ */
+ if (exprs[0]->expression.vtype != TYPE_FLOAT) {
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ parseerror(parser, "invalid type for prefix increment: %s", ty1);
+ return false;
+ }
+ if (op->id == opid3('+','+','P'))
+ addop = INSTR_ADD_F;
+ else
+ addop = INSTR_SUB_F;
+ if (ast_istype(exprs[0], ast_entfield)) {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STOREP_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ } else {
+ out = (ast_expression*)ast_binstore_new(ctx, INSTR_STORE_F, addop,
+ exprs[0],
+ (ast_expression*)parser_const_float(parser, 1));
+ }
+ break;
case opid2('+','='):
case opid2('-','='):
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
(exprs[0]->expression.vtype != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) )
{
+ ast_type_to_string(exprs[0], ty1, sizeof(ty1));
+ ast_type_to_string(exprs[1], ty2, sizeof(ty2));
parseerror(parser, "invalid types used in expression: cannot add or subtract type %s and %s",
- type_name[exprs[0]->expression.vtype],
- type_name[exprs[1]->expression.vtype]);
+ ty1, ty2);
return false;
}
if (ast_istype(exprs[0], ast_entfield))
else
{
/* classify the operator */
- /* TODO: suffix operators */
const oper_info *op;
const oper_info *olast = NULL;
size_t o;
for (o = 0; o < operator_count; ++o) {
if ((!(operators[o].flags & OP_PREFIX) == wantop) &&
- !(operators[o].flags & OP_SUFFIX) && /* remove this */
+ /* !(operators[o].flags & OP_SUFFIX) && / * remove this */
!strcmp(parser_tokval(parser), operators[o].op))
{
break;
} else {
DEBUGSHUNTDO(con_out("push operator %s\n", op->op));
vec_push(sy.ops, syop(parser_ctx(parser), op));
- wantop = false;
+ wantop = !!(op->flags & OP_SUFFIX);
}
}
if (!parser_next(parser)) {
lex_ctx ctx = parser_ctx(parser);
+ (void)block; /* not touching */
+
/* skip the 'if', parse an optional 'not' and check for an opening paren */
if (!parser_next(parser)) {
parseerror(parser, "expected condition or 'not'");
lex_ctx ctx = parser_ctx(parser);
+ (void)block; /* not touching */
+
/* skip the 'while' and check for opening paren */
if (!parser_next(parser) || parser->tok != '(') {
parseerror(parser, "expected 'while' condition in parenthesis");
lex_ctx ctx = parser_ctx(parser);
+ (void)block; /* not touching */
+
/* skip the 'do' and get the body */
if (!parser_next(parser)) {
parseerror(parser, "expected loop body");
ast_return *ret = NULL;
ast_value *expected = parser->function->vtype;
+ (void)block; /* not touching */
+
if (!parser_next(parser)) {
parseerror(parser, "expected return expression");
return false;
{
lex_ctx ctx = parser_ctx(parser);
+ (void)block; /* not touching */
+
if (!parser_next(parser) || parser->tok != ';') {
parseerror(parser, "expected semicolon");
return false;
lex_ctx ctx = parser_ctx(parser);
+ (void)block; /* not touching */
+
/* parse over the opening paren */
if (!parser_next(parser) || parser->tok != '(') {
parseerror(parser, "expected switch operand in parenthesis");
}
/* loop method */
-static bool create_vector_members(parser_t *parser, ast_value *var, varentry_t *ve)
+static bool create_vector_members(ast_value *var, varentry_t *ve)
{
size_t i;
size_t len = strlen(var->name);
continue;
}
- if (!create_vector_members(parser, param, ve)) {
+ if (!create_vector_members(param, ve)) {
ast_block_delete(block);
return false;
}
lex_ctx ctx = ast_ctx(array);
if (from+1 == afterend) {
- // set this value
+ /* set this value */
ast_block *block;
ast_return *ret;
ast_array_index *subscript;
+ ast_store *st;
int assignop = type_store_instr[value->expression.vtype];
if (value->expression.vtype == TYPE_FIELD && value->expression.next->expression.vtype == TYPE_VECTOR)
if (!subscript)
return NULL;
- ast_store *st = ast_store_new(ctx, assignop, (ast_expression*)subscript, (ast_expression*)value);
+ st = ast_store_new(ctx, assignop, (ast_expression*)subscript, (ast_expression*)value);
if (!st) {
ast_delete(subscript);
return NULL;
lex_ctx ctx = ast_ctx(array);
if (from+1 == afterend) {
- // set this value
+ /* set this value */
ast_block *block;
ast_return *ret;
ast_entfield *entfield;
ast_array_index *subscript;
+ ast_store *st;
int assignop = type_storep_instr[value->expression.vtype];
if (value->expression.vtype == TYPE_FIELD && value->expression.next->expression.vtype == TYPE_VECTOR)
return NULL;
}
- ast_store *st = ast_store_new(ctx, assignop, (ast_expression*)entfield, (ast_expression*)value);
+ st = ast_store_new(ctx, assignop, (ast_expression*)entfield, (ast_expression*)value);
if (!st) {
ast_delete(entfield);
return NULL;
isvector = true;
if (isvector) {
- if (!create_vector_members(parser, var, ve)) {
+ if (!create_vector_members(var, ve)) {
retval = false;
goto cleanup;
}
static void progdefs_crc_file(const char *str)
{
/* write to progdefs.h here */
+ (void)str;
}
static uint16_t progdefs_crc_both(uint16_t old, const char *str)