Improved Vector/Array interop (#3667)

`Vector` type is now a builtin type. This requires a bunch of additional builtin methods for its creation:
- Use `Vector.from_array` to convert any array-like structure into a `Vector` [by copy](f628b28f5f)
- Use (already existing) `Vector.from_polyglot_array` to convert any array-like structure into a `Vector` **without** copying
- Use (already existing) `Vector.fill 1 item` to create a singleton `Vector`

Additional, for pattern matching purposes, we had to implement a `VectorBranchNode`. Use following to match on `x` being an instance of `Vector` type:
```
import Standard.Base.Data.Vector

size = case x of
Vector.Vector -> x.length
_ -> 0
```

Finally, `VectorLiterals` pass that transforms `[1,2,3]` to (roughly)
```
a1 = 1
a2 = 2
a3 = 3
Vector (Array (a1,a2, a3))
```
had to be modified to generate
```
a1 = 1
a2 = 2
a3 = 3
Vector.from_array (Array (a1, a2, a3))
```
instead to accomodate to the API changes. As of 025acaa676 all the known CI checks passes. Let's start the review.

# Important Notes
Matching in `case` statement is currently done via `Vector_Data`. Use:
```
case x of
Vector.Vector_Data -> True
```
until a better alternative is found.
This commit is contained in:
Hubert Plociniczak 2022-09-13 05:07:17 +02:00 committed by GitHub
parent fa2e42c4e7
commit fba5047acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
161 changed files with 1396 additions and 651 deletions

View File

@ -60,6 +60,7 @@
could cause issues with starting further IDE instances.
- [New nodes are created in the project source when the searcher is opened and a
new node is created.][3645]
- [Proper Polyglot Vector and Array Support][3667]
- [IDE uses new visualization API.][3661]
- [Visualization of long textual values improved][3665]
@ -303,6 +304,7 @@
[3661]: https://github.com/enso-org/enso/pull/3661
[3665]: https://github.com/enso-org/enso/pull/3665
[3634]: https://github.com/enso-org/enso/pull/3634
[3667]: https://github.com/enso-org/enso/pull/3667
[3669]: https://github.com/enso-org/enso/pull/3669
[3647]: https://github.com/enso-org/enso/pull/3647
[3673]: https://github.com/enso-org/enso/pull/3673

View File

@ -1,4 +1,8 @@
import Standard.Base.Data.Vector
import Standard.Base.Data.Range
from Standard.Base.Data.Boolean import False, Boolean
import Standard.Base.Error.Common
import Standard.Base.Meta
## The type of primitive mutable arrays.
@Builtin_Type
@ -49,6 +53,21 @@ type Array
to_array : Array
to_array self = @Builtin_Method "Array.to_array"
## Checks whether this array is equal to `that`.
Arguments:
- that: The array to compare this array against.
Two arrays are considered equal, when they have the same length and
their items are pairwise equal.
== : Array -> Boolean
== self that =
if Meta.is_same_object Array self then Meta.is_same_object Array that else
eq_at i = self.at i == that.at i
Common.Panic.catch_primitive handler=(_ -> False)
if self.length == that.length then 0.up_to self.length . all eq_at else False
## UNSTABLE
ADVANCED
@ -64,7 +83,7 @@ type Array
[1, 2, 3, 4].to_array.to_default_visualization_data
to_default_visualization_data : Text
to_default_visualization_data self =
Vector.Vector_Data self . to_default_visualization_data
Vector.from_polyglot_array self . to_default_visualization_data
## Creates an array with length 0.

View File

@ -156,7 +156,7 @@ take_helper length at single_slice slice_ranges index_sub_range = case index_sub
single_slice 0 true_end
By_Index one_or_many_descriptors -> Panic.recover [Index_Out_Of_Bounds_Error_Data, Illegal_Argument_Error_Data] <|
indices = case one_or_many_descriptors of
Vector.Vector_Data _ -> one_or_many_descriptors
Vector.Vector -> one_or_many_descriptors
_ -> [one_or_many_descriptors]
trimmed = resolve_ranges indices length
slice_ranges trimmed
@ -205,7 +205,7 @@ drop_helper length at single_slice slice_ranges index_sub_range = case index_sub
single_slice true_end length
By_Index one_or_many_descriptors -> Panic.recover [Index_Out_Of_Bounds_Error_Data, Illegal_Argument_Error_Data] <|
indices = case one_or_many_descriptors of
Vector.Vector_Data _ -> one_or_many_descriptors
Vector.Vector -> one_or_many_descriptors
_ -> [one_or_many_descriptors]
trimmed = resolve_ranges indices length
normalized = normalize_ranges trimmed

View File

@ -98,7 +98,7 @@ type Json
example_into =
json = Examples.json
format = (Vector.Vector (Book title=Text (Author name=Text year_of_birth=Number)))
format = (Vector.fill 1 (Book title=Text (Author name=Text year_of_birth=Number)))
json.into format
into : Any -> Any ! Marshalling_Error
into self type_descriptor =

View File

@ -287,8 +287,8 @@ render_helper builder json = case json of
See `Json.into` for semantics documentation.
into_helper : Any -> Json -> Any
into_helper fmt json = case fmt of
Base.Vector.Vector_Data field -> case json of
Array items -> items.map (into_helper field)
Base.Vector.Vector -> case json of
Array items -> items.map (into_helper (fmt.at 0))
_ -> Panic.throw (Type_Mismatch_Error json fmt)
Base.Boolean -> case json of
Boolean v -> v

View File

@ -341,7 +341,7 @@ type Pattern
matches : Text -> Boolean
matches self input = case self.match input mode=Mode.Full of
Match_Data _ _ _ _ -> True
Vector.Vector_Data _ -> True
Vector.Vector -> True
_ -> False
## ADVANCED
@ -412,7 +412,7 @@ type Pattern
matches = self.match input mode
case matches of
Match_Data _ _ _ _ -> matches.group 0
Vector.Vector_Data _ -> matches.map (_.group 0)
Vector.Vector -> matches.map (_.group 0)
_ -> matches
## ADVANCED

View File

@ -83,7 +83,7 @@ find_codepoint_ranges text subrange =
Range_Data 0 indices.first
By_Index indices ->
case indices of
Vector.Vector_Data _ ->
Vector.Vector ->
if indices.length == 1 then resolve_index_or_range text indices.first else
batch_resolve_indices_or_ranges text indices
_ -> resolve_index_or_range text indices

View File

@ -1,12 +1,10 @@
from Standard.Base import all
import Standard.Base.Data.Index_Sub_Range
import Standard.Base.Polyglot.Proxy_Polyglot_Array
import Standard.Base.Random
import Standard.Base.Runtime.Unsafe
polyglot java import java.util.ArrayList
polyglot java import java.lang.IndexOutOfBoundsException
polyglot java import org.enso.base.Array_Utils
polyglot java import org.enso.base.Array_Builder
## Creates a new vector of the given length, initializing elements using
the provided constructor function.
@ -28,10 +26,19 @@ polyglot java import org.enso.base.Array_Utils
Vector.new my_vec.length (ix -> my_vec.at ix)
new : Number -> (Number -> Any) -> Vector Any
new length constructor =
builder = (0.up_to length).fold (new_builder length) builder-> ix->
builder.append (constructor ix)
builder.to_vector
new length constructor = @Builtin_Method "Vector.new_builtin"
## ADVANCED
Converts an array into a vector by copying content of the array.
Arguments:
- array: The array with content to copy into the new vector.
A vector allows to store an arbitrary number of elements in linear memory. It
is the recommended data structure for most applications.
from_array : Array -> Vector
from_array array = @Builtin_Method "Vector.from_array"
## Creates a new vector of the given length, filling the elements with
the provided constant.
@ -91,41 +98,27 @@ new_builder (capacity=10) = Builder.new capacity
A vector allows to store an arbitrary number of elements in linear memory. It
is the recommended data structure for most applications.
from_polyglot_array : Any -> Vector Any
from_polyglot_array arr = Vector_Data (Proxy_Polyglot_Array.Proxy_Polyglot_Array_Data arr)
from_polyglot_array array = @Builtin_Method "Vector.from_polyglot_array"
## The basic, immutable, vector type.
## The basic, immutable, vector type.
A vector allows to store an arbitrary number of elements, in linear memory.
It is the recommended data structure for most applications.
> Example
A vector containing the elements `1`, `2`, and `3`, in this order is:
[1, 2, 3]
> Example
A vector containing 50 elements, each being the number `42`, can be
created by:
Vector.fill length=50 item=42
@Builtin_Type
type Vector a
## ADVANCED
The basic, immutable, vector type.
Arguments:
- storage: The underlying storage.
A vector allows to store an arbitrary number of elements, in linear memory.
It is the recommended data structure for most applications.
> Example
A vector containing the elements `1`, `2`, and `3`, in this order is:
[1, 2, 3]
> Example
A vector containing 50 elements, each being the number `42`, can be
created by:
Vector.fill length=50 item=42
Vector_Data storage
## PRIVATE
to_array self =
arr = self.storage.to_array
case Meta.meta arr of
Meta.Primitive_Data _ -> arr
_ ->
len = self.storage.length
a = Array.new len
Array.copy arr 0 a 0 len
a
Copies content of a vector into an Array.
to_array self = @Builtin_Method "Vector.to_array"
## Returns the number of elements stored in this vector.
@ -134,8 +127,7 @@ type Vector a
[1, 2, 3, 4].length
length : Number
length self =
self.storage.length
length self = @Builtin_Method "Vector.length"
## Gets an element from the vector at a specified index (0-based).
@ -167,8 +159,7 @@ type Vector a
Thus it should only be used when the access is guaranteed to be within
bounds or with additional error handling.
unsafe_at : Integer -> Any
unsafe_at self index =
self.storage.at index
unsafe_at self index = @Builtin_Method "Vector.unsafe_at"
## Combines all the elements of the vector, by iteratively applying the
passed function with next elements of the vector.
@ -188,7 +179,7 @@ type Vector a
[0, 1, 2] . fold 0 (+)
fold : Any -> (Any -> Any -> Any) -> Any
fold self init function =
f = acc -> ix -> function acc (self.storage.at ix)
f = acc -> ix -> function acc (self.unsafe_at ix)
0.up_to self.length . fold init f
## Combines all the elements of the vector, by iteratively applying the
@ -205,7 +196,7 @@ type Vector a
[0, 1, 2] . fold_with_index 0 (s->i->e->s+i+e)
fold_with_index : Any -> (Any -> Integer -> Any -> Any) -> Any
fold_with_index self init function =
f = acc -> ix -> function acc ix (self.storage.at ix)
f = acc -> ix -> function acc ix (self.at ix)
0.up_to self.length . fold init f
## Combines all the elements of a non-empty vector using a binary operation.
@ -223,7 +214,7 @@ type Vector a
reduce self function =
case self.not_empty of
True -> if self.length == 1 then self.unsafe_at 0 else
f = acc -> ix -> function acc (self.storage.at ix)
f = acc -> ix -> function acc (self.at ix)
1.up_to self.length . fold (self.unsafe_at 0) f
False -> Error.throw Empty_Error
@ -471,7 +462,7 @@ type Vector a
self.fold 0 i-> vec->
Array.copy vec.to_array 0 arr i vec.length
i + vec.length
Vector_Data arr
Vector.from_polyglot_array arr
## Applies a function to each element of the vector, returning the vector
of results.
@ -582,9 +573,14 @@ type Vector a
[1, 2, 3] == [2, 3, 4]
== : Vector -> Boolean
== self that =
eq_at i = self.unsafe_at i == that.unsafe_at i
if self.length == that.length then 0.up_to self.length . all eq_at else False
== self that = case that of
Vector ->
eq_at i = self.unsafe_at i == that.unsafe_at i
if self.length == that.length then 0.up_to self.length . all eq_at else False
Array ->
eq_at i = self.at i == that.at i
if self.length == that.length then 0.up_to self.length . all eq_at else False
_ -> False
## Concatenates two vectors, resulting in a new vector, containing all the
elements of `self`, followed by all the elements of `that`.
@ -602,7 +598,7 @@ type Vector a
arr = Array.new (self_len + that.length)
Array.copy self.to_array 0 arr 0 self_len
Array.copy that.to_array 0 arr self_len that.length
Vector_Data arr
Vector.from_polyglot_array arr
## Add `element` to the beginning of `self` vector.
@ -667,7 +663,7 @@ type Vector a
len = slice_end - slice_start
arr = Array.new len
Array.copy self.to_array slice_start arr 0 len
Vector_Data arr
Vector.from_polyglot_array arr
## Creates a new vector with only the specified range of elements from the
input, removing any elements outside the range.
@ -888,7 +884,7 @@ type Vector a
new_vec_arr.sort compare
Vector_Data new_vec_arr
Vector.from_polyglot_array new_vec_arr
## UNSTABLE
Keeps only unique elements within the Vector, removing any duplicates.
@ -993,7 +989,7 @@ type Builder
Vector.new_builder
new : Integer -> Builder
new (capacity=10) = Builder_Data (ArrayList.new capacity)
new (capacity=10) = Builder_Data (Array_Builder.newBuilder capacity)
## Checks if this builder is empty.
is_empty : Boolean
@ -1039,7 +1035,7 @@ type Builder
## This workaround is needed because
`self.java_builder.addAll subrange.to_array` fails with
`Unsupported argument types: [Array]`.
Array_Utils.appendToArrayList self.java_builder subrange.to_array
self.java_builder.appendTo subrange.to_array
## PRIVATE
Appends a new element into this builder.

View File

@ -321,7 +321,7 @@ type Panic
Caught_Panic_Data _ internal_original_exception -> internal_original_exception
throwable -> throwable
prim_stack = Panic.primitive_get_attached_stack_trace throwable
stack_with_prims = Vector.Vector_Data prim_stack
stack_with_prims = Vector.from_polyglot_array prim_stack
stack_with_prims.map Runtime.wrap_primitive_stack_trace_element
## Takes any value, and if it is a dataflow error, throws it as a Panic,
@ -447,7 +447,7 @@ type Panic
recover : (Vector.Vector Any | Any) -> Any -> Any
recover expected_types ~action =
types_to_check = case expected_types of
Vector.Vector_Data _ -> expected_types
Vector.Vector -> expected_types
_ -> [expected_types]
Panic.catch Any action caught_panic->
is_matched = types_to_check.exists typ->

View File

@ -85,7 +85,7 @@ get_atom_fields atom = @Builtin_Method "Meta.get_atom_fields"
Returns a vector of field values of the given atom.
Atom.fields : Vector.Vector
Atom.fields self = Vector.Vector_Data (get_atom_fields self.value)
Atom.fields self = Vector.from_polyglot_array (get_atom_fields self.value)
## UNSTABLE
ADVANCED
@ -203,7 +203,7 @@ new_atom constructor fields = @Builtin_Method "Meta.new_atom"
Returns a vector of field names defined by a constructor.
Constructor.fields : Vector.Vector
Constructor.fields self = Vector.Vector_Data (get_constructor_fields self.value)
Constructor.fields self = Vector.from_polyglot_array (get_constructor_fields self.value)
## UNSTABLE
ADVANCED

View File

@ -21,7 +21,7 @@ primitive_get_stack_trace = @Builtin_Method "Runtime.primitive_get_stack_trace"
get_stack_trace : Vector.Vector Stack_Trace_Element
get_stack_trace =
prim_stack = primitive_get_stack_trace
stack_with_prims = Vector.Vector_Data prim_stack
stack_with_prims = Vector.from_polyglot_array prim_stack
stack = stack_with_prims.map wrap_primitive_stack_trace_element
# drop this frame and the one from `Runtime.primitive_get_stack_trace`
stack.drop (First 2)

View File

@ -7,7 +7,7 @@ from Standard.Base.Error.Problem_Behavior import Report_Warning
import Standard.Base.Runtime.Resource
from Standard.Base.Runtime.Resource import Managed_Resource
polyglot java import org.enso.base.Array_Utils
polyglot java import org.enso.base.Array_Builder
polyglot java import org.enso.base.Encoding_Utils
polyglot java import java.io.InputStream as Java_Input_Stream
polyglot java import java.io.OutputStream as Java_Output_Stream
@ -728,7 +728,7 @@ type File
Utility function that lists immediate children of a directory.
list_immediate_children : Vector.Vector File
list_immediate_children self = Vector.Vector_Data (self.list_immediate_children_array)
list_immediate_children self = Vector.from_polyglot_array (self.list_immediate_children_array)
## PRIVATE
@ -897,7 +897,7 @@ type Input_Stream
read_n_bytes self n = self.stream_resource . with java_stream->
handle_java_exceptions self.file <|
bytes = java_stream.readNBytes n
Vector.Vector_Data bytes
Vector.from_polyglot_array bytes
## ADVANCED
@ -963,7 +963,7 @@ type Input_Stream
with_stream_decoder self encoding on_problems action = self.stream_resource . with java_stream->
java_charset = encoding.to_java_charset
results = Encoding_Utils.with_stream_decoder java_stream java_charset action
problems = Vector.Vector_Data results.problems . map Encoding_Error_Data
problems = Vector.from_polyglot_array results.problems . map Encoding_Error_Data
on_problems.attach_problems_after results.result problems
## PRIVATE
@ -1110,7 +1110,7 @@ Vector.Vector.write_bytes : (File|Text) -> Existing_File_Behavior -> Nothing ! I
Vector.Vector.write_bytes self path on_existing_file=Existing_File_Behavior.Backup =
Panic.catch Unsupported_Argument_Types_Data handler=(Error.throw (Illegal_Argument_Error_Data "Only Vectors consisting of bytes (integers in the range from -128 to 127) are supported by the `write_bytes` method.")) <|
## Convert to a byte array before writing - and fail early if there is any problem.
byte_array = Array_Utils.ensureByteArray self.to_array
byte_array = Array_Builder.ensureByteArray self.to_array
file = new path
on_existing_file.write file stream->

View File

@ -36,7 +36,7 @@ type Warning
nature is preserved.
reassignments : Vector.Vector Stack_Trace_Element
reassignments self =
Vector.Vector_Data self.get_reassignments . map r->
Vector.from_polyglot_array self.get_reassignments . map r->
loc = case Polyglot.has_source_location r of
False -> Nothing
True -> Source_Location_Data (Polyglot.get_source_location r)
@ -46,7 +46,7 @@ type Warning
Builtin method for getting the list of locations where the warnings was reassigned.
Should use `Warning.reassignments` instead.
get_reassignments : Any
get_reassignments : Array Any
get_reassignments self = @Builtin_Method "Warning.get_reassignments"
## PRIVATE
@ -78,7 +78,7 @@ attach_with_stacktrace value warning origin = @Builtin_Method "Warning.attach_wi
Gets all the warnings attached to the given value. Warnings are returned in the
reverse-chronological order with respect to their attachment time.
get_all : Any -> Vector.Vector Warning
get_all value = Vector.Vector_Data (get_all_array value)
get_all value = Vector.from_polyglot_array (get_all_array value)
## PRIVATE

View File

@ -33,7 +33,7 @@ check_integrity entity1 entity2 =
as-is, otherwise it is wrapped in a singleton vector.
unify_vector_singleton : (Any | Vector.Vector Any) -> Vector.Vector Any
unify_vector_singleton x = case x of
Vector.Vector_Data _ -> x
Vector.Vector -> x
_ -> [x]
## UNSTABLE

View File

@ -108,7 +108,7 @@ type JDBC_Connection
num_rows = table.row_count
columns = table.columns
check_rows updates_array expected_size =
updates = Vector.Vector_Data updates_array
updates = Vector.from_polyglot_array updates_array
if updates.length != expected_size then Panic.throw <| Illegal_State_Error "The batch update unexpectedly affected "+updates.length.to_text+" rows instead of "+expected_size.to_text+"." else
updates.each affected_rows->
if affected_rows != 1 then

View File

@ -33,7 +33,7 @@ read location flags=[] =
File.File -> location.path
_ -> location
read_flags = case flags of
Vector.Vector_Data _ ->
Vector.Vector ->
if flags.is_empty then Java_Codecs.READ_FLAG_EMPTY else
flags.map .to_integer . reduce (_.bit_or _)
_ -> flags.to_integer
@ -65,7 +65,7 @@ Image.Image.write self location flags=[] =
File.File -> location.path
_ -> location
write_flags = case flags of
Vector.Vector_Data _ -> flags
Vector.Vector -> flags
_ -> [flags]
int_flags = Internal.mat_of_int (write_flags.flat_map x-> [x.to_integer, x.value])
Panic.catch_java Any (Java_Codecs.write path self.opencv_mat int_flags) _->

View File

@ -19,8 +19,8 @@ core_op : Mat -> Any -> (Mat -> Scalar -> Mat -> Nothing) -> Nothing
core_op mat value function =
result = Mat.new
scalar = case value of
Vector.Vector_Data arr ->
Scalar.new arr
Vector.Vector ->
Scalar.new value.to_array
Matrix.Matrix_Data m ->
if ((m.rows == mat.rows) && (m.cols == mat.cols) && (m.channels == mat.channels)) then m else Panic.throw Matrix.Dimensions_Not_Equal
_ ->

View File

@ -18,7 +18,7 @@ core_op : Mat -> Any -> (Mat -> Scalar -> Mat -> Nothing) -> Nothing
core_op mat value function =
result = Mat.new
scalar = case value of
Vector.Vector_Data _ ->
Vector.Vector ->
Scalar.new value.to_array
Matrix.Matrix_Data m ->
if ((m.rows == mat.rows) && (m.cols == mat.cols) && (m.channels == mat.channels)) then m else Panic.throw Matrix.Dimensions_Not_Equal

View File

@ -52,7 +52,7 @@ new : Vector (Vector | Column) -> Table
new columns =
cols = columns.map c->
case c of
Vector.Vector_Data _ -> Column.from_vector (c.at 0) (c.at 1) . java_column
Vector.Vector -> Column.from_vector (c.at 0) (c.at 1) . java_column
Column.Column_Data java_col -> java_col
from_columns cols
@ -256,7 +256,7 @@ type Table
at : Text | Integer -> Column ! No_Such_Column_Error | Index_Out_Of_Bounds_Error
at self selector=0 = case selector of
Integer ->
java_columns = Vector.Vector_Data self.java_table.getColumns
java_columns = Vector.from_polyglot_array self.java_table.getColumns
Column.Column_Data (java_columns.at selector)
Text ->
case self.java_table.getColumnOrIndexByName selector of
@ -837,7 +837,7 @@ type Table
table.set "total_stock" double_inventory
set : Text -> Column.Column | Vector.Vector -> Table
set self name column = case column of
Vector.Vector_Data _ ->
Vector.Vector ->
self.set name (Column.from_vector name column)
Column.Column_Data _ ->
Table_Data (self.java_table.addOrReplaceColumn (column.rename name . java_column))

View File

@ -56,7 +56,7 @@ type Vector_Builder
ix2 = go ix l
go ix2 r
go 0 self
Vector.Vector_Data array
Vector.from_polyglot_array array
## PRIVATE
@ -73,7 +73,7 @@ type Vector_Builder
case other of
Leaf _ -> Append self other len
Append _ _ _ -> Append self other len
Vector.Vector_Data _ -> Append self (Leaf other) len
Vector.Vector -> Append self (Leaf other) len
## PRIVATE

View File

@ -92,7 +92,7 @@ Table.Table.all_columns : Vector
Table.Table.all_columns self =
index = self.index.catch_ []
index_columns = case index of
Vector.Vector_Data _ -> index
Vector.Vector -> index
a -> [a]
index_columns + self.columns

View File

@ -56,7 +56,7 @@ from_value : Any -> Update
from_value value =
case value of
Table.Table_Data _ -> from_table value
Vector.Vector_Data _ -> from_vector value
Vector.Vector -> from_vector value
Column.Column_Data _ -> from_table value.to_table
_ -> from_vector value.to_vector

View File

@ -202,7 +202,7 @@ process_to_json_text value bounds=Nothing limit=Nothing =
json = case value of
Column.Column_Data _ -> json_from_table value.to_table bounds limit
Table.Table_Data _ -> json_from_table value bounds limit
Vector.Vector_Data _ -> json_from_vector value bounds limit
Vector.Vector -> json_from_vector value bounds limit
_ -> json_from_vector value.to_vector bounds limit
json.to_text

View File

@ -52,11 +52,11 @@ prepare_visualization x max_rows=1000 = Helpers.recover_errors <| case x of
# TODO [RW] Should we truncate Vectors?
# We also visualize Vectors and arrays
Vector.Vector_Data _ ->
Vector.Vector ->
truncated = x.take (First max_rows)
Json.from_pairs [["json", truncated], ["all_rows_count", x.length]] . to_text
Array ->
prepare_visualization (Vector.Vector_Data x) max_rows
prepare_visualization (Vector.from_polyglot_array x) max_rows
# Anything else will be visualized with the JSON or matrix visualization
_ ->

View File

@ -1,12 +1,9 @@
package org.enso.interpreter.epb.node;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.ReportPolymorphism;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
@GenerateUncached
@ -32,53 +29,53 @@ public abstract class CoercePrimitiveNode extends Node {
*/
public abstract Object execute(Object value);
@Specialization(guards = "bools.isBoolean(bool)")
boolean doBoolean(Object bool, @CachedLibrary(limit = "5") InteropLibrary bools) {
try {
return bools.asBoolean(bool);
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible, `bool` already checked to be a boolean");
}
@Specialization
boolean doBoolean(boolean bool) {
return bool;
}
@Specialization(guards = {"numbers.isNumber(integer)", "numbers.fitsInLong(integer)"})
long doInteger(Object integer, @CachedLibrary(limit = "5") InteropLibrary numbers) {
try {
return numbers.asLong(integer);
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible, `integer` is checked to be a long");
}
@Specialization
long doByte(byte n) {
return n;
}
@Specialization(
guards = {
"numbers.isNumber(decimal)",
"!numbers.fitsInLong(decimal)",
"numbers.fitsInDouble(decimal)"
})
double doDecimal(Object decimal, @CachedLibrary(limit = "5") InteropLibrary numbers) {
try {
return numbers.asDouble(decimal);
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible, `decimal` is checked to be a long");
}
@Specialization
long doShort(short n) {
return n;
}
@Specialization(guards = {"characters.isString(character)", "isChar(character)"})
long doChar(Object character, @CachedLibrary(limit = "5") InteropLibrary characters) {
try {
return characters.asString(character).charAt(0);
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible, `character` is checked to be a long");
}
@Specialization
long doInt(int n) {
return n;
}
static boolean isChar(Object s) {
return s instanceof Character;
@Specialization
long doLong(long n) {
return n;
}
@Fallback
Object doNonPrimitive(Object value) {
@Specialization
double doFloat(float n) {
return n;
}
@Specialization
double doDouble(double n) {
return n;
}
@Specialization
long doChar(char character) {
return character;
}
@Specialization
String doString(String s) {
return s;
}
@Specialization
Object doNonPrimitive(TruffleObject value) {
return value;
}
}

View File

@ -1,6 +1,5 @@
package org.enso.interpreter.test.instrument
import org.enso.compiler.pass.resolve.VectorLiterals
import org.enso.distribution.FileSystem
import org.enso.distribution.locking.ThreadSafeFileLockManager
import org.enso.docs.generator.DocsGenerator
@ -257,7 +256,6 @@ class RuntimeStdlibTest
xs.toVector.map(_.suggestion.module)
}
stdlibSuggestions.nonEmpty shouldBe true
stdlibSuggestions.flatten should contain(VectorLiterals.vectorModuleName)
// check that builtins are indexed
val builtinsSuggestions = responses.collect {

View File

@ -0,0 +1,142 @@
package org.enso.interpreter.bench.benchmarks.semantic;
import java.io.ByteArrayOutputStream;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Value;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.BenchmarkParams;
import org.openjdk.jmh.infra.Blackhole;
@BenchmarkMode(Mode.AverageTime)
@Fork(1)
@Warmup(iterations = 3)
@Measurement(iterations = 5)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class VectorBenchmarks {
private Value arrayOfFibNumbers;
private Value avg;
private Value self;
@Setup
public void initializeBenchmark(BenchmarkParams params) {
Engine eng = Engine.newBuilder()
.allowExperimentalOptions(true)
.logHandler(new ByteArrayOutputStream())
.option(
"enso.languageHomeOverride",
Paths.get("../../distribution/component").toFile().getAbsolutePath()
).build();
var ctx = Context.newBuilder()
.engine(eng)
.allowIO(true)
.allowAllAccess(true)
.build();
var module = ctx.eval("enso", "\n" +
"import Standard.Base.Data.Vector\n" +
"\n" +
"avg arr =\n" +
" sum acc i = if i == arr.length then acc else\n" +
" sum (acc + arr.at i) i+1\n" +
" (sum 0 0) / arr.length\n" +
"\n" +
"fibarr size modulo = \n" +
" b = Vector.new_builder size\n" +
" b.append 1\n" +
" b.append 1\n" +
" \n" +
" add_more n = if n == size then b else \n" +
" b.append <| (b.at n-1 + b.at n-2) % modulo\n" +
" @Tail_Call add_more n+1\n" +
" \n" +
" add_more 2 . to_vector\n" +
"\n" +
"to_vector arr = Vector.from_polyglot_array arr\n" +
"to_array vec = vec.to_array\n" +
"\n");
this.self = module.invokeMember("get_associated_type");
Function<String,Value> getMethod = (name) -> module.invokeMember("get_method", self, name);
Value arr = getMethod.apply("fibarr").execute(self, 1000, Integer.MAX_VALUE);
switch (params.getBenchmark().replaceFirst(".*\\.", "")) {
case "averageOverVector": {
this.arrayOfFibNumbers = arr;
break;
}
case "averageOverArray": {
this.arrayOfFibNumbers = getMethod.apply("to_array").execute(self, arr);
break;
}
case "averageOverPolyglotVector": {
long[] copy = copyToPolyglotArray(arr);
this.arrayOfFibNumbers = getMethod.apply("to_vector").execute(self, copy);
break;
}
case "averageOverPolyglotArray": {
long[] copy = copyToPolyglotArray(arr);
this.arrayOfFibNumbers = Value.asValue(copy);
break;
}
default:
throw new IllegalStateException("Unexpected benchmark: " + params.getBenchmark());
}
this.avg = getMethod.apply("avg");
}
private long[] copyToPolyglotArray(Value arr) {
long[] copy = new long[Math.toIntExact(arr.getArraySize())];
for (int i = 0; i < copy.length; i++) {
copy[i] = arr.getArrayElement(i).asLong();
}
return copy;
}
@Benchmark
public void averageOverVector(Blackhole matter) {
performBenchmark(matter);
}
@Benchmark
public void averageOverPolyglotVector(Blackhole matter) {
performBenchmark(matter);
}
@Benchmark
public void averageOverArray(Blackhole matter) {
performBenchmark(matter);
}
@Benchmark
public void averageOverPolyglotArray(Blackhole matter) {
performBenchmark(matter);
}
private void performBenchmark(Blackhole matter) throws AssertionError {
var average = avg.execute(self, arrayOfFibNumbers);
if (!average.fitsInDouble()) {
throw new AssertionError("Shall be a double: " + average);
}
var result = (long) average.asDouble();
if (result < 1019950590 || result > 1019950600) {
throw new AssertionError("Expecting reasonable average but was " + result + "\n" + arrayOfFibNumbers);
}
matter.consume(result);
}
}

View File

@ -6,7 +6,6 @@ import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.BranchProfile;
import org.enso.interpreter.node.BaseNode;
import org.enso.interpreter.node.callable.dispatch.IndirectInvokeFunctionNode;
import org.enso.interpreter.node.callable.resolver.ConversionResolverNode;

View File

@ -7,7 +7,6 @@ import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.source.SourceSection;
import org.enso.interpreter.node.BaseNode;
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;

View File

@ -16,8 +16,6 @@ import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import java.time.ZoneId;
import java.util.UUID;
import java.util.concurrent.locks.Lock;
import org.enso.interpreter.node.BaseNode;
import org.enso.interpreter.node.callable.dispatch.InvokeFunctionNode;
@ -175,7 +173,8 @@ public abstract class InvokeMethodNode extends BaseNode {
Object[] arguments,
@CachedLibrary(limit = "10") TypesLibrary methods,
@CachedLibrary(limit = "10") InteropLibrary interop,
@Bind("getPolyglotCallType(self, symbol.getName(), interop)")
@Cached MethodResolverNode preResolveMethod,
@Bind("getPolyglotCallType(self, symbol.getName(), interop, preResolveMethod)")
HostMethodCallNode.PolyglotCallType polyglotCallType,
@Cached(value = "buildExecutors()") ThunkExecutorNode[] argExecutors,
@Cached(value = "buildProfiles()", dimensions = 1) BranchProfile[] profiles,
@ -236,6 +235,59 @@ public abstract class InvokeMethodNode extends BaseNode {
}
}
@Specialization(
guards = {
"!types.hasType(self)",
"!types.hasSpecialDispatch(self)",
"getPolyglotCallType(self, symbol.getName(), interop) == CONVERT_TO_ARRAY",
},
rewriteOn = AbstractMethodError.class)
Stateful doConvertArray(
VirtualFrame frame,
Object state,
UnresolvedSymbol symbol,
Object self,
Object[] arguments,
@CachedLibrary(limit = "10") InteropLibrary interop,
@CachedLibrary(limit = "10") TypesLibrary types,
@Cached MethodResolverNode methodResolverNode)
throws AbstractMethodError {
var ctx = Context.get(this);
var arrayType = ctx.getBuiltins().array();
var function = methodResolverNode.execute(arrayType, symbol);
if (function != null) {
arguments[0] = self;
return invokeFunctionNode.execute(function, frame, state, arguments);
} else {
// let's replace us with a doConvertArrayWithCheck
CompilerDirectives.transferToInterpreter();
throw new AbstractMethodError();
}
}
@Specialization(
guards = {
"!types.hasType(self)",
"!types.hasSpecialDispatch(self)",
"getPolyglotCallType(self, symbol.getName(), interop, methodResolverNode) == CONVERT_TO_ARRAY"
},
replaces = "doConvertArray")
Stateful doConvertArrayWithCheck(
VirtualFrame frame,
Object state,
UnresolvedSymbol symbol,
Object self,
Object[] arguments,
@CachedLibrary(limit = "10") InteropLibrary interop,
@CachedLibrary(limit = "10") TypesLibrary types,
@Cached MethodResolverNode methodResolverNode) {
var ctx = Context.get(this);
var arrayType = ctx.getBuiltins().array();
var function = methodResolverNode.expectNonNull(self, arrayType, symbol);
arguments[0] = self;
return invokeFunctionNode.execute(function, frame, state, arguments);
}
@Specialization(
guards = {
"!types.hasType(self)",

View File

@ -5,6 +5,7 @@ import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.NodeInfo;
import org.enso.interpreter.node.ExpressionNode;
import org.enso.interpreter.runtime.data.Array;
import org.enso.interpreter.runtime.data.Vector;
@NodeInfo(shortName = "[]", description = "Creates a vector from given expressions.")
public class SequenceLiteralNode extends ExpressionNode {
@ -37,6 +38,6 @@ public class SequenceLiteralNode extends ExpressionNode {
for (int i = 0; i < items.length; i++) {
itemValues[i] = items[i].executeGeneric(frame);
}
return new Array(itemValues);
return Vector.fromArray(new Array(itemValues));
}
}

View File

@ -8,7 +8,6 @@ import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.callable.UnresolvedConversion;
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.error.PanicException;

View File

@ -7,6 +7,7 @@ import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.profiles.BranchProfile;
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
import org.enso.interpreter.runtime.error.PanicException;
/** Discovers and performs method calls on foreign values. */
@ -31,18 +32,16 @@ public abstract class HostMethodCallNode extends Node {
* Object...)}.
*/
INSTANTIATE,
/** The method call should be handled through {@link InteropLibrary#getArraySize(Object)}. */
GET_ARRAY_LENGTH,
/**
* The method call should be handled through {@link InteropLibrary#readArrayElement(Object,
* long)}.
*/
READ_ARRAY_ELEMENT,
/**
* The method call should be handled by converting {@code self} to a {@link
* org.enso.interpreter.runtime.data.text.Text} and dispatching natively.
*/
CONVERT_TO_TEXT,
/**
* The method call should be handled by converting {@code self} dispatching natively to methods
* of {@link org.enso.interpreter.runtime.data.Array}
*/
CONVERT_TO_ARRAY,
/**
* The method call should be handled by converting {@code self} to a {@code
* Standard.Base.Data.Time.Date} and dispatching natively.
@ -80,6 +79,7 @@ public abstract class HostMethodCallNode extends Node {
*/
public boolean isInteropLibrary() {
return this != NOT_SUPPORTED
&& this != CONVERT_TO_ARRAY
&& this != CONVERT_TO_TEXT
&& this != CONVERT_TO_DATE
&& this != CONVERT_TO_DATE_TIME
@ -89,8 +89,6 @@ public abstract class HostMethodCallNode extends Node {
}
}
private static final String ARRAY_LENGTH_NAME = "length";
private static final String ARRAY_READ_NAME = "at";
private static final String NEW_NAME = "new";
static final int LIB_LIMIT = 3;
@ -106,6 +104,24 @@ public abstract class HostMethodCallNode extends Node {
*/
public static PolyglotCallType getPolyglotCallType(
Object self, String methodName, InteropLibrary library) {
return getPolyglotCallType(self, methodName, library, null);
}
/**
* Returns a token instructing the caller about what mode of calling the given method should be
* used.
*
* @param self the method call target
* @param methodName the method name
* @param library an instance of interop library to use for interacting with the target
* @param methodResolverNode {@code null} or real instances of the node to resolve methods
* @return a {@link PolyglotCallType} to use for this target and method
*/
public static PolyglotCallType getPolyglotCallType(
Object self,
String methodName,
InteropLibrary library,
MethodResolverNode methodResolverNode) {
if (library.isDate(self)) {
if (library.isTime(self)) {
if (library.isTimeZone(self)) {
@ -122,16 +138,26 @@ public abstract class HostMethodCallNode extends Node {
return PolyglotCallType.CONVERT_TO_TIME_ZONE;
} else if (library.isString(self)) {
return PolyglotCallType.CONVERT_TO_TEXT;
} else if (library.isMemberInvocable(self, methodName)) {
} else if (library.hasArrayElements(self)) {
if (methodResolverNode != null) {
var ctx = Context.get(library);
var arrayType = ctx.getBuiltins().array();
var symbol = UnresolvedSymbol.build(methodName, ctx.getBuiltins().getScope());
var fn = methodResolverNode.execute(arrayType, symbol);
if (fn != null) {
return PolyglotCallType.CONVERT_TO_ARRAY;
}
} else {
return PolyglotCallType.CONVERT_TO_ARRAY;
}
}
if (library.isMemberInvocable(self, methodName)) {
return PolyglotCallType.CALL_METHOD;
} else if (library.isMemberReadable(self, methodName)) {
return PolyglotCallType.GET_MEMBER;
} else if (library.isInstantiable(self) && methodName.equals(NEW_NAME)) {
return PolyglotCallType.INSTANTIATE;
} else if (library.hasArrayElements(self) && methodName.equals(ARRAY_LENGTH_NAME)) {
return PolyglotCallType.GET_ARRAY_LENGTH;
} else if (library.hasArrayElements(self) && methodName.equals(ARRAY_READ_NAME)) {
return PolyglotCallType.READ_ARRAY_ELEMENT;
}
return PolyglotCallType.NOT_SUPPORTED;
}
@ -229,56 +255,4 @@ public abstract class HostMethodCallNode extends Node {
this);
}
}
@Specialization(guards = {"callType == GET_ARRAY_LENGTH"})
Object resolveHostArrayLength(
PolyglotCallType callType,
String symbol,
Object self,
Object[] args,
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
@Cached BranchProfile errorProfile,
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
if (args.length != 0) {
errorProfile.enter();
throw new PanicException(
Context.get(this).getBuiltins().error().makeArityError(0, 0, args.length), this);
}
try {
return hostValueToEnsoNode.execute(arrays.getArraySize(self));
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible to reach here, self is checked to be an array");
}
}
@Specialization(guards = {"callType == READ_ARRAY_ELEMENT"})
Object resolveHostArrayRead(
PolyglotCallType callType,
String symbol,
Object self,
Object[] args,
@CachedLibrary(limit = "LIB_LIMIT") InteropLibrary arrays,
@Cached BranchProfile arityErrorProfile,
@Cached BranchProfile typeErrorProfile,
@Cached HostValueToEnsoNode hostValueToEnsoNode) {
if (args.length != 1) {
arityErrorProfile.enter();
throw new PanicException(
Context.get(this).getBuiltins().error().makeArityError(1, 1, args.length), this);
}
if (!(args[0] instanceof Long)) {
typeErrorProfile.enter();
throw new PanicException(
Context.get(this).getBuiltins().error().makeInvalidArrayIndexError(self, args[0]), this);
}
long idx = (Long) args[0];
try {
return hostValueToEnsoNode.execute(arrays.readArrayElement(self, idx));
} catch (UnsupportedMessageException e) {
throw new IllegalStateException("Impossible to reach here, self is checked to be an array");
} catch (InvalidArrayIndexException e) {
throw new PanicException(
Context.get(this).getBuiltins().error().makeInvalidArrayIndexError(self, idx), this);
}
}
}

View File

@ -6,15 +6,11 @@ import com.oracle.truffle.api.dsl.GenerateUncached;
import com.oracle.truffle.api.dsl.ReportPolymorphism;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import org.checkerframework.checker.units.qual.C;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Number;
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
@GenerateUncached
@ReportPolymorphism

View File

@ -8,8 +8,6 @@ import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Array;
import org.enso.interpreter.runtime.data.Type;

View File

@ -6,8 +6,6 @@ import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
@NodeInfo(shortName = "BooleanConsMatch", description = "Match using the Boolean constructor.")

View File

@ -6,8 +6,6 @@ import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
@NodeInfo(shortName = "TextMatch", description = "Allows matching on the Decimal type.")

View File

@ -6,8 +6,6 @@ import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.EnsoFile;
import org.enso.interpreter.runtime.data.Type;

View File

@ -7,8 +7,6 @@ import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.builtin.Number;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,8 +7,6 @@ import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.builtin.Number;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -2,7 +2,6 @@ package org.enso.interpreter.node.controlflow.caseexpr;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.frame.VirtualFrame;
import org.enso.interpreter.runtime.Context;
public class ObjectEqualityBranchNode extends BranchNode {
private final Object expected;

View File

@ -7,8 +7,6 @@ import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
@NodeInfo(shortName = "PolyglotMatch", description = "Allows matching on polyglot objects.")

View File

@ -5,14 +5,11 @@ import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.node.expression.builtin.text.util.ToJavaStringNode;
import org.enso.interpreter.runtime.data.text.Text;
import java.math.BigInteger;
import com.ibm.icu.text.Normalizer;
@NodeInfo(shortName = "StringLiteralMatch", description = "Allows matching on String literals")

View File

@ -8,8 +8,6 @@ import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
@NodeInfo(shortName = "TextMatch", description = "Allows matching on the Text type.")

View File

@ -0,0 +1,48 @@
package org.enso.interpreter.node.controlflow.caseexpr;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.profiles.ConditionProfile;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.data.Vector;
/** An implementation of the case expression specialised to working on vectors. */
@NodeInfo(shortName = "VectorMatch")
public abstract class VectorBranchNode extends BranchNode {
private final Type vector;
private final ConditionProfile profile = ConditionProfile.createCountingProfile();
VectorBranchNode(Type vector, RootCallTarget branch) {
super(branch);
this.vector = vector;
}
/**
* Creates a new node for handling matching on a case expression.
*
* @param vector the expression to use for matching
* @param branch the expression to be executed if (@code matcher} matches
* @return a node for matching in a case expression
*/
public static VectorBranchNode build(Type vector, RootCallTarget branch) {
return VectorBranchNodeGen.create(vector, branch);
}
@Specialization
void doType(VirtualFrame frame, Object state, Type target) {
if (profile.profile(vector == target)) {
accept(frame, state, new Object[0]);
}
}
@Specialization
void doVector(VirtualFrame frame, Object state, Vector vector) {
accept(frame, state, new Object[0]);
}
@Fallback
void doFallback(VirtualFrame frame, Object state, Object target) {}
}

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.scope.ModuleScope;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

View File

@ -1,13 +1,9 @@
package org.enso.interpreter.node.expression.builtin.bool;
import com.oracle.truffle.api.dsl.Cached;
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.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
@BuiltinMethod(type = "Boolean", name = "==", description = "Computes the equality of two booleans")
public abstract class EqualsNode extends Node {

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -6,7 +6,6 @@ import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.AcceptsError;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.data.text.Text;
import org.enso.interpreter.runtime.error.DataflowError;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -2,9 +2,6 @@ package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;
@BuiltinType
public class ModuleNotInPackageError extends Builtin {}

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,8 +1,8 @@
package org.enso.interpreter.node.expression.builtin.error;
import com.oracle.truffle.api.exception.AbstractTruffleException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.error;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.dsl.Suspend;
import org.enso.interpreter.node.BaseNode;
import org.enso.interpreter.node.callable.InvokeCallableNode;
import org.enso.interpreter.runtime.callable.argument.CallArgumentInfo;
import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.state.Stateful;
@BuiltinMethod(

View File

@ -0,0 +1,67 @@
package org.enso.interpreter.node.expression.builtin.immutable;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.*;
import org.enso.interpreter.epb.node.CoercePrimitiveNode;
import org.enso.interpreter.node.expression.foreign.CoerceNothing;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.data.Array;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.data.Vector;
@BuiltinMethod(
type = "Vector",
name = "from_array",
description = "Creates a Vector by copying Array content.")
public abstract class FromArrayBuiltinVectorNode extends Node {
private @Child CoercePrimitiveNode coercePrimitiveNode = CoercePrimitiveNode.build();
private @Child CoerceNothing coerceNothingNode = CoerceNothing.build();
static FromArrayBuiltinVectorNode build() {
return FromArrayBuiltinVectorNodeGen.create();
}
abstract Vector execute(Object arr);
@Specialization
Vector fromVector(Vector arr) {
return arr;
}
@Specialization(guards = "interop.hasArrayElements(arr)")
Vector fromArrayLikeObject(Object arr, @CachedLibrary(limit = "3") InteropLibrary interop) {
try {
long length = interop.getArraySize(arr);
Object[] target = new Object[(int) length];
for (int i = 0; i < length; i++) {
try {
var value = interop.readArrayElement(arr, i);
target[i] = coerceNothingNode.execute(coercePrimitiveNode.execute(value));
} catch (InvalidArrayIndexException ex) {
var ctx = Context.get(this);
var err = ctx.getBuiltins().error().makeInvalidArrayIndexError(arr, i);
throw new PanicException(err, this);
}
}
return Vector.fromArray(new Array(target));
} catch (UnsupportedMessageException ex) {
throw unsupportedException(arr);
}
}
@Fallback
Vector fromUnknown(Object arr) {
throw unsupportedException(arr);
}
private PanicException unsupportedException(Object arr) {
var ctx = Context.get(this);
var err = ctx.getBuiltins().error().makeTypeError("polyglot array", arr, "array");
throw new PanicException(err, this);
}
}

View File

@ -0,0 +1,35 @@
package org.enso.interpreter.node.expression.builtin.immutable;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.*;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.data.Vector;
@BuiltinMethod(
type = "Vector",
name = "from_polyglot_array",
description = "Returns an Array representation of this Vector.")
public abstract class FromPolyglotArrayBuiltinVectorNode extends Node {
static FromPolyglotArrayBuiltinVectorNode build() {
return FromPolyglotArrayBuiltinVectorNodeGen.create();
}
abstract Vector execute(Object arr);
@Specialization(guards = "interop.hasArrayElements(arr)")
Vector doObject(Object arr, @CachedLibrary(limit = "1") InteropLibrary interop) {
return Vector.fromArray(arr);
}
@Fallback
Vector doOther(Object arr) {
Context ctx = Context.get(this);
throw new PanicException(
ctx.getBuiltins().error().makeTypeError("polyglot array", arr, "array"), this);
}
}

View File

@ -0,0 +1,32 @@
package org.enso.interpreter.node.expression.builtin.immutable;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.data.Vector;
import org.enso.interpreter.runtime.error.PanicException;
@BuiltinMethod(
type = "Vector",
name = "unsafe_at",
description = "Returns an element of Vector at the specified index.")
public class UnsafeAtVectorNode extends Node {
private @Child InteropLibrary interop = InteropLibrary.getFactory().createDispatched(3);
private @Child HostValueToEnsoNode toEnso = HostValueToEnsoNode.build();
Object execute(Vector self, long index) {
try {
return self.readArrayElement(index, interop, toEnso);
} catch (InvalidArrayIndexException e) {
Context ctx = Context.get(this);
throw new PanicException(
ctx.getBuiltins().error().makeInvalidArrayIndexError(self, index), this);
} catch (UnsupportedMessageException e) {
throw new PanicException(e.getMessage(), this);
}
}
}

View File

@ -5,7 +5,6 @@ import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.CachedLibrary;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.data.text.Text;
/**
@ -19,6 +18,10 @@ public abstract class HostValueToEnsoNode extends Node {
return HostValueToEnsoNodeGen.create();
}
public static HostValueToEnsoNode getUncached() {
return HostValueToEnsoNodeGen.getUncached();
}
/**
* Converts an arbitrary value to a value usable within Enso code.
*

View File

@ -4,7 +4,6 @@ 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.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
@BuiltinMethod(

View File

@ -5,7 +5,6 @@ import org.enso.interpreter.dsl.AcceptsError;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.type.TypesGen;
@BuiltinMethod(type = "Meta", name = "is_atom", description = "Checks if the argument is an atom")
public class IsAtomNode extends Node {

View File

@ -1,7 +1,6 @@
package org.enso.interpreter.node.expression.builtin.meta;
import org.enso.interpreter.dsl.BuiltinType;
import org.enso.interpreter.node.expression.builtin.Builtin;
import org.enso.interpreter.node.expression.builtin.UniquelyConstructibleBuiltin;
import java.util.List;

View File

@ -0,0 +1,32 @@
package org.enso.interpreter.node.expression.builtin.mutable;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.InvalidArrayIndexException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.interop.syntax.HostValueToEnsoNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.error.PanicException;
@BuiltinMethod(type = "Array", name = "at", description = "Get element of a polyglot array")
public class ArrayAtNode extends Node {
@Child InteropLibrary iop = InteropLibrary.getFactory().createDispatched(3);
@Child HostValueToEnsoNode convert = HostValueToEnsoNode.build();
Object execute(Object self, long at) {
try {
var r = iop.readArrayElement(self, at);
return convert.execute(r);
} catch (UnsupportedMessageException ex) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(ex);
} catch (InvalidArrayIndexException ex) {
Context ctx = Context.get(this);
Builtins builtins = ctx.getBuiltins();
throw new PanicException(builtins.error().makeInvalidArrayIndexError(self, at), this);
}
}
}

View File

@ -0,0 +1,23 @@
package org.enso.interpreter.node.expression.builtin.mutable;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.error.PanicException;
@BuiltinMethod(type = "Array", name = "length", description = "Length of polyglot array")
public class ArrayLengthNode extends Node {
@Child InteropLibrary iop = InteropLibrary.getFactory().createDispatched(3);
long execute(Object self) {
try {
return iop.getArraySize(self);
} catch (UnsupportedMessageException ex) {
var ctx = Context.get(this);
var pay = ctx.getBuiltins().error().makeUnsupportedArgumentsError(new Object[] {self});
throw new PanicException(pay, this);
}
}
}

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -6,7 +6,6 @@ import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -10,7 +10,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -1,14 +1,10 @@
package org.enso.interpreter.node.expression.builtin.number.bigInteger;
import com.oracle.truffle.api.dsl.Cached;
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.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
@BuiltinMethod(type = "Big_Integer", name = "==", description = "Big integer equality.")

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.node.expression.builtin.number.utils.ToEnsoNumberNode;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -1,15 +1,10 @@
package org.enso.interpreter.node.expression.builtin.number.decimal;
import com.oracle.truffle.api.dsl.Cached;
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.Context;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.callable.atom.AtomConstructor;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.number.EnsoBigInteger;
@BuiltinMethod(type = "Decimal", name = "==", description = "Equality on numbers.")

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,8 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -7,7 +7,6 @@ import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

View File

@ -8,7 +8,6 @@ import org.enso.interpreter.node.expression.builtin.number.decimal.ModNodeGen;
import org.enso.interpreter.node.expression.builtin.number.utils.BigIntegerOps;
import org.enso.interpreter.runtime.Context;
import org.enso.interpreter.runtime.builtin.Builtins;
import org.enso.interpreter.runtime.callable.atom.Atom;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.number.EnsoBigInteger;

Some files were not shown because too many files have changed in this diff Show More