]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Merge branch 'cooking' of github.com:graphitemaster/gmqcc into cooking
authorDale Weiler <killfieldengine@gmail.com>
Tue, 5 Feb 2013 16:35:12 +0000 (16:35 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Tue, 5 Feb 2013 16:35:12 +0000 (16:35 +0000)
1  2 
parser.c

diff --combined parser.c
index 1adab691326b9ea844e2d0cf82b65a8355ea0a08,984668a57895ce1daadf501a9bc29081f2292bc8..81bbbcbcba2cc8bd58e74eb16e436337bd7643b2
+++ b/parser.c
@@@ -671,8 -671,7 +671,7 @@@ static bool parser_sy_apply_operator(pa
                      return false;
                  }
              }
-             if (!ast_block_set_type(blocks[0], exprs[1]))
-                 return false;
+             ast_block_set_type(blocks[0], exprs[1]);
  
              vec_push(sy->out, syblock(ctx, blocks[0]));
              return true;
                  out = (ast_expression*)ast_ternary_new(ctx, exprs[0], exprs[1], exprs[2]);
              break;
  
 +        case opid3('<', '=', '>'): /* -1, 0, or 1 */
 +            if (NotSameType(TYPE_FLOAT)) {
 +                ast_type_to_string(exprs[0], ty1, sizeof(ty1));
 +                ast_type_to_string(exprs[1], ty2, sizeof(ty2));
 +                compile_error(ctx, "invalid types used in comparision: %s and %s",
 +                    ty1, ty2);
 +
 +                return false;
 +            }
 +
 +            if (CanConstFold(exprs[0], exprs[1])) {
 +                if (ConstF(0) < ConstF(1))
 +                    out = (ast_expression*)parser_const_float_neg1(parser);
 +                else if (ConstF(0) == ConstF(1))
 +                    out = (ast_expression*)parser_const_float_0(parser);
 +                else if (ConstF(0) > ConstF(1))
 +                    out = (ast_expression*)parser_const_float_1(parser);
 +            } else {
 +                    /* if (lt) { */
 +                out = (ast_expression*)ast_ternary_new(ctx,
 +                        (ast_expression*)ast_binary_new(ctx, INSTR_LT, exprs[0], exprs[1]),
 +
 +                        /* out = -1 */
 +                        (ast_expression*)parser_const_float_neg1(parser),
 +
 +                    /* } else { */
 +                        /* if (eq) { */
 +                        (ast_expression*)ast_ternary_new(ctx,
 +                            (ast_expression*)ast_binary_new(ctx, INSTR_EQ_F, exprs[0], exprs[1]),
 +
 +                            /* out = 0 */
 +                            (ast_expression*)parser_const_float_0(parser),
 +
 +                        /* } else { */
 +
 +                            /* out = 1 */
 +                            (ast_expression*)parser_const_float_1(parser)
 +                        /* } */
 +                        )
 +                    /* } */
 +                    );
 +
 +            }
 +            break;
 +
          case opid1('>'):
              generated_op += 1; /* INSTR_GT */
          case opid1('<'):
              else
                  out = (ast_expression*)ast_binary_new(ctx, INSTR_SUB_F, (ast_expression*)parser_const_float_neg1(parser), exprs[0]);
              break;
 -            
      }
  #undef NotSameType
  
@@@ -1944,6 -1899,11 +1943,6 @@@ static ast_expression* parse_expression
              if (o == operator_count) {
                  compile_error(parser_ctx(parser), "unknown operator: %s", parser_tokval(parser));
                  goto onerr;
 -#if 0
 -/* Are there any expressions which actually end with an operator? */
 -                /* no operator found... must be the end of the statement */
 -                break;
 -#endif
              }
              /* found an operator */
              op = &operators[o];
@@@ -3895,11 -3855,12 +3894,12 @@@ static bool parse_function_body(parser_
              ast_expression *functype = fld_think->expression.next;
  
              thinkfunc = ast_value_new(parser_ctx(parser), parser_tokval(parser), functype->expression.vtype);
-             if (!thinkfunc || !ast_type_adopt(thinkfunc, functype)) {
+             if (!thinkfunc) { /* || !ast_type_adopt(thinkfunc, functype)*/
                  ast_unref(framenum);
                  parseerror(parser, "failed to create implicit prototype for `%s`", parser_tokval(parser));
                  return false;
              }
+             ast_type_adopt(thinkfunc, functype);
  
              if (!parser_next(parser)) {
                  ast_unref(framenum);