Changeset 333 for cpp/frams/vm/framscript.y
- Timestamp:
- 03/01/15 01:19:56 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/vm/framscript.y
r332 r333 28 28 void warnTruthValue(const TokenValue& t); 29 29 void outFunName(const TokenValue& t); 30 static bool resultIsRelaxedEqual(ExtValue::CompareResult res); 30 31 31 32 static const char* assign_op_names[]={"add","sub","mul","div","mod"}; … … 46 47 %left NEG /* negation--unary minus */ 47 48 %left TYPEOF 48 %left INT 49 %left FLOAT 50 %left STRING 49 %left INT_TYPE 50 %left FLOAT_TYPE 51 %left STRING_TYPE 51 52 52 53 %token IDENT … … 67 68 %token DEFAULT "default" 68 69 69 %token TYPEOF "typeof"70 %token INT 71 %token FLOAT 72 %token STRING 70 %token TYPEOF "typeof" 71 %token INT_TYPE "int" 72 %token FLOAT_TYPE "float" 73 %token STRING_TYPE "string" 73 74 74 75 %token ASM … … 704 705 {trctx.out->printf("type s0,s0\n");} 705 706 } 706 | INT '(' expr ')' { trctx.emitLine(); $$.ident=0;707 | INT_TYPE '(' expr ')' { trctx.emitLine(); $$.ident=0; 707 708 if ($3.constant) 708 709 {$$.constant=1; $$=ExtValue($3.getInt());} … … 710 711 {trctx.out->printf("conv 1,s0\n");} 711 712 } 712 | FLOAT '(' expr ')' { trctx.emitLine(); $$.ident=0;713 | FLOAT_TYPE '(' expr ')' { trctx.emitLine(); $$.ident=0; 713 714 if ($3.constant) 714 715 {$$.constant=1; $$=ExtValue($3.getDouble());} … … 716 717 {trctx.out->printf("conv 2,s0\n");} 717 718 } 718 | STRING '(' expr ')' { trctx.emitLine(); $$.ident=0;719 | STRING_TYPE '(' expr ')' { trctx.emitLine(); $$.ident=0; 719 720 if ($3.constant) 720 721 {$$.constant=1; $$=ExtValue($3.getString());} … … 748 749 if ($1.constant) 749 750 { 750 int cond=$1.compare(ExtValue::zero());751 if ( (cond==0)||(cond==2))751 ExtValue::CompareResult cond=$1.compare(ExtValue::zero()); 752 if (resultIsRelaxedEqual(cond)) 752 753 { 753 754 $1.counter=0; … … 776 777 if (!($1.constant && $1.counter==0)) 777 778 { 778 intcond=$4.compare(ExtValue::zero());779 bool value=! ((cond==0)||(cond==2));779 ExtValue::CompareResult cond=$4.compare(ExtValue::zero()); 780 bool value=!resultIsRelaxedEqual(cond); 780 781 trstack.adjust(-1); 781 782 trctx.out->printf("push %d\n",value); … … 803 804 if ($1.constant) 804 805 { 805 intcond=$1.compare(ExtValue::zero());806 if (! ((cond==0)||(cond==2)))806 ExtValue::CompareResult cond=$1.compare(ExtValue::zero()); 807 if (!resultIsRelaxedEqual(cond)) 807 808 { 808 809 $1.counter=1; … … 831 832 if (!($1.constant && $1.counter==1)) 832 833 { 833 int cond=$4.compare(ExtValue::zero());834 bool value=! ((cond==0)||(cond==2));834 ExtValue::CompareResult cond=$4.compare(ExtValue::zero()); 835 bool value=!resultIsRelaxedEqual(cond); 835 836 trstack.adjust(-1); 836 837 trctx.out->printf("push %d\n",value); … … 854 855 trctx.emitLine(); $$.assign=$2.assign; $$.parens=0; $$.ident=0; 855 856 if ($2.constant) 856 {$$.constant=1; int res=$2.compare(ExtValue((paInt)0)); $$.setInt((res==0)||(res==2));}857 {$$.constant=1; ExtValue::CompareResult res=$2.compare(ExtValue((paInt)0)); $$.setInt(resultIsRelaxedEqual(res));} 857 858 else 858 859 {trctx.out->printf("setif ~=,s0,s0\n");} … … 1427 1428 { 1428 1429 result.constant=1; 1429 int cmp=arg1.compare(arg2);1430 ExtValue::CompareResult cmp=arg1.compare(arg2); 1430 1431 ExtValue::CmpContext context; 1431 1432 context.v1=&arg1; … … 1458 1459 } 1459 1460 1461 static bool resultIsRelaxedEqual(ExtValue::CompareResult res) 1462 { 1463 return (res==ExtValue::ResultEqual)||(res==ExtValue::ResultEqualUnordered)||(res==ExtValue::ResultUnequal_RelaxedEqual); 1464 } 1465 1460 1466 bool variableOk(TokenValue &tok, const TokenValue& var,int &loc) 1461 1467 {
Note: See TracChangeset
for help on using the changeset viewer.