mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-08 14:37:40 +00:00
Renamed calculate() to calculateLiteral()
This commit is contained in:
parent
ec791672ce
commit
cfa3ab9047
@ -11,7 +11,7 @@ public class OperatorAddressOf extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
throw new CompileError("Not implemented");
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,6 @@ public abstract class OperatorBinary extends Operator {
|
||||
super(operator, asmOperator, Type.BINARY, precedence);
|
||||
}
|
||||
|
||||
public abstract ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right);
|
||||
public abstract ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right);
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorBoolAnd extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() & ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorBoolNot extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left) {
|
||||
if(left instanceof ConstantInteger) {
|
||||
return new ConstantInteger(~((ConstantInteger) left).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorBoolOr extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() | ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorBoolXor extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() ^ ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorCastByte extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xff & ((ConstantInteger) value).getValue());
|
||||
} else if(value instanceof ConstantPointer) {
|
||||
|
@ -12,7 +12,7 @@ public class OperatorCastDWord extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xffffffffL & ((ConstantInteger) value).getValue());
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class OperatorCastPtrByte extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.BYTE);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorCastSByte extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xff & ((ConstantInteger) value).getValue());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorCastSDWord extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xffffffffL & ((ConstantInteger) value).getValue());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorCastSWord extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xffff & ((ConstantInteger) value).getValue());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorCastWord extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral value) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral value) {
|
||||
if(value instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0xffff & ((ConstantInteger) value).getValue());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorDWord extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0x10000 * ((ConstantInteger) left).getInteger() + ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorDecrement extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger ) {
|
||||
return new ConstantInteger(((ConstantInteger) operand).getInteger() -1);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class OperatorDeref extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
throw new CompileError("Not implemented");
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public class OperatorDerefIdx extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
throw new CompileError("Not implemented");
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorDivide extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() / ((ConstantInteger) right).getInteger());
|
||||
} else if(left instanceof ConstantPointer && right instanceof ConstantInteger) {
|
||||
|
@ -15,7 +15,7 @@ public class OperatorEqual extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(Objects.equals(((ConstantInteger) left).getInteger(), ((ConstantInteger) right).getInteger()));
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ public class OperatorGetHigh extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger) {
|
||||
ConstantInteger operandInt = (ConstantInteger) operand;
|
||||
if(SymbolType.isWord(operandInt.getType())) {
|
||||
|
@ -14,7 +14,7 @@ public class OperatorGetLow extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger) {
|
||||
ConstantInteger operandInt = (ConstantInteger) operand;
|
||||
if(SymbolType.isWord(operandInt.getType())) {
|
||||
|
@ -13,7 +13,7 @@ public class OperatorGreaterThan extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(((ConstantInteger) left).getInteger() > ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorGreaterThanEqual extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(((ConstantInteger) left).getInteger() >= ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorIncrement extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger ) {
|
||||
return new ConstantInteger(((ConstantInteger) operand).getInteger() + 1);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorLessThan extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(((ConstantInteger) left).getInteger() < ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class OperatorLessThanEqual extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(((ConstantInteger) left).getInteger() <= ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorLogicAnd extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantBool && right instanceof ConstantBool) {
|
||||
return new ConstantBool(((ConstantBool) left).getBool() && ((ConstantBool) right).getBool());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorLogicNot extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left) {
|
||||
if(left instanceof ConstantBool) {
|
||||
return new ConstantBool(!((ConstantBool) left).getBool() );
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorLogicOr extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantBool && right instanceof ConstantBool) {
|
||||
return new ConstantBool(((ConstantBool) left).getBool() || ((ConstantBool) right).getBool());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorMinus extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() - ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorMultiply extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() * ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorNeg extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger) {
|
||||
return new ConstantInteger(-((ConstantInteger)operand).getInteger());
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class OperatorNotEqual extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantBool(!Objects.equals(((ConstantInteger) left).getInteger(), ((ConstantInteger) right).getInteger()));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorPlus extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(((ConstantInteger) left).getInteger() + ((ConstantInteger) right).getInteger());
|
||||
} else if(left instanceof ConstantInteger && right instanceof ConstantChar) {
|
||||
|
@ -12,7 +12,7 @@ public class OperatorPos extends OperatorUnary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral operand) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral operand) {
|
||||
if(operand instanceof ConstantInteger) {
|
||||
return new ConstantInteger(+((ConstantInteger)operand).getInteger());
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class OperatorSetHigh extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
throw new CompileError("Not implemented");
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class OperatorSetLow extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
throw new CompileError("Not implemented");
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ public class OperatorShiftLeft extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger( ((ConstantInteger) left).getInteger() << ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorShiftRight extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger( ((ConstantInteger) left).getInteger() >> ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ public abstract class OperatorUnary extends Operator {
|
||||
super(operator, asmOperator, Type.UNARY, precedence);
|
||||
}
|
||||
|
||||
public abstract ConstantLiteral calculate(ConstantLiteral operand);
|
||||
public abstract ConstantLiteral calculateLiteral(ConstantLiteral operand);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class OperatorWord extends OperatorBinary {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantLiteral calculate(ConstantLiteral left, ConstantLiteral right) {
|
||||
public ConstantLiteral calculateLiteral(ConstantLiteral left, ConstantLiteral right) {
|
||||
if(left instanceof ConstantInteger && right instanceof ConstantInteger) {
|
||||
return new ConstantInteger(0x100 * ((ConstantInteger) left).getInteger() + ((ConstantInteger) right).getInteger());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user