Skip to content

Commit

Permalink
Better resolution of a conflict in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Jan 22, 2025
1 parent e776053 commit fb3196f
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 29 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
- [Allow using `/` to access files inside a directory reached through a data
link.][11926]
- [Reducing helper methods in `Standard.Base.Meta`.][12031]

[11926]: https://github.com/enso-org/enso/pull/11926
[12031]: https://github.com/enso-org/enso/pull/12031
- [Added Table.Offset][12071]

[11926]: https://github.com/enso-org/enso/pull/11926
[12031]: https://github.com/enso-org/enso/pull/12031
[12071]: https://github.com/enso-org/enso/pull/12071

#### Enso Language & Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type_of_builtin value = @Builtin_Method "Meta.type_of"
get_annotation_builtin target method parameter_name = @Builtin_Method "Meta.get_annotation"
find_atom_constructor_builtin value = @Builtin_Method "Meta.find_atom_constructor"
get_kind_builtin value = @Builtin_Method "Meta.get_kind_builtin"
get_simple_type_name_builtin value = @Builtin_Method "Meta.get_simple_type_name"
simple_type_name_builtin value = @Builtin_Method "Meta.simple_name_builtin"
get_qualified_type_name_builtin value = @Builtin_Method "Meta.get_qualified_type_name"
get_short_type_name_builtin typ = @Builtin_Method "Meta.get_short_type_name"
get_constructor_declaring_type_builtin constructor = @Builtin_Method "Meta.get_constructor_declaring_type"
Expand Down
25 changes: 18 additions & 7 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Meta.enso
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ type Type
c = self.value
@Tail_Call Meta_Helpers.get_qualified_type_name_builtin c

## ADVANCED
GROUP Metadata
ICON metadata

Returns the simplified name of the type.
simple_name self -> Text = self.name
# c = self.value
# @Tail_Call Meta_Helpers.simple_type_name_builtin c

## ADVANCED
GROUP Metadata
ICON metadata
Expand Down Expand Up @@ -390,16 +399,18 @@ is_polyglot value -> Boolean = 3 == Meta_Helpers.get_kind_builtin value

## PRIVATE

Displays the type of the provided value as text.
Returns the fully qualified type name of the given value.

Arguments:
- value: The value for which to display the type.
get_simple_type_name value -> Text = @Tail_Call Meta_Helpers.get_simple_type_name_builtin value
- value: the value to get the type of.
get_qualified_type_name value -> Text = @Tail_Call Meta_Helpers.get_qualified_type_name_builtin value

## PRIVATE

Returns the fully qualified type name of the given value.
##
Converts any value to its type

Arguments:
- value: the value to get the type of.
get_qualified_type_name value -> Text = @Tail_Call Meta_Helpers.get_qualified_type_name_builtin value
- value: the value to get the type of
Type.from (that:Any) = if is_type that then Type.Value that else
typ = Meta.type_of that
Type.Value typ
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Header
_ : Pair -> Header.new (h.at 0) (h.at 1)
_ : Function -> h:Header
_ : Header -> h
_ -> Error.throw (Illegal_Argument.Error "Invalid header type - all values must be Vector, Pair or Header (got "+(Meta.get_simple_type_name h)+").")
_ -> Error.throw (Illegal_Argument.Error "Invalid header type - all values must be Vector, Pair or Header (got "+(h.to Meta.Type . simple_name)+").")

