39 lines
1006 B
Java
39 lines
1006 B
Java
package io.gitlab.jfronny.muscript.ast.literal;
|
|
|
|
import io.gitlab.jfronny.commons.StringFormatter;
|
|
import io.gitlab.jfronny.muscript.compiler.ExprWriter;
|
|
import io.gitlab.jfronny.muscript.compiler.Order;
|
|
import io.gitlab.jfronny.muscript.data.Scope;
|
|
import io.gitlab.jfronny.muscript.ast.NumberExpr;
|
|
|
|
import java.io.IOException;
|
|
|
|
public final class NumberLiteral extends NumberExpr {
|
|
public final double value;
|
|
|
|
public NumberLiteral(int chStart, int chEnd, double value) {
|
|
super(Order.Primary, chStart, chEnd);
|
|
this.value = value;
|
|
}
|
|
|
|
@Override
|
|
public Double get(Scope dataRoot) {
|
|
return value;
|
|
}
|
|
|
|
@Override
|
|
public NumberExpr optimize() {
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public void decompile(ExprWriter writer) throws IOException {
|
|
writer.append(StringFormatter.toString(value));
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
return obj instanceof NumberLiteral literal && value == literal.value;
|
|
}
|
|
}
|