1.4.1 locus roundabout fix, 3 more operators

This commit is contained in:
Arndt 2016-05-09 22:05:40 +02:00
parent 0d70493919
commit 8609c1f47b
17 changed files with 54 additions and 24 deletions

View file

@ -5,7 +5,7 @@
<parent>
<groupId>org.btools</groupId>
<artifactId>brouter</artifactId>
<version>1.4</version>
<version>1.4.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>brouter-expressions</artifactId>

View file

@ -15,6 +15,10 @@ final class BExpression
private static final int GREATER_EXP = 24;
private static final int MIN_EXP = 25;
private static final int SUB_EXP = 26;
private static final int LESSER_EXP = 27;
private static final int XOR_EXP = 28;
private static final int SWITCH_EXP = 30;
private static final int ASSIGN_EXP = 31;
private static final int LOOKUP_EXP = 32;
@ -115,6 +119,18 @@ final class BExpression
{
exp.typ = GREATER_EXP;
}
else if ( "sub".equals( operator ) )
{
exp.typ = SUB_EXP;
}
else if ( "lesser".equals( operator ) )
{
exp.typ = LESSER_EXP;
}
else if ( "xor".equals( operator ) )
{
exp.typ = XOR_EXP;
}
else
{
nops = 1; // check unary expressions
@ -231,13 +247,16 @@ final class BExpression
switch( typ )
{
case OR_EXP: return op1.evaluate(ctx) != 0.f ? 1.f : ( op2.evaluate(ctx) != 0.f ? 1.f : 0.f );
case XOR_EXP: return ( (op1.evaluate(ctx) != 0.f) ^ ( op2.evaluate(ctx) != 0.f ) ? 1.f : 0.f );
case AND_EXP: return op1.evaluate(ctx) != 0.f ? ( op2.evaluate(ctx) != 0.f ? 1.f : 0.f ) : 0.f;
case ADD_EXP: return op1.evaluate(ctx) + op2.evaluate(ctx);
case SUB_EXP: return op1.evaluate(ctx) - op2.evaluate(ctx);
case MULTIPLY_EXP: return op1.evaluate(ctx) * op2.evaluate(ctx);
case MAX_EXP: return max( op1.evaluate(ctx), op2.evaluate(ctx) );
case MIN_EXP: return min( op1.evaluate(ctx), op2.evaluate(ctx) );
case EQUAL_EXP: return op1.evaluate(ctx) == op2.evaluate(ctx) ? 1.f : 0.f;
case GREATER_EXP: return op1.evaluate(ctx) > op2.evaluate(ctx) ? 1.f : 0.f;
case LESSER_EXP: return op1.evaluate(ctx) < op2.evaluate(ctx) ? 1.f : 0.f;
case SWITCH_EXP: return op1.evaluate(ctx) != 0.f ? op2.evaluate(ctx) : op3.evaluate(ctx);
case ASSIGN_EXP: return ctx.assign( variableIdx, op1.evaluate(ctx) );
case LOOKUP_EXP: return ctx.getLookupMatch( lookupNameIdx, lookupValueIdxArray );