## PRIVATE
A type representing a header.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public void numbersAreEitherIntegerOrFloat() throws Exception {
"""
from Standard.Base import Meta
sn v = Meta.get_simple_type_name v
sn v = v.to Meta.Type . simple_name
""")
.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "sn");
for (var v : g.numbers()) {
Expand Down Expand Up @@ -311,7 +311,7 @@ public void compareQualifiedAndSimpleTypeName() throws Exception {
"""
from Standard.Base import Meta
sn v = Meta.get_simple_type_name v
sn v = v.to Meta.Type . simple_name
""")
.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "sn");
var sb = new StringBuilder();
Expand Down Expand Up @@ -388,7 +388,7 @@ private boolean compareQualifiedNameOfValue(Value sn, Value v, StringBuilder sb)
sb.append("\n")
.append("Simple names shall be the same for ")
.append(v)
.append(" get_simple_type_name: ")
.append(" Enso simple name: ")
.append(simpleName)
.append(" getMetaSimpleName: ")
.append(metaName);
Expand All @@ -405,7 +405,7 @@ public void compareQualifiedAndSimpleTypeNameForTypes() throws Exception {
"""
from Standard.Base import Meta
sn v = Meta.get_simple_type_name v
sn v = v.to Meta.Type . simple_name
""")
.invokeMember(MethodNames.Module.EVAL_EXPRESSION, "sn");
var sb = new StringBuilder();
Expand All @@ -426,7 +426,7 @@ public void compareQualifiedAndSimpleTypeNameForTypes() throws Exception {
sb.append("\n")
.append("Simple names shall be the same for ")
.append(typ)
.append(" get_simple_type_name: ")
.append(" Enso simple name: ")
.append(simpleName)
.append(" getMetaSimpleName: ")
.append(metaName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.enso.interpreter.node.expression.builtin.meta;

import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.AcceptsError;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.text.util.TypeToDisplayTextNode;
import org.enso.interpreter.runtime.data.text.Text;

import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.nodes.Node;

@BuiltinMethod(
type = "Meta",
name = "get_simple_type_name",
name = "simple_name_builtin",
description = "Pretty prints a type.",
autoRegister = false)
public class GetSimpleTypeNameNode extends Node {
Expand Down
2 changes: 1 addition & 1 deletion test/Base_Tests/src/Data/Array_Proxy_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ add_specs suite_builder =
_ -> "other"
ok_match . should_equal "Array"
Meta.get_qualified_type_name proxy . should_equal "Standard.Base.Data.Array.Array"
Meta.get_simple_type_name proxy . should_equal "Array"
proxy.to Meta.Type . simple_name . should_equal "Array"

main filter=Nothing =
suite = Test.build suite_builder->
Expand Down
2 changes: 1 addition & 1 deletion test/Base_Tests/src/Data/Vector_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ type_spec suite_builder name alter = suite_builder.group name group_builder->
vec.slice 0 100 . should_equal [1, 2, 3, 4, 5, 6]

Meta.get_qualified_type_name (vec.slice 1 1) . should_equal (Meta.meta Vector . qualified_name)
Meta.get_simple_type_name (vec.slice 1 1) . should_equal "Vector"
(vec.slice 1 1) . to Meta.Type . simple_name . should_equal "Vector"

group_builder.specify "should define take and drop family of operations" <|
vec = alter [1, 2, 3, 4, 5, 6]
Expand Down
4 changes: 2 additions & 2 deletions test/Base_Tests/src/Runtime/Stack_Traces_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ add_specs suite_builder = suite_builder.group "Stack traces" group_builder->
out . should_contain "f5"

group_builder.specify "should capture traces correctly" <|
modname = Meta.get_simple_type_name Stack_Traces_Spec
modname = Stack_Traces_Spec.to Meta.Type . simple_name
stack = My_Type.foo
names = [modname + ".bar", modname + ".baz", "Number.foo", modname + ".foo", "My_Type.foo"]
stack.take (..First 5) . map .name . should_equal names
file = enso_project.root / 'src' / 'Runtime' / 'Stack_Traces_Spec.enso'
stack.take (..First 5) . map (.source_location >> .file) . each (_.should_equal file)

group_builder.specify "should respect Runtime.Context.Dataflow_Stack_Trace (for error thrown from Enso)" <|
modname = Meta.get_simple_type_name Stack_Traces_Spec
modname = Stack_Traces_Spec.to Meta.Type . simple_name
names = [modname + ".deep_e", modname + ".deep_d", modname + ".deep_c", modname + ".deep_b", modname + ".deep_a"]

shallow_stack_trace = deep_a.stack_trace
Expand Down
4 changes: 2 additions & 2 deletions test/Base_Tests/src/Semantic/Meta_Location_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil
x = 42
y = My_Type.Value 1 2 3
Meta.get_qualified_type_name x . should_equal "Standard.Base.Data.Numbers.Integer"
Meta.get_simple_type_name x . should_equal "Integer"
x.to Meta.Type . simple_name . should_equal "Integer"
Meta.get_qualified_type_name y . should_equal "enso_dev.Base_Tests.Semantic.Meta_Location_Spec.My_Type"
Meta.get_simple_type_name y . should_equal "My_Type"
y.to Meta.Type . simple_name . should_equal "My_Type"

group_builder.specify "should allow access to package names" <|
enso_project.name.should_equal 'Base_Tests'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ add_column_operation_specs suite_builder setup =
converters.map converter->
const_float = 3.0
constant = converter const_float
Test.with_clue " constant: "+(Meta.get_simple_type_name constant) <|
Test.with_clue " constant: "+(constant.to Meta.Type . simple_name) <|
(x == constant).to_vector . should_equal [False, False, False, Nothing]
(x != constant).to_vector . should_equal [True, True, True, Nothing]
(y == constant).to_vector . should_equal [False, True, False, Nothing]
Expand All @@ -734,7 +734,7 @@ add_column_operation_specs suite_builder setup =
[6.5, 1000.5].map const_float->
converters.map converter->
constant = converter const_float
Test.with_clue " constant: "+(Meta.get_simple_type_name constant) <|
Test.with_clue " constant: "+(constant.to Meta.Type . simple_name) <|
(x < -constant).to_vector . should_equal [False, False, False, Nothing]
(x < constant).to_vector . should_equal [True, True, True, Nothing]
(x <= -constant).to_vector . should_equal [False, False, False, Nothing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ add_specs suite_builder =
expect_type_representation value expected_text =
type_name = Meta.get_qualified_type_name value . to_text
type_name . should_equal <| expected_text
simple_name = Meta.get_simple_type_name value . to_text
simple_name = value.to Meta.Type . simple_name . to_text
type_name . ends_with simple_name . should_be_true

suite_builder.group "Type Names of Visualization Defaults" group_builder->
Expand Down

0 comments on commit fb3196f

Please sign in to comment.