Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing builtin methods from Any #12155

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
private

println message ends_with = @Builtin_Method "IO.println"
any_to_text obj = @Builtin_Method "Any.to_text"
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.=="
Loading