From e956b941f907ebf19a507f43a6838e557a4a3d80 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 27 Jan 2025 11:50:18 +0100 Subject: [PATCH 1/3] Removing builtin methods from Any --- distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso | 11 ++++++----- .../Base/0.0.0-dev/src/Internal/Any_Helpers.enso | 7 +++++++ .../Base/0.0.0-dev/src/Internal/IO_Helpers.enso | 1 + .../node/expression/builtin/error/CatchAnyNode.java | 4 ++-- .../expression/builtin/meta/EqualsBuiltinNode.java | 6 +++--- .../node/expression/builtin/text/AnyPrettyNode.java | 2 +- .../expression/builtin/text/AnyToDisplayTextNode.java | 2 +- .../node/expression/builtin/text/AnyToTextNode.java | 2 +- 8 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso index 0f0196181e4c..7e2fe1c86f42 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso @@ -9,6 +9,7 @@ import project.Meta import project.Nothing.Nothing import project.Panic.Panic import project.Warning.Warning +import project.Internal.Any_Helpers from project.Data.Boolean import Boolean, False, True from project.Data.Ordering import all from project.Data.Range.Extensions import all @@ -76,7 +77,7 @@ type Any 7.to_text to_text : Text - to_text self = @Builtin_Method "Any.to_text" + to_text self = Any_Helpers.any_to_text self ## GROUP convert ICON enso_logo @@ -96,7 +97,7 @@ type Any ## Returns a Text 'Hello World!' pretty : Text - pretty self = @Builtin_Method "Any.pretty" + pretty self = Any_Helpers.any_pretty self ## PRIVATE Generic conversion of an arbitrary Enso value to a corresponding short @@ -107,7 +108,7 @@ type Any 7.to_display_text to_display_text : Text - to_display_text self = @Builtin_Method "Any.to_display_text" + to_display_text self = Any_Helpers.any_to_display_text self ## ALIAS equals GROUP Operators @@ -156,7 +157,7 @@ type Any a = 7 * 21 a == 147 == : Any -> Boolean - == self that = @Builtin_Method "Any.==" + == self that = Any_Helpers.any_equals self that ## ALIAS not equals GROUP Operators @@ -384,7 +385,7 @@ type Any Arguments: - handler: The function to call on this if it is an error value. catch_primitive : (Error -> Any) -> Any - catch_primitive self handler = @Builtin_Method "Any.catch_primitive" + catch_primitive self handler = Any_Helpers.any_catch_primitive self handler ## ICON column_add Transforms an error. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso new file mode 100644 index 000000000000..35261706f393 --- /dev/null +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso @@ -0,0 +1,7 @@ +private + +any_equals o1 o2 = @Builtin_Method "Any.==" +any_to_text obj = @Builtin_Method "Any.to_text" +any_to_display_text obj = @Builtin_Method "Any.to_display_text" +any_pretty obj = @Builtin_Method "Any.pretty" +any_catch_primitive obj handler = @Builtin_Method "Any.catch_primitive" \ No newline at end of file diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/IO_Helpers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/IO_Helpers.enso index f5f31e4cb855..9eb7172dc7c0 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/IO_Helpers.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/IO_Helpers.enso @@ -1,3 +1,4 @@ private println message ends_with = @Builtin_Method "IO.println" +any_to_text obj = @Builtin_Method "Any.to_text" diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchAnyNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchAnyNode.java index 6523dca58061..053698df1efc 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchAnyNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/error/CatchAnyNode.java @@ -24,7 +24,7 @@ public class CatchAnyNode extends Node { this.invokeCallableNode.setTailStatus(BaseNode.TailStatus.TAIL_DIRECT); } - Object execute(Object self, Object handler) { - return self; + Object execute(Object obj, Object handler) { + return obj; } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsBuiltinNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsBuiltinNode.java index 2f4789ad5882..8d400cb4e204 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsBuiltinNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsBuiltinNode.java @@ -41,12 +41,12 @@ static EqualsBuiltinNode build() { * Compares two objects for equality. * * @param frame the stack frame we are executing at - * @param self the self object + * @param obj the self object * @param other the other object * @return {@code true} if {@code self} and {@code that} seem equal */ - public Object execute(VirtualFrame frame, Object self, Object other) { - var areEqual = node.execute(frame, self, other); + public Object execute(VirtualFrame frame, Object obj, Object other) { + var areEqual = node.execute(frame, obj, other); if (areEqual.getWarnings() != null) { if (append == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyPrettyNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyPrettyNode.java index 2d1301804798..63e0d3f2bf2d 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyPrettyNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyPrettyNode.java @@ -24,7 +24,7 @@ public static AnyPrettyNode build() { return AnyPrettyNodeGen.create(); } - public abstract Text execute(Object self); + public abstract Text execute(Object obj); @Specialization Text doAtom(Atom at) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToDisplayTextNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToDisplayTextNode.java index 29677b9b90f0..88b450c286f6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToDisplayTextNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToDisplayTextNode.java @@ -25,7 +25,7 @@ static AnyToDisplayTextNode build() { return AnyToDisplayTextNodeGen.create(); } - abstract Text execute(Object self); + abstract Text execute(Object obj); @Specialization(guards = {"iop.isException(self)", "iop.hasExceptionMessage(self)"}) Text showExceptions(Object self, @Shared("iop") @CachedLibrary(limit = "3") InteropLibrary iop) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToTextNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToTextNode.java index d398f7fe4456..1f397e546330 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToTextNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/text/AnyToTextNode.java @@ -22,7 +22,7 @@ public static AnyToTextNode build() { return AnyToTextNodeGen.create(); } - public abstract Text execute(Object self); + public abstract Text execute(Object obj); @Specialization Text doAtom(Atom at) { From 22abb542bd6a66678286e0bc6464b3ccf2fc737a Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Mon, 27 Jan 2025 12:03:24 +0100 Subject: [PATCH 2/3] Ajusting micro distribution --- .../lib/Standard/Base/0.0.0-dev/src/Any.enso | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/micro-distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso b/test/micro-distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso index e74970f4350d..1f7a8febd083 100644 --- a/test/micro-distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso +++ b/test/micro-distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso @@ -2,11 +2,11 @@ import project.Data.Boolean.Boolean.False @Builtin_Type type Any - catch_primitive handler = @Builtin_Method "Any.catch_primitive" - to_text self = @Builtin_Method "Any.to_text" - to_display_text self = @Builtin_Method "Any.to_display_text" + catch_primitive self handler = any_catch_primitive self handler + to_text self = any_to_text self + to_display_text self = any_to_display_text self is_error self = False - == self other = @Builtin_Method "Any.==" + == self other = any_equals self other != self other = (self == other).not < self other = Default_Comparator.less_than_builtin self other <= self other = Default_Comparator.less_than_builtin self other || Any.== self other @@ -18,3 +18,8 @@ type Default_Comparator ## PRIVATE less_than_builtin left right = @Builtin_Method "Default_Comparator.less_than_builtin" + +any_to_text obj = @Builtin_Method "Any.to_text" +any_to_display_text obj = @Builtin_Method "Any.to_display_text" +any_catch_primitive obj handler = @Builtin_Method "Any.catch_primitive" +any_equals o1 o2 = @Builtin_Method "Any.==" From 699c34729ca79887c05d4c71e9f8bdb3707a42d1 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Thu, 30 Jan 2025 14:51:36 +0100 Subject: [PATCH 3/3] New line at the end of file Co-authored-by: AdRiley --- .../lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso index 35261706f393..c5a908bd8078 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Any_Helpers.enso @@ -4,4 +4,4 @@ any_equals o1 o2 = @Builtin_Method "Any.==" any_to_text obj = @Builtin_Method "Any.to_text" any_to_display_text obj = @Builtin_Method "Any.to_display_text" any_pretty obj = @Builtin_Method "Any.pretty" -any_catch_primitive obj handler = @Builtin_Method "Any.catch_primitive" \ No newline at end of file +any_catch_primitive obj handler = @Builtin_Method "Any.catch_primitive"