1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Renamed calculate() to calculateLiteral()

This commit is contained in:
jespergravgaard 2018-03-10 21:14:51 +01:00
parent ec791672ce
commit cfa3ab9047
41 changed files with 41 additions and 41 deletions

View File

@ -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");
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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) {

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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");
}

View File

@ -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");
}
}

View File

@ -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) {

View File

@ -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()));
}

View File

@ -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())) {

View File

@ -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())) {

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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() );
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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()));
}

View File

@ -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) {

View File

@ -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());
}

View File

@ -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");
}
}

View File

@ -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");
}

View File

@ -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());
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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());
}