fix: int value not correctly recognized
This commit is contained in:
parent
9b957335bf
commit
0670ffcdd1
@ -383,6 +383,15 @@ public class SimpleRepl {
|
|||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
|
return Value.UNDEFINED;
|
||||||
|
}));
|
||||||
|
glob.defineOwnMember(null, "measure", new NativeFunction("measure", args -> {
|
||||||
|
var start = System.nanoTime();
|
||||||
|
|
||||||
|
((FunctionValue)args.get(0)).invoke(args.env, Value.UNDEFINED);
|
||||||
|
|
||||||
|
System.out.println(String.format("Finished in %sns", System.nanoTime() - start));
|
||||||
|
|
||||||
return Value.UNDEFINED;
|
return Value.UNDEFINED;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -522,6 +522,7 @@ public abstract class Value {
|
|||||||
else if (this instanceof VoidValue) return ((VoidValue)this).name;
|
else if (this instanceof VoidValue) return ((VoidValue)this).name;
|
||||||
else if (this instanceof StringValue) return JSON.stringify(JSONElement.string(((StringValue)this).value));
|
else if (this instanceof StringValue) return JSON.stringify(JSONElement.string(((StringValue)this).value));
|
||||||
else if (this instanceof SymbolValue) return this.toString();
|
else if (this instanceof SymbolValue) return this.toString();
|
||||||
|
else if (this instanceof NumberValue num && num.isLong()) return num.getLong() + "i";
|
||||||
else return this.toString(env);
|
else return this.toString(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ public final class IntValue extends NumberValue {
|
|||||||
public final long value;
|
public final long value;
|
||||||
|
|
||||||
@Override public boolean isInt() {
|
@Override public boolean isInt() {
|
||||||
return (value & 0xFFFFFFFF00000000l) == 0;
|
return (int)value == value;
|
||||||
}
|
}
|
||||||
@Override public boolean isLong() {
|
@Override public boolean isLong() {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user