forked from JavaTX/JavaCompilerCore
69 lines
1.6 KiB
Java
69 lines
1.6 KiB
Java
package de.dhbwstuttgart.target.tree.expression;
|
|
|
|
import de.dhbwstuttgart.target.tree.type.TargetType;
|
|
|
|
public sealed interface TargetLiteral extends TargetExpression {
|
|
Object value();
|
|
|
|
record BooleanLiteral(Boolean value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Boolean;
|
|
}
|
|
}
|
|
|
|
record CharLiteral(Character value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Char;
|
|
}
|
|
}
|
|
|
|
record IntLiteral(Integer value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Integer;
|
|
}
|
|
}
|
|
|
|
record LongLiteral(Long value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Long;
|
|
}
|
|
}
|
|
|
|
record FloatLiteral(Float value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Float;
|
|
}
|
|
}
|
|
|
|
record DoubleLiteral(Double value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Double;
|
|
}
|
|
}
|
|
|
|
record StringLiteral(String value) implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.String;
|
|
}
|
|
}
|
|
|
|
record Null() implements TargetLiteral {
|
|
@Override
|
|
public TargetType type() {
|
|
return TargetType.Object;
|
|
}
|
|
|
|
@Override
|
|
public Object value() {
|
|
return null;
|
|
}
|
|
}
|
|
}
|