diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Numbers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Numbers.enso index 083e0c4f8191..c107a5b7d0a5 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Numbers.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Numbers.enso @@ -457,54 +457,6 @@ type Decimal ^ : Number -> Number ^ self that = @Builtin_Method "Decimal.^" - ## Checks if this is greater than that. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is greater than 7.3. - - 10 > 7.3 - > : Number -> Boolean - > self that = @Builtin_Method "Decimal.>" - - ## Checks if this is greater than or equal to thatthat. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is greater than or equal to 7.3. - - 10 >= 7.3 - >= : Number -> Boolean - >= self that = @Builtin_Method "Decimal.>=" - - ## Checks if this is less than that. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is less than 7.3. - - 10 < 7.3 - < : Number -> Boolean - < self that = @Builtin_Method "Decimal.<" - - ## Checks if this is less than or equal to thatthat. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10.4 is less than or equal to 7. - - 10.4 <= 7 - <= : Number -> Boolean - <= self that = @Builtin_Method "Decimal.<=" - ## Computes the absolute value of this. The absolute value of a positive number is itself, while the absolute @@ -682,54 +634,6 @@ type Integer ^ : Number -> Number ^ self that = @Builtin_Method "Integer.^" - ## Checks if this is greater than that. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is greater than 7. - - 10 > 7 - > : Number -> Boolean - > self that = @Builtin_Method "Integer.>" - - ## Checks if this is greater than or equal to thatthat. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is greater than or equal to 7. - - 10 >= 7 - >= : Number -> Boolean - >= self that = @Builtin_Method "Integer.>=" - - ## Checks if this is less than that. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is less than 7. - - 10 < 7 - < : Number -> Boolean - < self that = @Builtin_Method "Integer.<" - - ## Checks if this is less than or equal to thatthat. - - Arguments: - - that: The number to compare this against. - - > Example - Checking if 10 is less than or equal to 7. - - 10 <= 7 - <= : Number -> Boolean - <= self that = @Builtin_Method "Integer.<=" - ## Computes the absolute value of this. The absolute value of a positive number is itself, while the absolute @@ -937,6 +841,7 @@ type Integer parse_builtin text radix = @Builtin_Method "Integer.parse" + ## UNSTABLE A syntax error when parsing a double. diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterNode.java deleted file mode 100644 index 963c004ec802..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.bigInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Big_Integer", name = ">", description = "Comparison of numbers.") -public abstract class GreaterNode extends Node { - - abstract Object execute(EnsoBigInteger self, Object that); - - static GreaterNode build() { - return GreaterNodeGen.create(); - } - - @Specialization - boolean doDouble(EnsoBigInteger self, double that) { - return BigIntegerOps.toDouble(self.getValue()) > that; - } - - @Specialization - boolean doLong(EnsoBigInteger self, long that) { - return self.getValue().signum() > 0; - } - - @Specialization - boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) { - return BigIntegerOps.compare(self.getValue(), that.getValue()) > 0; - } - - @Fallback - DataflowError doOther(EnsoBigInteger self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterOrEqualNode.java deleted file mode 100644 index c615457d1a15..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/GreaterOrEqualNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.bigInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Big_Integer", name = ">=", description = "Comparison of numbers.") -public abstract class GreaterOrEqualNode extends Node { - - abstract Object execute(EnsoBigInteger self, Object that); - - static GreaterOrEqualNode build() { - return GreaterOrEqualNodeGen.create(); - } - - @Specialization - boolean doDouble(EnsoBigInteger self, double that) { - return BigIntegerOps.toDouble(self.getValue()) >= that; - } - - @Specialization - boolean doLong(EnsoBigInteger self, long that) { - return self.getValue().signum() > 0; - } - - @Specialization - boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) { - return BigIntegerOps.compare(self.getValue(), that.getValue()) >= 0; - } - - @Fallback - DataflowError doOther(EnsoBigInteger self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessNode.java deleted file mode 100644 index 71e4a55e74ac..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.bigInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Big_Integer", name = "<", description = "Comparison of numbers.") -public abstract class LessNode extends Node { - - abstract Object execute(EnsoBigInteger self, Object that); - - static LessNode build() { - return LessNodeGen.create(); - } - - @Specialization - boolean doDouble(EnsoBigInteger self, double that) { - return BigIntegerOps.toDouble(self.getValue()) < that; - } - - @Specialization - boolean doLong(EnsoBigInteger self, long that) { - return self.getValue().signum() < 0; - } - - @Specialization - boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) { - return BigIntegerOps.compare(self.getValue(), that.getValue()) < 0; - } - - @Fallback - DataflowError doOther(EnsoBigInteger self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessOrEqualNode.java deleted file mode 100644 index 5fd408ba79f7..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/bigInteger/LessOrEqualNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.bigInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Big_Integer", name = "<=", description = "Comparison of numbers.") -public abstract class LessOrEqualNode extends Node { - - abstract Object execute(EnsoBigInteger self, Object that); - - static LessOrEqualNode build() { - return LessOrEqualNodeGen.create(); - } - - @Specialization - boolean doDouble(EnsoBigInteger self, double that) { - return BigIntegerOps.toDouble(self.getValue()) <= that; - } - - @Specialization - boolean doLong(EnsoBigInteger self, long that) { - return self.getValue().signum() < 0; - } - - @Specialization - boolean doBigInteger(EnsoBigInteger self, EnsoBigInteger that) { - return BigIntegerOps.compare(self.getValue(), that.getValue()) <= 0; - } - - @Fallback - DataflowError doOther(EnsoBigInteger self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterNode.java deleted file mode 100644 index cf1d301edb4d..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.decimal; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Decimal", name = ">", description = "Comparison of numbers.") -public abstract class GreaterNode extends Node { - - abstract Object execute(double self, Object that); - - static GreaterNode build() { - return GreaterNodeGen.create(); - } - - @Specialization - boolean doDouble(double self, double that) { - return self > that; - } - - @Specialization - boolean doLong(double self, long that) { - return self > (double) that; - } - - @Specialization - boolean doBigInteger(double self, EnsoBigInteger that) { - return self > BigIntegerOps.toDouble(that.getValue()); - } - - @Fallback - DataflowError doOther(double self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterOrEqualNode.java deleted file mode 100644 index 00683e4cf399..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/GreaterOrEqualNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.decimal; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Decimal", name = ">=", description = "Comparison of numbers.") -public abstract class GreaterOrEqualNode extends Node { - - abstract Object execute(double self, Object that); - - static GreaterOrEqualNode build() { - return GreaterOrEqualNodeGen.create(); - } - - @Specialization - boolean doDouble(double self, double that) { - return self >= that; - } - - @Specialization - boolean doLong(double self, long that) { - return self >= (double) that; - } - - @Specialization - boolean doBigInteger(double self, EnsoBigInteger that) { - return self >= BigIntegerOps.toDouble(that.getValue()); - } - - @Fallback - DataflowError doOther(double self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessNode.java deleted file mode 100644 index 914f28259971..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.decimal; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Decimal", name = "<", description = "Comparison of numbers.") -public abstract class LessNode extends Node { - - abstract Object execute(double self, Object that); - - static LessNode build() { - return LessNodeGen.create(); - } - - @Specialization - boolean doDouble(double self, double that) { - return self < that; - } - - @Specialization - boolean doLong(double self, long that) { - return self < (double) that; - } - - @Specialization - boolean doBigInteger(double self, EnsoBigInteger that) { - return self < BigIntegerOps.toDouble(that.getValue()); - } - - @Fallback - DataflowError doOther(double self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessOrEqualNode.java deleted file mode 100644 index 9e58ffed5818..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/LessOrEqualNode.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.decimal; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Decimal", name = "<=", description = "Comparison of numbers.") -public abstract class LessOrEqualNode extends Node { - - abstract Object execute(double self, Object that); - - static LessOrEqualNode build() { - return LessOrEqualNodeGen.create(); - } - - @Specialization - boolean doDouble(double self, double that) { - return self <= that; - } - - @Specialization - boolean doLong(double self, long that) { - return self <= (double) that; - } - - @Specialization - boolean doBigInteger(double self, EnsoBigInteger that) { - return self <= BigIntegerOps.toDouble(that.getValue()); - } - - @Fallback - DataflowError doOther(double self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterNode.java deleted file mode 100644 index e444e925bac4..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterNode.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.smallInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Small_Integer", name = ">", description = "Comparison of numbers.") -public abstract class GreaterNode extends Node { - - abstract Object execute(long self, Object that); - - static GreaterNode build() { - return GreaterNodeGen.create(); - } - - @Specialization - boolean doLong(long self, long that) { - return self > that; - } - - @Specialization - boolean doDouble(long self, double that) { - return (double) self > that; - } - - @Specialization - boolean doBigInteger(long self, EnsoBigInteger that) { - return that.getValue().signum() < 0; - } - - @Fallback - DataflowError doOther(long self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterOrEqualNode.java deleted file mode 100644 index dcb316b7ff6d..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/GreaterOrEqualNode.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.smallInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Small_Integer", name = ">=", description = "Comparison of numbers.") -public abstract class GreaterOrEqualNode extends Node { - - abstract Object execute(long self, Object that); - - static GreaterOrEqualNode build() { - return GreaterOrEqualNodeGen.create(); - } - - @Specialization - boolean doLong(long self, long that) { - return self >= that; - } - - @Specialization - boolean doDouble(long self, double that) { - return (double) self >= that; - } - - @Specialization - boolean doBigInteger(long self, EnsoBigInteger that) { - return that.getValue().signum() < 0; - } - - @Fallback - DataflowError doOther(long self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessNode.java deleted file mode 100644 index 2bf8362b6ee3..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessNode.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.smallInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Small_Integer", name = "<", description = "Comparison of numbers.") -public abstract class LessNode extends Node { - - abstract Object execute(long self, Object that); - - static LessNode build() { - return LessNodeGen.create(); - } - - @Specialization - boolean doLong(long self, long that) { - return self < that; - } - - @Specialization - boolean doDouble(long self, double that) { - return (double) self < that; - } - - @Specialization - boolean doBigInteger(long self, EnsoBigInteger that) { - return that.getValue().signum() > 0; - } - - @Fallback - DataflowError doOther(long self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -} diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessOrEqualNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessOrEqualNode.java deleted file mode 100644 index e74a28297f9d..000000000000 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/LessOrEqualNode.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.enso.interpreter.node.expression.builtin.number.smallInteger; - -import com.oracle.truffle.api.dsl.Fallback; -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.api.nodes.Node; -import org.enso.interpreter.dsl.BuiltinMethod; -import org.enso.interpreter.runtime.EnsoContext; -import org.enso.interpreter.runtime.error.DataflowError; -import org.enso.interpreter.runtime.number.EnsoBigInteger; - -@BuiltinMethod(type = "Small_Integer", name = "<=", description = "Comparison of numbers.") -public abstract class LessOrEqualNode extends Node { - - abstract Object execute(long self, Object that); - - static LessOrEqualNode build() { - return LessOrEqualNodeGen.create(); - } - - @Specialization - boolean doLong(long self, long that) { - return self <= that; - } - - @Specialization - boolean doDouble(long self, double that) { - return (double) self <= that; - } - - @Specialization - boolean doBigInteger(long self, EnsoBigInteger that) { - return that.getValue().signum() > 0; - } - - @Fallback - DataflowError doOther(long self, Object that) { - var builtins = EnsoContext.get(this).getBuiltins(); - var typeError = builtins.error().makeTypeError(builtins.number().getNumber(), that, "that"); - return DataflowError.withoutTrace(typeError, this); - } -}