diff --git a/.vscode/launch.json b/.vscode/launch.json index 86ced2f1ac0a..8c6d1f8bede4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,7 +33,7 @@ "request": "launch", "name": "Launch Native Image", "nativeImagePath": "${workspaceFolder}/runner", - "args": "--help" + "args": "--run ${file}" } ] } \ No newline at end of file diff --git a/build.sbt b/build.sbt index e2d91e239508..bd30dfed9c0a 100644 --- a/build.sbt +++ b/build.sbt @@ -2549,8 +2549,10 @@ lazy val `engine-runner` = project if (smallJdkDirectory.exists()) { IO.delete(smallJdkDirectory) } - val JS_MODULES = - "org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise,jdk.compiler.graal,jdk.httpserver,java.naming,java.net.http" + val NI_MODULES = + "org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise" + val JDK_MODULES = + "jdk.localedata,jdk.compiler.graal,jdk.httpserver,java.naming,java.net.http" val DEBUG_MODULES = "jdk.jdwp.agent" val PYTHON_MODULES = "jdk.security.auth,java.naming" @@ -2578,7 +2580,7 @@ lazy val `engine-runner` = project } val exec = - s"$jlink --module-path ${modules.mkString(":")} --output $smallJdkDirectory --add-modules $JS_MODULES,$DEBUG_MODULES,$PYTHON_MODULES" + s"$jlink --module-path ${modules.mkString(":")} --output $smallJdkDirectory --add-modules $NI_MODULES,$JDK_MODULES,$DEBUG_MODULES,$PYTHON_MODULES" val exitCode = scala.sys.process.Process(exec).! if (exitCode != 0) { @@ -2610,6 +2612,9 @@ lazy val `engine-runner` = project additionalOptions = Seq( "-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog", "-H:IncludeResources=.*Main.enso$", + "-H:+AddAllCharsets", + "-H:+IncludeAllLocales", + "-ea", // useful perf & debug switches: // "-g", // "-H:+SourceLevelDebug", @@ -2660,6 +2665,7 @@ lazy val `engine-runner` = project .dependsOn(`logging-service`) .dependsOn(`logging-service-logback` % Runtime) .dependsOn(`polyglot-api`) + .dependsOn(`enso-test-java-helpers`) lazy val buildSmallJdk = taskKey[File]("Build a minimal JDK used for native image generation") @@ -3567,7 +3573,7 @@ ThisBuild / buildEngineDistributionNoIndex := { lazy val runEngineDistribution = inputKey[Unit]("Run or --debug the engine distribution with arguments") runEngineDistribution := { - buildEngineDistribution.value + buildEngineDistributionNoIndex.value val args: Seq[String] = spaceDelimited("").parsed DistributionPackage.runEnginePackage( engineDistributionRoot.value, diff --git a/build/build/src/engine/context.rs b/build/build/src/engine/context.rs index eaa17546d2df..8da68903ab0e 100644 --- a/build/build/src/engine/context.rs +++ b/build/build/src/engine/context.rs @@ -630,28 +630,12 @@ pub async fn runner_sanity_test( repo_root: &crate::paths::generated::RepoRoot, enso_java: Option<&str>, ) -> Result { - let factorial_input = "6"; - let factorial_expected_output = "720"; let engine_package = repo_root.built_distribution.enso_engine_triple.engine_package.as_path(); // The engine package is necessary for running the native runner. ide_ci::fs::tokio::require_exist(engine_package).await?; - let output = Command::new(&repo_root.runner) - .args([ - "--run", - repo_root.engine.runner.src.test.resources.factorial_enso.as_str(), - factorial_input, - ]) - .set_env_opt(ENSO_JAVA, enso_java)? - .set_env(ENSO_DATA_DIRECTORY, engine_package)? - .run_stdout() - .await?; - ensure!( - output.contains(factorial_expected_output), - "Native runner output does not contain expected result '{factorial_expected_output}'. Output:\n{output}", - ); if enso_java.is_none() { let test_base = Command::new(&repo_root.runner) - .args(["--run", repo_root.test.join("Base_Tests").as_str(), "^Text"]) + .args(["--run", repo_root.test.join("Base_Tests").as_str()]) .set_env_opt(ENSO_JAVA, enso_java)? .set_env(ENSO_DATA_DIRECTORY, engine_package)? .run_stdout() diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Base_64.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Base_64.enso index e97b04c71233..f0b09db02756 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Base_64.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Base_64.enso @@ -4,6 +4,8 @@ import project.Errors.Encoding_Error.Encoding_Error from project.Data.Text.Extensions import all polyglot java import java.util.Base64 +polyglot java import java.util.Base64.Decoder +polyglot java import java.util.Base64.Encoder ## A helper utility for handling base64 encoding. type Base_64 diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso index 2f0e7c0955f4..1dc72a6ea39e 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json.enso @@ -30,6 +30,7 @@ from project.Data.Text.Extensions import all from project.Metadata.Choice import Option from project.Metadata.Widget import Single_Choice +polyglot java import com.fasterxml.jackson.core.JsonLocation polyglot java import com.fasterxml.jackson.core.JsonProcessingException polyglot java import com.fasterxml.jackson.databind.JsonNode polyglot java import com.fasterxml.jackson.databind.node.ArrayNode diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Regression.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Regression.enso index 2bff31d18a26..b844d2de3959 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Regression.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Regression.enso @@ -9,6 +9,7 @@ import project.Nothing.Nothing import project.Panic.Panic polyglot java import org.enso.base.statistics.FitError +polyglot java import org.enso.base.statistics.LinearModel polyglot java import org.enso.base.statistics.Regression type Model diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso index 47efb90734f7..769ca1f247e6 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Text/Extensions.enso @@ -544,7 +544,7 @@ Text.replace self term:(Text | Regex) replacement:Text (case_sensitivity:Case_Se Applies the specified cleansings to the text. Arguments: - - remove: A vector of the named patterns to cleanse from the text. The named patterns are + - remove: A vector of the named patterns to cleanse from the text. The named patterns are applied in the order they are provided. The same named pattern can be used multiple times. The named patterns are: - ..Leading_Whitespace: Removes all whitespace from the start of the string. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso index 217f0a24ad59..c09f93072bab 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date.enso @@ -34,6 +34,7 @@ polyglot java import java.time.DateTimeException polyglot java import java.time.temporal.ChronoField polyglot java import java.time.temporal.IsoFields polyglot java import org.enso.base.Time_Utils +polyglot java import org.enso.base.Time_Utils.AdjustOp ## PRIVATE Constructs a new Date from a year, month, and day. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Period.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Period.enso index 27416f46dbab..99067fd360ca 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Period.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Time/Date_Period.enso @@ -11,7 +11,10 @@ polyglot java import java.time.temporal.TemporalAdjuster polyglot java import java.time.temporal.TemporalAdjusters polyglot java import java.time.temporal.TemporalUnit polyglot java import org.enso.base.time.CustomTemporalUnits +polyglot java import org.enso.base.time.Date_Utils polyglot java import org.enso.base.time.Date_Period_Utils +polyglot java import org.enso.base.time.Date_Time_Utils +polyglot java import org.enso.base.time.Time_Of_Day_Utils polyglot java import org.enso.base.Time_Utils ## Represents a unit of time longer on the scale of days (longer than a day). diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso index afe7039d3dcb..5f6960f0a75b 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso @@ -25,19 +25,18 @@ from project.Data.Range.Extensions import all from project.Data.Text.Extensions import all from project.Metadata import Display, make_single_choice, Widget -polyglot java import java.io.StringReader polyglot java import java.lang.Exception as JException -polyglot java import javax.xml.parsers.DocumentBuilder -polyglot java import javax.xml.parsers.DocumentBuilderFactory +polyglot java import javax.xml.xpath.XPath polyglot java import javax.xml.xpath.XPathConstants polyglot java import javax.xml.xpath.XPathFactory polyglot java import org.enso.base.XML_Utils +polyglot java import org.w3c.dom.Attr polyglot java import org.w3c.dom.Document polyglot java import org.w3c.dom.Element polyglot java import org.w3c.dom.Node polyglot java import org.w3c.dom.NodeList +polyglot java import org.w3c.dom.NamedNodeMap polyglot java import org.w3c.dom.Text as Java_Text -polyglot java import org.xml.sax.InputSource polyglot java import org.xml.sax.SAXException polyglot java import org.xml.sax.SAXParseException @@ -75,7 +74,8 @@ type XML_Document from_stream : Input_Stream -> XML_Document ! XML_Error from_stream input_stream:Input_Stream = XML_Error.handle_java_exceptions <| - input_stream.with_java_stream java_stream-> XML_Document.from_source java_stream + input_stream.with_java_stream java_stream-> + XML_Document.Value (XML_Utils.parseStream java_stream) ## GROUP Conversions ICON convert @@ -93,20 +93,13 @@ type XML_Document from_text : Text -> XML_Document ! XML_Error from_text xml_string:Text = XML_Error.handle_java_exceptions <| - string_reader = StringReader.new xml_string - XML_Document.from_source (InputSource.new string_reader) + XML_Document.Value (XML_Utils.parseString xml_string) ## PRIVATE - Read XML from an input source. - from_source : Any -> XML_Document ! XML_Error - from_source input_source = - document_builder_factory = DocumentBuilderFactory.newInstance - document_builder = document_builder_factory.newDocumentBuilder - XML_Utils.setCustomErrorHandler document_builder - XML_Document.Value (document_builder.parse input_source) + Wrap Java's Document to XML_Document + new doc:Document = XML_Document.Value doc - ## PRIVATE - Value (java_document:Document) + private Value (java_document:Document) ## GROUP Metadata diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso index ee838109d095..fd0f8133990b 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_Secret.enso @@ -24,6 +24,10 @@ from project.Metadata import make_single_choice polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper polyglot java import org.enso.base.enso_cloud.HideableValue +polyglot java import org.enso.base.enso_cloud.HideableValue.PlainValue +polyglot java import org.enso.base.enso_cloud.HideableValue.SecretValue +polyglot java import org.enso.base.enso_cloud.HideableValue.ConcatValues +polyglot java import org.enso.base.enso_cloud.HideableValue.Base64EncodeValue ## A reference to a secret stored in the Enso Cloud. type Enso_Secret diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso index 581045287f98..599a5e4a6663 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso @@ -78,7 +78,7 @@ slice vector start end = @Builtin_Method "Array_Like_Helpers.slice" `Map_Error`. - No_Wrap: The first error is thrown, and is not wrapped in `Map_Error`. - - Report_Warning: The result for that element is `Nothing`, + - Report_Warning: The result for that element is `Nothing`, the error is attached as a warning. Currently unimplemented. - Ignore: The result is `Nothing`, and the error is ignored. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso index 4981b39243ae..7771401cf43d 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Extra_Imports.enso @@ -14,3 +14,18 @@ polyglot java import org.enso.base.text.CaseFoldedString.Grapheme # needed by Comparator_Spec: polyglot java import org.enso.base.ObjectComparator + +# often used in tests +polyglot java import java.util.ArrayList +polyglot java import java.util.Map +polyglot java import java.nio.CharBuffer +polyglot java import java.nio.file.Path +polyglot java import java.io.FileInputStream +polyglot java import java.io.FileOutputStream +polyglot java import java.math.BigInteger +polyglot java import java.time.LocalDate +polyglot java import java.time.LocalDateTime +polyglot java import java.util.function.Function +polyglot java import java.lang.Thread +polyglot java import java.lang.Thread.State +polyglot java import java.lang.Float diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso index e6a98f22370c..7a7af704033a 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Meta/Enso_Project.enso @@ -45,7 +45,7 @@ type Project_Description Arguments: - prim_root_file: The primitive root file of the project. - prim_config: The primitive config of the project. - private Value prim_root_file prim_config + private Value prim_root_file ns:Text n:Text ## GROUP Metadata ICON folder @@ -78,7 +78,7 @@ type Project_Description enso_project.name name : Text - name self = self.prim_config.name + name self = self.n ## GROUP Metadata ICON metadata @@ -89,7 +89,7 @@ type Project_Description enso_project.namespace namespace : Text - namespace self = self.prim_config.namespace + namespace self = self.ns ## ICON enso_icon Returns the Enso project description for the project that the engine was diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso index 7c56510c72fb..05a92252b3df 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP.enso @@ -30,12 +30,17 @@ from project.Data.Json.Extensions import all polyglot java import java.lang.Exception as JException polyglot java import java.net.http.HttpClient +polyglot java import java.net.http.HttpClient.Redirect +polyglot java import java.net.http.HttpClient.Version +polyglot java import java.net.http.HttpClient.Builder as ClientBuilder polyglot java import java.net.http.HttpRequest polyglot java import java.net.http.HttpRequest.BodyPublisher +polyglot java import java.net.http.HttpRequest.BodyPublishers +polyglot java import java.net.http.HttpRequest.Builder polyglot java import java.net.InetSocketAddress polyglot java import java.net.ProxySelector -polyglot java import java.nio.file.Path polyglot java import javax.net.ssl.SSLContext +polyglot java import org.enso.base.file_system.File_Utils polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper polyglot java import org.enso.base.net.http.MultipartBodyBuilder polyglot java import org.enso.base.net.http.UrlencodedBodyBuilder @@ -242,7 +247,7 @@ resolve_body_to_publisher_and_boundary body:Request_Body = json.if_not_error <| Pair.new (body_publishers.ofString json) Nothing Request_Body.Binary file -> - path = Path.of file.path + path = File_Utils.toPath file.path Pair.new (body_publishers.ofFile path) Nothing Request_Body.Form_Data form_data url_encoded -> build_form_body_publisher form_data url_encoded diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Response.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Response.enso index febf5b30ebc2..44fe5a0de624 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Response.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Response.enso @@ -25,6 +25,10 @@ from project.Data.Text.Extensions import all from project.Metadata import Display, Widget from project.Network.HTTP.Response_Body import decode_format_selector +polyglot java import java.net.http.HttpHeaders +polyglot java import org.enso.base.enso_cloud.EnsoHttpResponse +polyglot java import java.util.Optional + type Response ## PRIVATE diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File.enso index 5310ad036fe0..791ca7086495 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File.enso @@ -42,13 +42,12 @@ from project.System.File_Format import Auto_Detect, File_Format polyglot java import java.io.File as Java_File polyglot java import java.io.InputStream as Java_Input_Stream polyglot java import java.io.OutputStream as Java_Output_Stream -polyglot java import java.nio.file.FileSystems -polyglot java import java.nio.file.Path polyglot java import java.nio.file.StandardCopyOption polyglot java import java.nio.file.StandardOpenOption polyglot java import java.time.ZonedDateTime polyglot java import org.enso.base.DryRunFileManager polyglot java import org.enso.base.file_system.FileSystemSPI +polyglot java import org.enso.base.file_system.File_Utils ## PRIVATE file_types : Vector @@ -795,11 +794,10 @@ type File _ -> used_filter = if recursive.not || name_filter.contains "**" then name_filter else (if name_filter.starts_with "*" then "*" else "**/") + name_filter - fs = FileSystems.getDefault - matcher = fs.getPathMatcher "glob:"+used_filter + matcher = File_Utils.matchPath "glob:"+used_filter all_files.filter file-> pathStr = self.relativize file . path - matcher.matches (Path.of pathStr) + File_Utils.matches matcher pathStr ## GROUP Metadata ICON metadata @@ -894,11 +892,11 @@ Writable_File.from (that : File) = if Data_Link.is_data_link that then Data_Link ## PRIVATE local_file_copy (source : File) (destination : File) (replace_existing : Boolean) -> Nothing = File_Error.handle_java_exceptions source <| - copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING] else [] + copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING.to_text] else [] source.copy_builtin destination copy_options ## PRIVATE local_file_move (source : File) (destination : File) (replace_existing : Boolean) -> Nothing = File_Error.handle_java_exceptions source <| - copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING] else [] + copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING.to_text] else [] source.move_builtin destination copy_options diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Access.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Access.enso index 3f5527c8de97..ed1d7c39a8df 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Access.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Access.enso @@ -49,18 +49,20 @@ type File_Access ## PRIVATE Convert this object into a representation understandable by the JVM. - to_java : StandardOpenOption - to_java self = case self of - File_Access.Append -> StandardOpenOption.APPEND - File_Access.Create -> StandardOpenOption.CREATE - File_Access.Create_New -> StandardOpenOption.CREATE_NEW - File_Access.Delete_On_Close -> StandardOpenOption.DELETE_ON_CLOSE - File_Access.Dsync -> StandardOpenOption.DSYNC - File_Access.Read -> StandardOpenOption.READ - File_Access.Sparse -> StandardOpenOption.SPARSE - File_Access.Sync -> StandardOpenOption.SYNC - File_Access.Truncate_Existing -> StandardOpenOption.TRUNCATE_EXISTING - File_Access.Write -> StandardOpenOption.WRITE + to_java : Text + to_java self = + java_option = case self of + File_Access.Append -> StandardOpenOption.APPEND + File_Access.Create -> StandardOpenOption.CREATE + File_Access.Create_New -> StandardOpenOption.CREATE_NEW + File_Access.Delete_On_Close -> StandardOpenOption.DELETE_ON_CLOSE + File_Access.Dsync -> StandardOpenOption.DSYNC + File_Access.Read -> StandardOpenOption.READ + File_Access.Sparse -> StandardOpenOption.SPARSE + File_Access.Sync -> StandardOpenOption.SYNC + File_Access.Truncate_Existing -> StandardOpenOption.TRUNCATE_EXISTING + File_Access.Write -> StandardOpenOption.WRITE + java_option.to_text ## PRIVATE ensure_only_allowed_options (operation_name : Text) (allowed_options : Vector) (got_options : Vector) ~action = diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Permissions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Permissions.enso index 8c247f78daf2..791e4add9052 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Permissions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/File/File_Permissions.enso @@ -3,6 +3,8 @@ import project.Data.Text.Text import project.Data.Vector.Vector polyglot java import java.nio.file.attribute.PosixFilePermission +polyglot java import java.nio.file.attribute.PosixFilePermissions +polyglot java import java.util.Set type Permission ## Permission for read access for a given entity. @@ -101,7 +103,8 @@ type File_Permissions ## PRIVATE ADVANCED Converts a Java `Set` of Java `PosixFilePermission` to `File_Permissions`. - from_java_set java_set = + from_java_set permissions:Text = + java_set = PosixFilePermissions.fromString permissions vecs = Vector.build_multiple 3 builders-> owner = builders.at 0 group = builders.at 1 diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Input_Stream.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Input_Stream.enso index 3fcbf7e15317..fb636a3873e3 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Input_Stream.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Input_Stream.enso @@ -23,6 +23,7 @@ polyglot java import java.io.InputStream as Java_Input_Stream polyglot java import org.enso.base.encoding.Encoding_Utils polyglot java import org.enso.base.encoding.ReportingStreamDecoder polyglot java import org.enso.base.Stream_Utils +polyglot java import org.enso.base.Stream_Utils.InputStreamLike ## PRIVATE An input stream, allowing for interactive reading of contents. @@ -113,7 +114,8 @@ type Input_Stream Arguments: - f: Applies a function over the internal java stream. with_java_stream : (Java_Input_Stream -> Any) -> Any - with_java_stream self f = self.stream_resource . with java_stream-> + with_java_stream self f = self.stream_resource . with java_like_stream-> + java_stream = Stream_Utils.asInputStream java_like_stream self.error_handler <| f java_stream ## PRIVATE @@ -158,7 +160,8 @@ type Input_Stream The current stream may be invalidated after the conversion, and it should no longer be used - only the returned stream should be used. as_peekable_stream self -> Input_Stream = if self.is_peekable then self else - raw_java_stream = self.stream_resource.take + raw_stream = self.stream_resource.take + raw_java_stream = Stream_Utils.asInputStream raw_stream buffered_stream = BufferedInputStream.new raw_java_stream Input_Stream.new buffered_stream self.error_handler self.associated_source diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Internal/Reporting_Stream_Decoder_Helper.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Internal/Reporting_Stream_Decoder_Helper.enso index 83ee49e76226..dc49ec2a3ab3 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Internal/Reporting_Stream_Decoder_Helper.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Internal/Reporting_Stream_Decoder_Helper.enso @@ -13,6 +13,7 @@ from project.Data.Boolean import Boolean, False, True from project.Runtime import assert polyglot java import org.enso.base.encoding.DecodingProblemAggregator +polyglot java import org.enso.base.encoding.DecodingProblem polyglot java import org.enso.base.encoding.Encoding_Utils polyglot java import org.enso.base.encoding.ReportingStreamDecoder diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Output_Stream.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Output_Stream.enso index fb2cd5b1cfc7..5ce7fe4526fb 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/System/Output_Stream.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/System/Output_Stream.enso @@ -15,6 +15,9 @@ from project.System.Input_Stream import close_stream polyglot java import java.io.ByteArrayOutputStream polyglot java import java.io.OutputStream as Java_Output_Stream polyglot java import org.enso.base.encoding.Encoding_Utils + +polyglot java import org.enso.base.Stream_Utils +polyglot java import org.enso.base.Stream_Utils.OutputStreamLike polyglot java import org.enso.base.encoding.ReportingStreamEncoder ## PRIVATE @@ -57,7 +60,7 @@ type Output_Stream - stream_resource: The internal resource that represents the underlying stream. - error_handler: An error handler for IOExceptions thrown when writing. - Value stream_resource error_handler + private Value stream_resource error_handler ## PRIVATE ADVANCED @@ -66,7 +69,8 @@ type Output_Stream Arguments: - contents: A vector of bytes to write. write_bytes : Vector Integer -> Nothing - write_bytes self contents = self.stream_resource . with java_stream-> + write_bytes self contents = self.stream_resource . with raw_stream-> + java_stream = Stream_Utils.asOutputStream raw_stream self.error_handler <| java_stream.write contents java_stream.flush @@ -80,7 +84,8 @@ type Output_Stream - input_stream: An Input_Stream to write to this stream. write_stream : Input_Stream -> Nothing write_stream self input_stream:Input_Stream = - self.stream_resource . with java_output_stream-> + self.stream_resource . with raw_stream-> + java_output_stream = Stream_Utils.asOutputStream raw_stream self.error_handler <| input_stream.with_java_stream java_input_stream-> java_input_stream.transferTo java_output_stream @@ -107,7 +112,9 @@ type Output_Stream Arguments: - f: Applies a function over the internal java stream. with_java_stream : (Java_Output_Stream -> Any) -> Any - with_java_stream self f = self.stream_resource . with f + with_java_stream self f = self.stream_resource . with raw_stream-> + java_stream = Stream_Utils.asOutputStream raw_stream + f java_stream ## PRIVATE ADVANCED diff --git a/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso b/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso index 4fe9b0360aea..e713fc45a010 100644 --- a/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso +++ b/distribution/lib/Standard/Table/0.0.0-dev/src/Table.enso @@ -2721,13 +2721,13 @@ type Table - root_name: The name of the root tag in the XML. - row_name: The name of the row tag in the XML. - on_problems: Specifies how to handle warnings if they occur, reporting - them as warnings by default. + them as warnings by default. ! Error Conditions - - If a column in `element_columns`, `attribute_columns` or `value_column` is not in + - If a column in `element_columns`, `attribute_columns` or `value_column` is not in the input table, a `Missing_Input_Columns` is raised as an error. - - If any incomming columns aree not specified in one of `element_columns`, + - If any incomming columns aree not specified in one of `element_columns`, `attribute_columns` or `value_column`, a `Unexpected_Extra_Columns` is reported according to the `on_problems` setting. @@ -2736,10 +2736,10 @@ type Table Input Table `table`: - Title | Author | Price | Year + Title | Author | Price | Year ------------------------+---------------------+-------+------ - A Tale Of Two Cities | Charles Dickens | 9.99 | 1859 - The Great Gatsby | F. Scott Fitzgerald | 5.99 | 1925 + A Tale Of Two Cities | Charles Dickens | 9.99 | 1859 + The Great Gatsby | F. Scott Fitzgerald | 5.99 | 1925 Result `r = t.to_xml ["Year"] ["Author", "Price"] "Title" "Books" "Book"`: @@ -2770,9 +2770,9 @@ type Table unused_columns = columns_helper.internal_columns.filter (Filter_Condition.Is_In resolved_element_columns+resolved_attribute_columns+[resolved_value_column] Filter_Action.Remove) . map .name if unused_columns.length > 0 then problem_builder.report_other_warning (Unexpected_Extra_Columns.Warning unused_columns) - + problem_builder.attach_problems_before on_problems <| - XML_Document.Value (Java_TableToXml.to_xml self.row_count java_element_columns java_attribute_column java_value_column root_name row_name) + XML_Document.new (Java_TableToXml.to_xml self.row_count java_element_columns java_attribute_column java_value_column root_name row_name) ## PRIVATE columns_helper : Table_Column_Helper diff --git a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso index 6fe511012264..bc7e7d83716a 100644 --- a/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso +++ b/distribution/lib/Standard/Test/0.0.0-dev/src/Test.enso @@ -205,8 +205,5 @@ type Test if i % 10 == 0 then IO.println 'Still failing after '+i.to_text+' retries ('+loc.to_display_text+'):\n'+caught_panic.payload.to_display_text Thread.sleep milliseconds_between_attempts - ## TODO This used to be - @Tail_Call go (i+1) - We should re-add the tail call once https://github.com/enso-org/enso/issues/9251 is fixed. - go (i+1) + @Tail_Call go (i+1) go 1 diff --git a/docs/infrastructure/native-image.md b/docs/infrastructure/native-image.md index 3dd872d00a80..b1091285b21f 100644 --- a/docs/infrastructure/native-image.md +++ b/docs/infrastructure/native-image.md @@ -207,17 +207,16 @@ state. To generate the Native Image for runner simply execute sbt> engine-runner/buildNativeImage ``` -and execute the binary on a sample factorial test program +and execute any program with that binary - for example `test/Base_Tests` ```bash -> runner --run engine/runner/src/test/resources/Factorial.enso 6 +$ runner --run test/Base_Tests ``` The task that generates the Native Image, along with all the necessary -configuration, reside in a separate project due to a bug in the currently used -GraalVM version. As September 2023 it can execute all Enso code, but cannot -invoke `IO.println` or other library functions that require -[polyglot java import](../../docs/polyglot/java.md), but read on... +configuration, makes sure that `Standard.Base` library calls into Java via +[polyglot java import](../../docs/polyglot/java.md) are compiled into the binary +and ready to be used. ### Engine with Espresso diff --git a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java index 86a7cddadbb1..3463df945e2b 100644 --- a/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java +++ b/engine/runner/src/main/java/org/enso/runner/EnsoLibraryFeature.java @@ -9,6 +9,7 @@ import org.enso.compiler.core.ir.module.scope.imports.Polyglot; import org.enso.pkg.PackageManager$; import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.hosted.RuntimeProxyCreation; import org.graalvm.nativeimage.hosted.RuntimeReflection; public final class EnsoLibraryFeature implements Feature { @@ -75,6 +76,9 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { RuntimeReflection.registerAllConstructors(clazz); RuntimeReflection.registerAllFields(clazz); RuntimeReflection.registerAllMethods(clazz); + if (clazz.isInterface()) { + RuntimeProxyCreation.register(clazz); + } } } } diff --git a/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/reflect-config.json b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/reflect-config.json index c54a35e2ae28..bcfb3e1fce1b 100644 --- a/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/reflect-config.json +++ b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/reflect-config.json @@ -50,12 +50,20 @@ { "name":"[Lscala.Tuple2;" }, +{ + "name":"[Lsun.security.pkcs.SignerInfo;" +}, { "name":"[S" }, { "name":"[Z" }, +{ + "name":"ch.qos.logback.classic.encoder.PatternLayoutEncoder", + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"ch.qos.logback.classic.pattern.DateConverter", "methods":[{"name":"","parameterTypes":[] }] @@ -80,6 +88,31 @@ "name":"ch.qos.logback.classic.pattern.NopThrowableInformationConverter", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"ch.qos.logback.classic.pattern.ThreadConverter", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"ch.qos.logback.core.ConsoleAppender", + "queryAllPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"ch.qos.logback.core.OutputStreamAppender", + "methods":[{"name":"setEncoder","parameterTypes":["ch.qos.logback.core.encoder.Encoder"] }] +}, +{ + "name":"ch.qos.logback.core.encoder.Encoder", + "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] +}, +{ + "name":"ch.qos.logback.core.encoder.LayoutWrappingEncoder", + "methods":[{"name":"setParent","parameterTypes":["ch.qos.logback.core.spi.ContextAware"] }] +}, +{ + "name":"ch.qos.logback.core.pattern.PatternLayoutEncoderBase", + "methods":[{"name":"setPattern","parameterTypes":["java.lang.String"] }] +}, { "name":"ch.qos.logback.core.rolling.helper.DateTokenConverter", "methods":[{"name":"","parameterTypes":[] }] @@ -88,6 +121,10 @@ "name":"ch.qos.logback.core.rolling.helper.IntegerTokenConverter", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"ch.qos.logback.core.spi.ContextAware", + "methods":[{"name":"valueOf","parameterTypes":["java.lang.String"] }] +}, { "name":"com.fasterxml.jackson.core.JsonProcessingException" }, @@ -179,6 +216,10 @@ "name":"com.sun.crypto.provider.GaloisCounterMode$AESGCM", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"com.sun.crypto.provider.HmacCore$HmacSHA256", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"com.sun.crypto.provider.TlsKeyMaterialGenerator", "methods":[{"name":"","parameterTypes":[] }] @@ -243,13 +284,29 @@ "name":"com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"com.typesafe.sslconfig.ssl.NoopHostnameVerifier", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"com.univocity.parsers.common.TextParsingException" +}, +{ + "name":"java.beans.Introspector" +}, +{ + "name":"java.io.BufferedInputStream" +}, { "name":"java.io.ByteArrayInputStream" }, +{ + "name":"java.io.ByteArrayOutputStream" +}, { "name":"java.io.File" }, @@ -271,15 +328,27 @@ { "name":"java.io.OutputStream" }, +{ + "name":"java.io.PrintWriter" +}, +{ + "name":"java.io.Reader" +}, { "name":"java.io.Serializable" }, { "name":"java.io.StringReader" }, +{ + "name":"java.io.StringWriter" +}, { "name":"java.io.UncheckedIOException" }, +{ + "name":"java.io.Writer" +}, { "name":"java.lang.ArithmeticException" }, @@ -402,6 +471,9 @@ "name":"java.lang.Throwable", "methods":[{"name":"addSuppressed","parameterTypes":["java.lang.Throwable"] }] }, +{ + "name":"java.lang.UnsupportedOperationException" +}, { "name":"java.lang.Void", "fields":[{"name":"TYPE"}] @@ -527,15 +599,39 @@ { "name":"java.net.http.HttpClient" }, +{ + "name":"java.net.http.HttpClient$Builder" +}, +{ + "name":"java.net.http.HttpClient$Redirect" +}, +{ + "name":"java.net.http.HttpClient.Builder" +}, +{ + "name":"java.net.http.HttpClient.Redirect" +}, { "name":"java.net.http.HttpRequest" }, { "name":"java.net.http.HttpRequest$BodyPublisher" }, +{ + "name":"java.net.http.HttpRequest$BodyPublishers" +}, +{ + "name":"java.net.http.HttpRequest$Builder" +}, { "name":"java.net.http.HttpRequest.BodyPublisher" }, +{ + "name":"java.net.http.HttpRequest.BodyPublishers" +}, +{ + "name":"java.net.http.HttpRequest.Builder" +}, { "name":"java.nio.Buffer" }, @@ -572,6 +668,9 @@ { "name":"java.nio.file.Path" }, +{ + "name":"java.nio.file.WatchEvent$Modifier" +}, { "name":"java.nio.file.Path[]" }, @@ -584,6 +683,9 @@ { "name":"java.nio.file.attribute.PosixFilePermission" }, +{ + "name":"java.nio.file.attribute.PosixFilePermissions" +}, { "name":"java.security.AlgorithmParametersSpi" }, @@ -623,12 +725,39 @@ { "name":"java.security.spec.DSAParameterSpec" }, +{ + "name":"java.sql.Connection" +}, +{ + "name":"java.sql.DatabaseMetaData" +}, { "name":"java.sql.Date" }, +{ + "name":"java.sql.JDBCType" +}, +{ + "name":"java.sql.PreparedStatement" +}, +{ + "name":"java.sql.ResultSet" +}, +{ + "name":"java.sql.ResultSetMetaData" +}, +{ + "name":"java.sql.SQLException" +}, +{ + "name":"java.sql.SQLTimeoutException" +}, { "name":"java.sql.Timestamp" }, +{ + "name":"java.sql.Types" +}, { "name":"java.text.DecimalFormat" }, @@ -710,6 +839,9 @@ { "name":"java.time.temporal.TemporalUnit" }, +{ + "name":"java.time.temporal.UnsupportedTemporalTypeException" +}, { "name":"java.util.AbstractList" }, @@ -719,9 +851,27 @@ { "name":"java.util.Base64" }, +{ + "name":"java.util.Base64$Decoder" +}, +{ + "name":"java.util.Base64$Encoder" +}, +{ + "name":"java.util.Base64.Decoder" +}, +{ + "name":"java.util.Base64.Encoder" +}, { "name":"java.util.Date" }, +{ + "name":"java.util.HashSet" +}, +{ + "name":"java.util.Iterator" +}, { "name":"java.util.List" }, @@ -746,6 +896,9 @@ { "name":"java.util.Random" }, +{ + "name":"java.util.Set" +}, { "name":"java.util.UUID" }, @@ -783,6 +936,9 @@ "name":"java.util.logging.LoggingMXBean", "queryAllPublicMethods":true }, +{ + "name":"java.util.regex.Pattern" +}, { "name":"javax.management.MBeanOperationInfo", "queryAllPublicMethods":true, @@ -834,6 +990,9 @@ { "name":"javax.xml.parsers.DocumentBuilderFactory" }, +{ + "name":"javax.xml.xpath.XPath" +}, { "name":"javax.xml.xpath.XPathConstants" }, @@ -924,6 +1083,15 @@ "name":"org.apache.commons.compress.archivers.zip.Zip64ExtendedInformationExtraField", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.apache.poi.UnsupportedFileFormatException" +}, +{ + "name":"org.apache.poi.poifs.filesystem.NotOLE2FileException" +}, +{ + "name":"org.apache.poi.ss.usermodel.Workbook" +}, { "name":"org.bouncycastle.jcajce.provider.asymmetric.COMPOSITE$Mappings", "methods":[{"name":"","parameterTypes":[] }] @@ -1388,18 +1556,54 @@ { "name":"org.enso.base.Regex_Utils" }, +{ + "name":"org.enso.base.Stream_Utils" +}, +{ + "name":"org.enso.base.Stream_Utils$InputStreamLike" +}, +{ + "name":"org.enso.base.Stream_Utils$OutputStreamLike" +}, +{ + "name":"org.enso.base.Stream_Utils.InputStreamLike" +}, +{ + "name":"org.enso.base.Stream_Utils.OutputStreamLike" +}, { "name":"org.enso.base.Text_Utils" }, { "name":"org.enso.base.Time_Utils" }, +{ + "name":"org.enso.base.Time_Utils$AdjustOp" +}, +{ + "name":"org.enso.base.Time_Utils.AdjustOp" +}, +{ + "name":"org.enso.base.WithProblems" +}, { "name":"org.enso.base.XML_Utils" }, { "name":"org.enso.base.arrays.LongArrayList" }, +{ + "name":"org.enso.base.encoding.DecodingProblem" +}, +{ + "name":"org.enso.base.encoding.DecodingProblemAggregator" +}, +{ + "name":"org.enso.base.encoding.Encoding_Utils" +}, +{ + "name":"org.enso.base.encoding.NewlineDetector" +}, { "name":"org.enso.base.encoding.ReportingStreamDecoder" }, @@ -1433,12 +1637,42 @@ { "name":"org.enso.base.enso_cloud.HideableValue" }, +{ + "name":"org.enso.base.enso_cloud.HideableValue$Base64EncodeValue" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue$ConcatValues" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue$PlainValue" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue$SecretValue" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue.Base64EncodeValue" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue.ConcatValues" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue.PlainValue" +}, +{ + "name":"org.enso.base.enso_cloud.HideableValue.SecretValue" +}, +{ + "name":"org.enso.base.enso_cloud.audit.AuditLog" +}, { "name":"org.enso.base.file_format.FileFormatSPI" }, { "name":"org.enso.base.file_system.FileSystemSPI" }, +{ + "name":"org.enso.base.file_system.File_Utils" +}, { "name":"org.enso.base.net.URITransformer" }, @@ -1457,6 +1691,12 @@ { "name":"org.enso.base.numeric.Decimal_Utils" }, +{ + "name":"org.enso.base.polyglot.NumericConverter" +}, +{ + "name":"org.enso.base.polyglot.WrappedDataflowError" +}, { "name":"org.enso.base.random.RandomInstanceHolder" }, @@ -1469,12 +1709,21 @@ { "name":"org.enso.base.statistics.FitError" }, +{ + "name":"org.enso.base.statistics.LinearModel" +}, { "name":"org.enso.base.statistics.Moments" }, { "name":"org.enso.base.statistics.Rank" }, +{ + "name":"org.enso.base.statistics.Rank$Method" +}, +{ + "name":"org.enso.base.statistics.Rank.Method" +}, { "name":"org.enso.base.statistics.Regression" }, @@ -1484,18 +1733,33 @@ { "name":"org.enso.base.text.CaseFoldedString" }, +{ + "name":"org.enso.base.text.GraphemeSpan" +}, { "name":"org.enso.base.text.Replacer_Cache" }, +{ + "name":"org.enso.base.text.ResultWithWarnings" +}, { "name":"org.enso.base.text.TextFoldingStrategy" }, +{ + "name":"org.enso.base.text.Utf16Span" +}, { "name":"org.enso.base.time.CustomTemporalUnits" }, { "name":"org.enso.base.time.Date_Period_Utils" }, +{ + "name":"org.enso.base.time.Date_Time_Utils" +}, +{ + "name":"org.enso.base.time.Date_Utils" +}, { "name":"org.enso.base.time.EnsoDateTimeFormatter" }, @@ -1509,19 +1773,32 @@ "name":"org.enso.base.time.FormatterKind" }, { - "name":"org.enso.base_test_helpers.CallbackHelper" + "name":"org.enso.base.time.Time_Of_Day_Utils" +}, +{ + "name":"org.enso.base_test_helpers.CallbackHelper", + "methods":[{"name":"runCallbackInt","parameterTypes":["java.util.function.Function","int"] }] +}, +{ + "name":"org.enso.base_test_helpers.FileSystemHelper", + "methods":[{"name":"setWritable","parameterTypes":["java.lang.String","boolean"] }] }, { - "name":"org.enso.base_test_helpers.FileSystemHelper" + "name":"org.enso.base_test_helpers.IntHolder", + "methods":[{"name":"","parameterTypes":["int"] }], + "fields":[{"name":"value"}, {"name":"boxed"}] }, { - "name":"org.enso.base_test_helpers.IntHolder" + "name":"org.enso.base_test_helpers.IntHolderEquals", + "methods":[{"name":"","parameterTypes":["int"] }] }, { - "name":"org.enso.base_test_helpers.IntHolderEquals" + "name":"org.enso.base_test_helpers.Number_Utils", + "methods":[{"name":"floatId","parameterTypes":["java.lang.Double"] }] }, { - "name":"org.enso.base_test_helpers.Number_Utils" + "name":"org.enso.base_test_helpers.RangeStream", + "methods":[{"name":"","parameterTypes":["int", "int"] }] }, { "name":"org.enso.compiler.core.ir.IrPersistance$PersistDiagnosticStorage", @@ -1535,6 +1812,10 @@ "name":"org.enso.compiler.core.ir.IrPersistance$PersistIdentifiedLocation", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.compiler.core.ir.IrPersistance$PersistJavaListLazy", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.enso.compiler.core.ir.IrPersistance$PersistLong", "methods":[{"name":"","parameterTypes":[] }] @@ -1755,6 +2036,14 @@ "name":"org.enso.compiler.core.ir.PersistWarning_DuplicatedImport", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.compiler.core.ir.PersistWarning_NotInvokable", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.core.ir.PersistWarning_TypeMismatch", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.enso.compiler.core.ir.PersistWarning_WrongBuiltinMethod", "methods":[{"name":"","parameterTypes":[] }] @@ -1907,6 +2196,10 @@ "name":"org.enso.compiler.pass.analyse.PersistTailCall$", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.compiler.pass.analyse.PersistTypeInference", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.enso.compiler.pass.analyse.PersistTypeNames$", "methods":[{"name":"","parameterTypes":[] }] @@ -1919,6 +2212,61 @@ "name":"org.enso.compiler.pass.analyse.PersistTypeSignatures_Signature", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistAtomTypeInterfaceFromBindingsMap", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistInferredType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistQualifiedName", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_ArrowType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_AtomType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_IntersectionType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_SumType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_TopType", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_TypeObject", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.compiler.pass.analyse.types.PersistTypeRepresentation_UnresolvedSymbol", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.database.DatabaseConnectionDetailsSPI" +}, +{ + "name":"org.enso.database.JDBCProxy" +}, +{ + "name":"org.enso.database.JDBCUtils" +}, +{ + "name":"org.enso.database.dryrun.HiddenTableReferenceCounter" +}, +{ + "name":"org.enso.database.dryrun.OperationSynchronizer" +}, { "name":"org.enso.interpreter.caches.ImportExportCache$PersistBindingsMap", "methods":[{"name":"","parameterTypes":[] }] @@ -1955,6 +2303,10 @@ "name":"org.enso.interpreter.caches.PersistBindingsMap$SymbolRestriction$Union", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.interpreter.caches.PersistBindingsMap_Argument", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.enso.interpreter.caches.PersistBindingsMap_Cons", "methods":[{"name":"","parameterTypes":[] }] @@ -2007,44 +2359,92 @@ "name":"org.enso.interpreter.caches.PersistBindingsMap_Type", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"org.enso.interpreter.caches.PersistLibraryName", + "methods":[{"name":"","parameterTypes":[] }] +}, { "name":"org.enso.interpreter.caches.PersistQualifiedName", "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.Any", + "name":"org.enso.interpreter.caches.PersistSuggestion_Argument", "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.Boolean", + "name":"org.enso.interpreter.caches.PersistSuggestion_Constructor", "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.CreateProcessSystemMethodGen", - "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] + "name":"org.enso.interpreter.caches.PersistSuggestion_Conversion", + "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.EmptyMapMethodGen", - "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] + "name":"org.enso.interpreter.caches.PersistSuggestion_DefinedMethod", + "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.Error", + "name":"org.enso.interpreter.caches.PersistSuggestion_Function", "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.ExitSystemMethodGen", - "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] + "name":"org.enso.interpreter.caches.PersistSuggestion_Getter", + "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.Is_normalizedTextMethodGen", - "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] + "name":"org.enso.interpreter.caches.PersistSuggestion_Local", + "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.Is_unixSystemMethodGen", - "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] + "name":"org.enso.interpreter.caches.PersistSuggestion_Module", + "methods":[{"name":"","parameterTypes":[] }] }, { - "name":"org.enso.interpreter.node.expression.builtin.LengthTextMethodGen", + "name":"org.enso.interpreter.caches.PersistSuggestion_Type", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.caches.PersistSuggestionsCache_CachedSuggestions", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.caches.PersistUtils$PersistArrayList", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.Any", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.Boolean", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.CreateProcessSystemMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.EmptyMapMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.Error", + "methods":[{"name":"","parameterTypes":[] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.ExitSystemMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.Is_normalizedTextMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.Is_unixSystemMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, +{ + "name":"org.enso.interpreter.node.expression.builtin.LengthTextMethodGen", "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] }, { @@ -2367,6 +2767,10 @@ "name":"org.enso.interpreter.node.expression.builtin.error.GetAllArrayWarningMethodGen", "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] }, +{ + "name":"org.enso.interpreter.node.expression.builtin.error.GetAllVectorWarningMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, { "name":"org.enso.interpreter.node.expression.builtin.error.GetAttachedStackTraceMethodGen", "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] @@ -3055,6 +3459,10 @@ "name":"org.enso.interpreter.node.expression.builtin.resource.RegisterManagedResourceMethodGen", "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] }, +{ + "name":"org.enso.interpreter.node.expression.builtin.resource.TakeManagedResourceMethodGen", + "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] +}, { "name":"org.enso.interpreter.node.expression.builtin.resource.WithMethodGen", "methods":[{"name":"makeFunction","parameterTypes":["org.enso.interpreter.EnsoLanguage","boolean"] }] @@ -3190,6 +3598,405 @@ "name":"org.enso.runner.Main", "methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }] }, +{ + "name":"org.enso.table.aggregations.Aggregator" +}, +{ + "name":"org.enso.table.aggregations.Concatenate" +}, +{ + "name":"org.enso.table.aggregations.Count" +}, +{ + "name":"org.enso.table.aggregations.CountDistinct" +}, +{ + "name":"org.enso.table.aggregations.CountEmpty" +}, +{ + "name":"org.enso.table.aggregations.CountNothing" +}, +{ + "name":"org.enso.table.aggregations.First" +}, +{ + "name":"org.enso.table.aggregations.GroupBy" +}, +{ + "name":"org.enso.table.aggregations.Last" +}, +{ + "name":"org.enso.table.aggregations.Mean" +}, +{ + "name":"org.enso.table.aggregations.MinOrMax" +}, +{ + "name":"org.enso.table.aggregations.Mode" +}, +{ + "name":"org.enso.table.aggregations.Percentile" +}, +{ + "name":"org.enso.table.aggregations.ShortestOrLongest" +}, +{ + "name":"org.enso.table.aggregations.StandardDeviation" +}, +{ + "name":"org.enso.table.aggregations.Sum" +}, +{ + "name":"org.enso.table.data.column.builder.BigIntegerBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.BoolBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.Builder" +}, +{ + "name":"org.enso.table.data.column.builder.DateBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.DateTimeBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.InferredBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.LossOfBigDecimalPrecision" +}, +{ + "name":"org.enso.table.data.column.builder.LossOfIntegerPrecision" +}, +{ + "name":"org.enso.table.data.column.builder.NumericBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.StringBuilder" +}, +{ + "name":"org.enso.table.data.column.builder.TimeOfDayBuilder" +}, +{ + "name":"org.enso.table.data.column.operation.CountNothing" +}, +{ + "name":"org.enso.table.data.column.operation.UnaryOperation" +}, +{ + "name":"org.enso.table.data.column.operation.cast.CastProblemAggregator" +}, +{ + "name":"org.enso.table.data.column.operation.cast.ConversionFailure" +}, +{ + "name":"org.enso.table.data.column.operation.cast.ConversionFailureType" +}, +{ + "name":"org.enso.table.data.column.operation.map.MapOperationProblemAggregator" +}, +{ + "name":"org.enso.table.data.column.operation.unary.DatePartOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.IsEmptyOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.IsInfiniteOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.IsNaNOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.IsNothingOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.NotOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.TextLengthOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.TruncatedTimePartOperation" +}, +{ + "name":"org.enso.table.data.column.operation.unary.UnaryRoundOperation" +}, +{ + "name":"org.enso.table.data.column.storage.Storage" +}, +{ + "name":"org.enso.table.data.column.storage.numeric.LongRangeStorage" +}, +{ + "name":"org.enso.table.data.column.storage.type.AnyObjectType" +}, +{ + "name":"org.enso.table.data.column.storage.type.BigDecimalType" +}, +{ + "name":"org.enso.table.data.column.storage.type.BigIntegerType" +}, +{ + "name":"org.enso.table.data.column.storage.type.Bits" +}, +{ + "name":"org.enso.table.data.column.storage.type.BooleanType" +}, +{ + "name":"org.enso.table.data.column.storage.type.DateTimeType" +}, +{ + "name":"org.enso.table.data.column.storage.type.DateType" +}, +{ + "name":"org.enso.table.data.column.storage.type.FloatType" +}, +{ + "name":"org.enso.table.data.column.storage.type.IntegerType" +}, +{ + "name":"org.enso.table.data.column.storage.type.StorageType" +}, +{ + "name":"org.enso.table.data.column.storage.type.TextType" +}, +{ + "name":"org.enso.table.data.column.storage.type.TimeOfDayType" +}, +{ + "name":"org.enso.table.data.index.MultiValueIndex" +}, +{ + "name":"org.enso.table.data.mask.OrderMask" +}, +{ + "name":"org.enso.table.data.table.Column" +}, +{ + "name":"org.enso.table.data.table.Table" +}, +{ + "name":"org.enso.table.data.table.TableToXml" +}, +{ + "name":"org.enso.table.data.table.join.JoinKind" +}, +{ + "name":"org.enso.table.data.table.join.conditions.Between" +}, +{ + "name":"org.enso.table.data.table.join.conditions.Equals" +}, +{ + "name":"org.enso.table.data.table.join.conditions.EqualsIgnoreCase" +}, +{ + "name":"org.enso.table.data.table.join.lookup.LookupColumnDescription" +}, +{ + "name":"org.enso.table.data.table.join.lookup.LookupJoin" +}, +{ + "name":"org.enso.table.data.table.problems.ArithmeticError" +}, +{ + "name":"org.enso.table.data.table.problems.ArithmeticOverflow" +}, +{ + "name":"org.enso.table.data.table.problems.FloatingPointGrouping" +}, +{ + "name":"org.enso.table.data.table.problems.IgnoredNaN" +}, +{ + "name":"org.enso.table.data.table.problems.IgnoredNothing" +}, +{ + "name":"org.enso.table.data.table.problems.IllegalArgumentError" +}, +{ + "name":"org.enso.table.data.table.problems.InvalidAggregation" +}, +{ + "name":"org.enso.table.data.table.problems.UnquotedCharactersInOutput" +}, +{ + "name":"org.enso.table.data.table.problems.UnquotedDelimiter" +}, +{ + "name":"org.enso.table.error.ColumnCountMismatchException" +}, +{ + "name":"org.enso.table.error.ColumnNameMismatchException" +}, +{ + "name":"org.enso.table.error.EmptyFileException" +}, +{ + "name":"org.enso.table.error.EmptySheetException" +}, +{ + "name":"org.enso.table.error.ExistingDataException" +}, +{ + "name":"org.enso.table.error.InvalidColumnNameException" +}, +{ + "name":"org.enso.table.error.InvalidLocationException" +}, +{ + "name":"org.enso.table.error.NonUniqueLookupKey" +}, +{ + "name":"org.enso.table.error.NullValuesInKeyColumns" +}, +{ + "name":"org.enso.table.error.RangeExceededException" +}, +{ + "name":"org.enso.table.error.TooManyColumnsException" +}, +{ + "name":"org.enso.table.error.UnmatchedRow" +}, +{ + "name":"org.enso.table.error.ValueTypeMismatchException" +}, +{ + "name":"org.enso.table.excel.ExcelConnectionPool" +}, +{ + "name":"org.enso.table.excel.ExcelFileFormat" +}, +{ + "name":"org.enso.table.excel.ExcelHeaders" +}, +{ + "name":"org.enso.table.excel.ExcelRange" +}, +{ + "name":"org.enso.table.excel.ReadOnlyExcelConnection" +}, +{ + "name":"org.enso.table.expressions.ExpressionVisitorImpl" +}, +{ + "name":"org.enso.table.formatting.AnyObjectFormatter" +}, +{ + "name":"org.enso.table.formatting.BooleanFormatter" +}, +{ + "name":"org.enso.table.formatting.DateFormatter" +}, +{ + "name":"org.enso.table.formatting.DateTimeFormatter" +}, +{ + "name":"org.enso.table.formatting.DecimalFormatter" +}, +{ + "name":"org.enso.table.formatting.IntegerFormatter" +}, +{ + "name":"org.enso.table.formatting.TextFormatter" +}, +{ + "name":"org.enso.table.formatting.TimeFormatter" +}, +{ + "name":"org.enso.table.operations.AddRowNumber" +}, +{ + "name":"org.enso.table.operations.AddRunning" +}, +{ + "name":"org.enso.table.operations.OrderBuilder" +}, +{ + "name":"org.enso.table.parsing.BooleanParser" +}, +{ + "name":"org.enso.table.parsing.DateParser" +}, +{ + "name":"org.enso.table.parsing.DateTimeParser" +}, +{ + "name":"org.enso.table.parsing.IdentityParser" +}, +{ + "name":"org.enso.table.parsing.NumberParser" +}, +{ + "name":"org.enso.table.parsing.TimeOfDayParser" +}, +{ + "name":"org.enso.table.parsing.TypeInferringParser" +}, +{ + "name":"org.enso.table.parsing.WhitespaceStrippingParser" +}, +{ + "name":"org.enso.table.parsing.problems.AdditionalInvalidRows" +}, +{ + "name":"org.enso.table.parsing.problems.InvalidFormat" +}, +{ + "name":"org.enso.table.parsing.problems.InvalidRow" +}, +{ + "name":"org.enso.table.parsing.problems.MismatchedQuote" +}, +{ + "name":"org.enso.table.parsing.problems.ParseProblemAggregator" +}, +{ + "name":"org.enso.table.problems.ProblemAggregator" +}, +{ + "name":"org.enso.table.read.DelimitedReader" +}, +{ + "name":"org.enso.table.read.ExcelReader" +}, +{ + "name":"org.enso.table.read.ParsingFailedException" +}, +{ + "name":"org.enso.table.read.QuoteStrippingParser" +}, +{ + "name":"org.enso.table.util.ColumnMapper" +}, +{ + "name":"org.enso.table.util.NameDeduplicator" +}, +{ + "name":"org.enso.table.util.problems.DuplicateNames" +}, +{ + "name":"org.enso.table.util.problems.InvalidNames" +}, +{ + "name":"org.enso.table.write.DelimitedWriter" +}, +{ + "name":"org.enso.table.write.ExcelWriter" +}, +{ + "name":"org.enso.table.write.ExistingDataMode" +}, +{ + "name":"org.enso.table.write.ExistingFileBehavior" +}, +{ + "name":"org.enso.table.write.WriteQuoteBehavior" +}, { "name":"org.graalvm.collections.Pair" }, @@ -3224,12 +4031,24 @@ { "name":"org.openide.util.RequestProcessor" }, +{ + "name":"org.sqlite.SQLiteErrorCode" +}, +{ + "name":"org.sqlite.SQLiteException" +}, +{ + "name":"org.w3c.dom.Attr" +}, { "name":"org.w3c.dom.Document" }, { "name":"org.w3c.dom.Element" }, +{ + "name":"org.w3c.dom.NamedNodeMap" +}, { "name":"org.w3c.dom.Node" }, @@ -3388,6 +4207,9 @@ "name":"sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"sun.security.util.ObjectIdentifier" +}, { "name":"sun.security.x509.AuthorityInfoAccessExtension", "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] @@ -3404,6 +4226,9 @@ "name":"sun.security.x509.CRLDistributionPointsExtension", "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] }, +{ + "name":"sun.security.x509.CertificateExtensions" +}, { "name":"sun.security.x509.CertificatePoliciesExtension", "methods":[{"name":"","parameterTypes":["java.lang.Boolean","java.lang.Object"] }] diff --git a/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/resource-config.json b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/resource-config.json index db8b9343c210..e8b2a0b8e74e 100644 --- a/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/resource-config.json +++ b/engine/runner/src/main/resources/META-INF/native-image/org/enso/runner/resource-config.json @@ -1,6 +1,8 @@ { "resources":{ "includes":[{ + "pattern":"\\QMETA-INF/native-image/com.oracle.truffle.espresso/native-image.properties\\E" + }, { "pattern":"\\QMETA-INF/org/enso/interpreter/node/expression/builtin/BuiltinMethods.metadata\\E" }, { "pattern":"\\QMETA-INF/org/enso/interpreter/node/expression/builtin/BuiltinTypes.metadata\\E" @@ -52,6 +54,8 @@ "pattern":"\\QMETA-INF/services/java.time.zone.ZoneRulesProvider\\E" }, { "pattern":"\\QMETA-INF/services/javax.xml.parsers.DocumentBuilderFactory\\E" + }, { + "pattern":"\\QMETA-INF/services/javax.xml.parsers.SAXParserFactory\\E" }, { "pattern":"\\QMETA-INF/services/javax.xml.xpath.XPathFactory\\E" }, { @@ -166,6 +170,8 @@ "pattern":"\\Qversion.json\\E" }, { "pattern":"\\Qversion.properties\\E" + }, { + "pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt72b/nfkc.nrm\\E" }, { "pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt72b/uprops.icu\\E" }, { @@ -597,13 +603,13 @@ }]}, "bundles":[{ "name":"com.oracle.js.parser.resources.Messages", - "locales":[""] + "locales":["", "und"] }, { "name":"com.sun.org.apache.xerces.internal.impl.msg.XMLMessages", - "locales":[""] + "locales":["", "und"] }, { "name":"com.sun.org.apache.xml.internal.serializer.XMLEntities", - "locales":[""] + "locales":["", "und"] }, { "name":"com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages", "classNames":["com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages", "com.sun.org.apache.xml.internal.serializer.utils.SerializerMessages_en"] diff --git a/engine/runner/src/test/resources/Factorial.enso b/engine/runner/src/test/resources/Factorial.enso deleted file mode 100644 index ef86800b699f..000000000000 --- a/engine/runner/src/test/resources/Factorial.enso +++ /dev/null @@ -1,12 +0,0 @@ -import Standard.Base.Data.Numbers -import Standard.Base.IO - -fac n = - facacc n v = if n <= 1 then v else @Tail_Call facacc n-1 n*v - - res = facacc n 1 - res - -main number=5 = - v = fac number - IO.println v diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java index 4752d1126125..cab2c0456df0 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java @@ -183,13 +183,17 @@ public static PolyglotCallType getPolyglotCallType( return PolyglotCallType.CONVERT_TO_HASH_MAP; } - String methodName = symbol.getName(); - 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; + try { + String methodName = symbol.getName(); + 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; + } + } catch (TypeNotPresentException ex) { + // no call, get or instantiate is possible } return PolyglotCallType.NOT_SUPPORTED; } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EnsoProjectNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EnsoProjectNode.java index 69084e337a72..09d3a7f3f7a7 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EnsoProjectNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EnsoProjectNode.java @@ -98,10 +98,11 @@ private static Package getMainProjectFromCtx(EnsoContext ctx) { private static Atom createProjectDescriptionAtom(EnsoContext ctx, Package pkg) { var rootPath = new EnsoFile(pkg.root().normalize()); - var cfg = ctx.asGuestValue(pkg.getConfig()); + var namespace = pkg.getConfig().namespace(); + var name = pkg.getConfig().name(); var cons = ctx.getBuiltins().getProjectDescription().getUniqueConstructor(); - return AtomNewInstanceNode.getUncached().newInstance(cons, rootPath, cfg); + return AtomNewInstanceNode.getUncached().newInstance(cons, rootPath, namespace, name); } private DataflowError unsupportedArgsError(Object moduleActual) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/ProjectDescription.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/ProjectDescription.java index 053a96a3dceb..6d93c6805cae 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/ProjectDescription.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/ProjectDescription.java @@ -13,6 +13,6 @@ protected String getConstructorName() { @Override protected List getConstructorParamNames() { - return List.of("prim_root_file", "prim_config"); + return List.of("prim_root_file", "ns", "n"); } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java index d80c8cb71aab..5d2de7614117 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/data/EnsoFile.java @@ -4,9 +4,13 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.TruffleFile; import com.oracle.truffle.api.dsl.Bind; +import com.oracle.truffle.api.dsl.Cached; +import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.interop.InteropLibrary; import com.oracle.truffle.api.interop.InvalidArrayIndexException; +import com.oracle.truffle.api.interop.UnknownIdentifierException; import com.oracle.truffle.api.interop.UnsupportedMessageException; +import com.oracle.truffle.api.interop.UnsupportedTypeException; import com.oracle.truffle.api.library.CachedLibrary; import com.oracle.truffle.api.library.ExportLibrary; import com.oracle.truffle.api.library.ExportMessage; @@ -22,16 +26,22 @@ import java.nio.file.NoSuchFileException; import java.nio.file.NotDirectoryException; import java.nio.file.OpenOption; +import java.nio.file.StandardCopyOption; import java.nio.file.StandardOpenOption; -import java.nio.file.attribute.PosixFilePermission; +import java.nio.file.attribute.PosixFilePermissions; import java.time.ZoneOffset; import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Set; -import java.util.function.IntFunction; +import java.util.function.Function; import org.enso.interpreter.dsl.Builtin; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.data.text.Text; +import org.enso.interpreter.runtime.data.vector.ArrayLikeAtNode; import org.enso.interpreter.runtime.data.vector.ArrayLikeHelpers; +import org.enso.interpreter.runtime.data.vector.ArrayLikeLengthNode; import org.enso.interpreter.runtime.error.PanicException; import org.enso.interpreter.runtime.library.dispatch.TypesLibrary; @@ -54,60 +64,273 @@ public EnsoFile(TruffleFile truffleFile) { @Builtin.Method(name = "output_stream_builtin") @Builtin.WrapException(from = IOException.class) - @Builtin.ReturningGuestObject @Builtin.Specialize - @CompilerDirectives.TruffleBoundary - public OutputStream outputStream(Object opts, EnsoContext ctx) throws IOException { - OpenOption[] openOptions = - convertInteropArray(opts, InteropLibrary.getUncached(), ctx, OpenOption[]::new); - return this.truffleFile.newOutputStream(openOptions); + @TruffleBoundary + public EnsoObject outputStream( + Object opts, + @Cached ArrayLikeLengthNode lengthNode, + @Cached ArrayLikeAtNode atNode, + EnsoContext ctx) + throws IOException { + var options = namesToValues(opts, lengthNode, atNode, ctx, StandardOpenOption::valueOf); + var os = this.truffleFile.newOutputStream(options.toArray(OpenOption[]::new)); + return new EnsoOutputStream(os); + } + + @ExportLibrary(InteropLibrary.class) + static final class EnsoOutputStream implements EnsoObject { + private static final String[] MEMBERS = new String[] {"write", "flush", "close"}; + private final OutputStream os; + + EnsoOutputStream(OutputStream os) { + this.os = os; + } + + @ExportMessage + boolean hasMembers() { + return true; + } + + @TruffleBoundary + @ExportMessage + boolean isMemberInvocable(String member) { + return Arrays.asList(MEMBERS).contains(member); + } + + @ExportMessage + Object getMembers(boolean includeInternal) throws UnsupportedMessageException { + return ArrayLikeHelpers.wrapStrings(MEMBERS); + } + + @TruffleBoundary + @ExportMessage + Object invokeMember( + String name, + Object[] args, + @Cached ArrayLikeLengthNode lengthNode, + @Cached ArrayLikeAtNode atNode, + @CachedLibrary(limit = "3") InteropLibrary iop) + throws ArityException, UnsupportedMessageException, UnknownIdentifierException { + try { + return switch (name) { + case "write" -> { + long from; + long to; + switch (args.length) { + case 1 -> { + from = 0; + to = lengthNode.executeLength(args[0]); + } + case 3 -> { + from = iop.asLong(args[1]); + to = from + iop.asLong(args[2]); + } + default -> { + throw ArityException.create(1, 3, args.length); + } + } + for (long i = from; i < to; i++) { + var elem = atNode.executeAt(args[0], i); + var byt = iop.asInt(elem); + os.write(byt); + } + yield this; + } + case "flush" -> { + os.flush(); + yield this; + } + case "close" -> { + os.close(); + yield this; + } + default -> throw UnknownIdentifierException.create(name); + }; + } catch (IOException ex) { + throw raiseIOException(iop, ex); + } catch (InvalidArrayIndexException ex) { + var ctx = EnsoContext.get(iop); + throw ctx.raiseAssertionPanic(iop, name, ex); + } + } + + @Override + public String toString() { + return "EnsoOutputStream"; + } } @Builtin.Method(name = "input_stream_builtin") @Builtin.WrapException(from = IOException.class) @Builtin.Specialize - @Builtin.ReturningGuestObject - @CompilerDirectives.TruffleBoundary - public InputStream inputStream(Object opts, EnsoContext ctx) throws IOException { - OpenOption[] openOptions = - convertInteropArray(opts, InteropLibrary.getUncached(), ctx, OpenOption[]::new); - return this.truffleFile.newInputStream(openOptions); + @TruffleBoundary + public EnsoObject inputStream( + Object opts, + @Cached ArrayLikeLengthNode lengthNode, + @Cached ArrayLikeAtNode atNode, + EnsoContext ctx) + throws IOException { + var options = namesToValues(opts, lengthNode, atNode, ctx, StandardOpenOption::valueOf); + var is = this.truffleFile.newInputStream(options.toArray(OpenOption[]::new)); + return new EnsoInputStream(is); + } + + @ExportLibrary(InteropLibrary.class) + static final class EnsoInputStream implements EnsoObject { + private static final String[] MEMBERS = + new String[] { + "read", "readAllBytes", "readNBytes", "skipNBytes", "markSupported", "available", "close" + }; + private final InputStream is; + + EnsoInputStream(InputStream is) { + this.is = is; + } + + @ExportMessage + boolean hasMembers() { + return true; + } + + @TruffleBoundary + @ExportMessage + boolean isMemberInvocable(String member) { + return Arrays.asList(MEMBERS).contains(member); + } + + @ExportMessage + Object getMembers(boolean includeInternal) throws UnsupportedMessageException { + return ArrayLikeHelpers.wrapStrings(MEMBERS); + } + + @TruffleBoundary + @ExportMessage + Object invokeMember(String name, Object[] args, @CachedLibrary(limit = "3") InteropLibrary iop) + throws UnknownIdentifierException, + UnsupportedMessageException, + ArityException, + UnsupportedTypeException { + try { + return switch (name) { + case "read" -> { + if (args.length == 0) { + yield is.read(); + } + long from; + long to; + switch (args.length) { + case 1 -> { + from = 0; + to = iop.getArraySize(args[0]); + } + case 3 -> { + from = iop.asLong(args[1]); + to = from + iop.asLong(args[2]); + } + default -> throw ArityException.create(0, 3, args.length); + } + for (var i = from; i < to; i++) { + var b = is.read(); + if (b == -1) { + var count = i - from; + yield count > 0 ? count : -1; + } + iop.writeArrayElement(args[0], i, (byte) b); + } + yield to - from; + } + case "readAllBytes" -> { + if (args.length != 0) { + throw ArityException.create(0, 0, args.length); + } + var arr = is.readAllBytes(); + var buf = ByteBuffer.wrap(arr); + yield ArrayLikeHelpers.wrapBuffer(buf); + } + case "readNBytes" -> { + if (args.length != 1) { + throw ArityException.create(1, 1, args.length); + } + var len = iop.asInt(args[0]); + var arr = is.readNBytes(len); + var buf = ByteBuffer.wrap(arr); + yield ArrayLikeHelpers.wrapBuffer(buf); + } + case "skipNBytes" -> { + if (args.length != 1) { + throw ArityException.create(1, 1, args.length); + } + var len = iop.asInt(args[0]); + is.skipNBytes(len); + yield this; + } + case "markSupported" -> { + if (args.length != 0) { + throw ArityException.create(0, 0, args.length); + } + yield is.markSupported(); + } + case "available" -> { + if (args.length != 0) { + throw ArityException.create(0, 0, args.length); + } + yield is.available(); + } + case "close" -> { + if (args.length != 0) { + throw ArityException.create(0, 0, args.length); + } + is.close(); + yield this; + } + default -> throw UnknownIdentifierException.create(name); + }; + } catch (IOException ex) { + throw raiseIOException(iop, ex); + } catch (InvalidArrayIndexException ex) { + var ctx = EnsoContext.get(iop); + throw ctx.raiseAssertionPanic(iop, name, ex); + } + } + + @Override + public String toString() { + return "EnsoInputStream"; + } } @SuppressWarnings("unchecked") - private static T[] convertInteropArray( - Object arr, InteropLibrary interop, EnsoContext ctx, IntFunction hostArrayCtor) { - if (!interop.hasArrayElements(arr)) { - var vecType = ctx.getBuiltins().vector().getType(); - var typeError = ctx.getBuiltins().error().makeTypeError(vecType, arr, "opts"); - throw new PanicException(typeError, interop); - } - T[] hostArr; + @TruffleBoundary + private static List namesToValues( + Object arr, + ArrayLikeLengthNode lengthNode, + ArrayLikeAtNode atNode, + EnsoContext ctx, + Function convertor) { + var size = (int) lengthNode.executeLength(arr); + List hostArr = new ArrayList<>(); try { - int size = Math.toIntExact(interop.getArraySize(arr)); - hostArr = hostArrayCtor.apply(size); - for (int i = 0; i < size; i++) { - Object elem = interop.readArrayElement(arr, i); - if (!ctx.isJavaPolyglotObject(elem)) { + for (var i = 0; i < size; i++) { + var elem = atNode.executeAt(arr, i); + if (elem instanceof Text name) { + hostArr.add(convertor.apply(name.toString())); + } else { var err = ctx.getBuiltins() .error() - .makeUnsupportedArgumentsError( - new Object[] {arr}, - "Arguments to opts should be host objects from java.io package"); - throw new PanicException(err, interop); + .makeTypeError(ctx.getBuiltins().text(), elem, "File_Access permissions"); + throw new PanicException(err, lengthNode); } - hostArr[i] = (T) ctx.asJavaPolyglotObject(elem); } - } catch (ClassCastException | UnsupportedMessageException | InvalidArrayIndexException e) { - throw EnsoContext.get(interop).raiseAssertionPanic(interop, null, e); + } catch (ClassCastException | InvalidArrayIndexException e) { + throw EnsoContext.get(lengthNode).raiseAssertionPanic(lengthNode, null, e); } return hostArr; } @Builtin.Method(name = "read_last_bytes_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoObject readLastBytes(long n) throws IOException { try (SeekableByteChannel channel = this.truffleFile.newByteChannel(Set.of(StandardOpenOption.READ))) { @@ -136,7 +359,7 @@ public boolean exists() { @Builtin.Method(name = "creation_time_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoDateTime getCreationTime() throws IOException { return new EnsoDateTime( ZonedDateTime.ofInstant(truffleFile.getCreationTime().toInstant(), ZoneOffset.UTC)); @@ -144,7 +367,7 @@ public EnsoDateTime getCreationTime() throws IOException { @Builtin.Method(name = "last_modified_time_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoDateTime getLastModifiedTime() throws IOException { return new EnsoDateTime( ZonedDateTime.ofInstant(truffleFile.getLastModifiedTime().toInstant(), ZoneOffset.UTC)); @@ -152,14 +375,13 @@ public EnsoDateTime getLastModifiedTime() throws IOException { @Builtin.Method(name = "posix_permissions_builtin") @Builtin.WrapException(from = IOException.class) - @Builtin.ReturningGuestObject - @CompilerDirectives.TruffleBoundary - public Set getPosixPermissions() throws IOException { - return truffleFile.getPosixPermissions(); + @TruffleBoundary + public Text getPosixPermissions() throws IOException { + return Text.create(PosixFilePermissions.toString(truffleFile.getPosixPermissions())); } @Builtin.Method(name = "parent") - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoObject getParent() { // Normalization is needed to correctly handle paths containing `..` and `.`. var parentOrNull = this.normalize().truffleFile.getParent(); @@ -179,32 +401,32 @@ public EnsoObject getParent() { } @Builtin.Method(name = "absolute") - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoFile getAbsoluteFile() { return new EnsoFile(this.truffleFile.getAbsoluteFile()); } @Builtin.Method(name = "path") - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public Text getPath() { return Text.create(this.truffleFile.getPath()); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public boolean isAbsolute() { return this.truffleFile.isAbsolute(); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public boolean isDirectory() { return this.truffleFile.isDirectory(); } @Builtin.Method(name = "create_directory_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public void createDirectories() throws IOException { try { this.truffleFile.createDirectories(); @@ -282,32 +504,32 @@ private static FileSystemException replaceCreateDirectoriesGenericException( @Builtin.Method(name = "list_immediate_children_array") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoObject list() throws IOException { return ArrayLikeHelpers.wrapEnsoObjects( this.truffleFile.list().stream().map(EnsoFile::new).toArray(EnsoFile[]::new)); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoFile relativize(EnsoFile other) { return new EnsoFile(this.truffleFile.relativize(other.truffleFile)); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public boolean isRegularFile() { return this.truffleFile.isRegularFile(); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public boolean isWritable() { return this.truffleFile.isWritable(); } @Builtin.Method(name = "name") - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public Text getName() { var name = this.normalize().truffleFile.getName(); return Text.create(name == null ? "/" : name); @@ -315,7 +537,7 @@ public Text getName() { @Builtin.Method(name = "size_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public long getSize() throws IOException { if (this.truffleFile.isDirectory()) { throw new IOException("size can only be called on files."); @@ -334,7 +556,7 @@ public boolean equals(Object obj) { } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public EnsoFile normalize() { TruffleFile simplyNormalized = truffleFile.normalize(); String name = simplyNormalized.getName(); @@ -347,7 +569,7 @@ public EnsoFile normalize() { @Builtin.Method(name = "delete_builtin") @Builtin.WrapException(from = IOException.class) - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public void delete(boolean recursive) throws IOException { if (recursive && truffleFile.isDirectory(LinkOption.NOFOLLOW_LINKS)) { deleteRecursively(truffleFile); @@ -368,25 +590,35 @@ private void deleteRecursively(TruffleFile file) throws IOException { @Builtin.Method(name = "copy_builtin", description = "Copy this file to a target destination") @Builtin.WrapException(from = IOException.class) @Builtin.Specialize - @CompilerDirectives.TruffleBoundary - public void copy(EnsoFile target, Object options, EnsoContext ctx) throws IOException { - CopyOption[] copyOptions = - convertInteropArray(options, InteropLibrary.getUncached(), ctx, CopyOption[]::new); - truffleFile.copy(target.truffleFile, copyOptions); + @TruffleBoundary + public void copy( + EnsoFile target, + Object options, + @Cached ArrayLikeLengthNode lengthNode, + @Cached ArrayLikeAtNode atNode, + EnsoContext ctx) + throws IOException { + var copyOptions = namesToValues(options, lengthNode, atNode, ctx, StandardCopyOption::valueOf); + truffleFile.copy(target.truffleFile, copyOptions.toArray(CopyOption[]::new)); } @Builtin.Method(name = "move_builtin", description = "Move this file to a target destination") @Builtin.WrapException(from = IOException.class) @Builtin.Specialize - @CompilerDirectives.TruffleBoundary - public void move(EnsoFile target, Object options, EnsoContext ctx) throws IOException { - CopyOption[] copyOptions = - convertInteropArray(options, InteropLibrary.getUncached(), ctx, CopyOption[]::new); - truffleFile.move(target.truffleFile, copyOptions); + @TruffleBoundary + public void move( + EnsoFile target, + Object options, + @Cached ArrayLikeLengthNode lengthNode, + @Cached ArrayLikeAtNode atNode, + EnsoContext ctx) + throws IOException { + var copyOptions = namesToValues(options, lengthNode, atNode, ctx, StandardCopyOption::valueOf); + truffleFile.move(target.truffleFile, copyOptions.toArray(CopyOption[]::new)); } @Builtin.Method - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public boolean startsWith(EnsoFile parent) { return truffleFile.startsWith(parent.truffleFile); } @@ -397,7 +629,7 @@ public boolean startsWith(EnsoFile parent) { "Takes the text representation of a path and returns a TruffleFile corresponding to it.", autoRegister = false) @Builtin.Specialize - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public static EnsoFile fromString(EnsoContext context, String path) { TruffleFile file = context.getPublicTruffleFile(path); return new EnsoFile(file); @@ -408,7 +640,7 @@ public static EnsoFile fromString(EnsoContext context, String path) { description = "A file corresponding to the current working directory.", autoRegister = false) @Builtin.Specialize - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public static EnsoFile currentDirectory(EnsoContext context) { TruffleFile file = context.getCurrentWorkingDirectory(); return new EnsoFile(file); @@ -419,13 +651,13 @@ public static EnsoFile currentDirectory(EnsoContext context) { description = "Gets the user's system-defined home directory.", autoRegister = false) @Builtin.Specialize - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public static EnsoFile userHome(EnsoContext context) { return fromString(context, System.getProperty("user.home")); } @Override - @CompilerDirectives.TruffleBoundary + @TruffleBoundary public String toString() { return "(File " + truffleFile.getPath() + ")"; } @@ -449,4 +681,10 @@ boolean hasType() { Type getType(@Bind("$node") Node node) { return EnsoContext.get(node).getBuiltins().file(); } + + static RuntimeException raiseIOException(Node where, IOException ex) { + var ctx = EnsoContext.get(where); + var guestEx = ctx.asGuestValue(ex); + throw new PanicException(guestEx, where); + } } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java index 9fc608c994a3..2493789d0066 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/error/PanicException.java @@ -111,8 +111,12 @@ boolean hasExceptionMessage() { } @NeverDefault - static UnresolvedSymbol toDisplayText(IndirectInvokeMethodNode payloads) { + static UnresolvedSymbol toDisplayText(IndirectInvokeMethodNode payloads) + throws UnsupportedMessageException { var ctx = EnsoContext.get(payloads); + if (ctx == null) { + throw UnsupportedMessageException.create(); + } var scope = ctx.getBuiltins().panic().getDefinitionScope(); return UnresolvedSymbol.build("to_display_text", scope); } diff --git a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java index 8e355c2dd375..d2c8a75fef2f 100644 --- a/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java +++ b/lib/rust/parser/generate-java/java/org/enso/syntax2/Parser.java @@ -24,26 +24,31 @@ private static void initializeLibraries() { name = "libenso_parser.so"; } - File parser = null; + var whereAmI = Parser.class.getProtectionDomain().getCodeSource().getLocation(); + File root; try { - var whereAmI = Parser.class.getProtectionDomain().getCodeSource().getLocation(); - var d = new File(whereAmI.toURI()).getParentFile(); + root = new File(whereAmI.toURI()).getParentFile(); + } catch (URISyntaxException ex) { + root = new File(".").getAbsoluteFile(); + } + try { + var d = root; File path = null; while (d != null) { path = new File(d, name); if (path.exists()) break; d = d.getParentFile(); } - if (d == null) { - throw new LinkageError( - "Cannot find parser in " + new File(whereAmI.toURI()).getParentFile()); + if (d == null || path == null) { + throw new LinkageError("Cannot find parser in " + root); } - parser = path; - System.load(parser.getAbsolutePath()); - } catch (IllegalArgumentException | URISyntaxException | LinkageError e) { - File root = new File(".").getAbsoluteFile(); + System.load(path.getAbsolutePath()); + } catch (NullPointerException | IllegalArgumentException | LinkageError e) { if (!searchFromDirToTop(e, root, "target", "rust", "debug", name)) { - throw new IllegalStateException("Cannot load parser from " + parser, e); + if (!searchFromDirToTop( + e, new File(".").getAbsoluteFile(), "target", "rust", "debug", name)) { + throw new IllegalStateException("Cannot load parser from " + root, e); + } } } } diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/Builtin.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/Builtin.java index 789f34aab785..850b90f4cbf6 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/Builtin.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/Builtin.java @@ -289,48 +289,6 @@ WrapException[] value() default {}; } - /** - * Annotation approving implicit {@link - * com.oracle.truffle.api.TruffleLanguage#asGuestValue(Object)} translation done on the return - * object. The conversion is generated automatically, depending on the type of the value. - * - *

Note that while explicit translations to interop value are discouraged, we still want to - * occasionally support it to easy builtins-writing process. The presence of the {@link - * ReturningGuestObject} only ensures that it is intentional. - * - *

Consider a method returning an {@link java.io.OutputStream} which is not an interop value, - * for the sake of the example: - * - *

-   * class Foo {
-   *     {@link Builtin.Method @Builtin.Method}
-   *     {@link Builtin.ReturningGuestObject @Builtin.ReturningGuestObject}
-   *     java.lang.OutputStream foo(Object item) {
-   *         return // ...
-   *     }
-   * }
-   * 
- * - * The processor will detect the return type of method {@code foo} and perform an automatic - * conversion: - * - *
-   * {@link BuiltinMethod @BuiltinMethod}(type = "Foo", name = "create")
-   * public class CreateFooNode extends Node {
-   *   java.lang.Object execute(Foo self, Object item) {
-   *     return context
-   *           .asGuestValue(self.foo(item));
-   *   }
-   * }
-   * 
- * - * Without converting the object to the guest language value, it would crash during runtime. - * Without the presence of the annotation, the processor would detect the potential value - * requiring {@link com.oracle.truffle.api.TruffleLanguage#asGuestValue(Object)} translation but - * stop and report the error since it didn't seem to be intended by the user. - */ - @interface ReturningGuestObject {} - /** * A Method marked with {@link Builtin.Specialize} annotation will generate specializations for * overloaded and non-overloaded methods. The annotation requires presence of {@link diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java index 5ae0b2c458f5..17806a3d297d 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/BuiltinsProcessor.java @@ -180,10 +180,6 @@ public void handleMethodElement(Element element, RoundEnvironment roundEnv) thro OK: if (!TypeWithKind.isValidGuestType(processingEnv, method.getReturnType())) { - if (method.getAnnotation(Builtin.ReturningGuestObject.class) != null) { - // guest objects can be of any type - break OK; - } if (method.getAnnotation(SuppressWarnings.class) instanceof SuppressWarnings sw && Arrays.asList(sw.value()).contains("generic-enso-builtin-type")) { // assume the case was review diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodGenerator.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodGenerator.java index d844ea95f658..c6ef343d058d 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodGenerator.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodGenerator.java @@ -105,8 +105,7 @@ protected String targetReturnType(TypeWithKind tpe) { Kind.ERROR, "Automatic conversion of value of type " + tpe.baseType() - + " to guest value requires explicit '@Builtin.ReturningGuestObject'" - + " annotation"); + + " is no longer supported."); } return "Object"; } diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodNodeClassGenerator.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodNodeClassGenerator.java index ea8e2b3f31f2..4ac4505934f3 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodNodeClassGenerator.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/MethodNodeClassGenerator.java @@ -8,7 +8,6 @@ import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.Element; import javax.tools.JavaFileObject; -import org.enso.interpreter.dsl.Builtin; public abstract class MethodNodeClassGenerator { ClassName builtinNode; @@ -29,7 +28,7 @@ public MethodNodeClassGenerator( * @return true if the annotation exists, false otherwise */ protected boolean needsGuestValueConversion(Element origin) { - return origin.getAnnotation(Builtin.ReturningGuestObject.class) != null; + return false; } public void generate( diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/NoSpecializationClassGenerator.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/NoSpecializationClassGenerator.java index 973b0761a414..64f80208ce96 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/NoSpecializationClassGenerator.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/NoSpecializationClassGenerator.java @@ -41,9 +41,7 @@ protected MethodGenerator methodsGen() { processingEnvironment .getMessager() .printMessage( - Kind.ERROR, - "Value is already TruffleObject, don't use @Builtin.ReturningGuestObject", - origin); + Kind.ERROR, "Value is already TruffleObject, don't need any conversions", origin); } return new ExecuteMethodImplGenerator( processingEnvironment, origin, asGuestValue, varArgExpansion); diff --git a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodsGenerator.java b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodsGenerator.java index f84e4e4ae2aa..fef6ddeb4803 100644 --- a/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodsGenerator.java +++ b/lib/scala/interpreter-dsl/src/main/java/org/enso/interpreter/dsl/builtins/SpecializedMethodsGenerator.java @@ -38,14 +38,12 @@ private SpecializedMethodsGenerator( elements, first.getModifiers().contains(Modifier.STATIC), first.getKind() == ElementKind.CONSTRUCTOR, - first.getAnnotation(Builtin.ReturningGuestObject.class) != null, + false, TypeWithKind.createFromTpe(first.getReturnType().toString())); // Make sure all methods were defined the same way, except for paramters' types assert (allEqual(elements.stream().map(e -> e.getModifiers().contains(Modifier.STATIC)))); assert (allEqual(elements.stream().map(e -> e.getKind() == ElementKind.CONSTRUCTOR))); - assert (allEqual( - elements.stream().map(e -> e.getAnnotation(Builtin.ReturningGuestObject.class) != null))); assert (allEqual( elements.stream().map(e -> TypeWithKind.createFromTpe(e.getReturnType().toString())))); } diff --git a/std-bits/base/src/main/java/org/enso/base/Stream_Utils.java b/std-bits/base/src/main/java/org/enso/base/Stream_Utils.java index d5fc7cfd41e2..04bd9e3be0f9 100644 --- a/std-bits/base/src/main/java/org/enso/base/Stream_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/Stream_Utils.java @@ -2,9 +2,84 @@ import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.util.Arrays; -public class Stream_Utils { +public final class Stream_Utils { + private Stream_Utils() {} + + /** + * Conversion interface. Any Enso/Truffle object with invocable {@read} member that takes three + * arguments is eligible for being treated as host Java {@link InputStream}. There are two + * overloaded {@link #asInputStream conversion methods}. The hosted Java interop system + * of Truffle will pick the more suitable one depending on the type of argument. + * + * @see #asInputStream + */ + public static interface InputStreamLike { + public int read(byte[] arr, int off, int len) throws IOException; + + public default int available() { + return 0; + } + } + + /** + * No conversion conversion. When the argument is already {@link InputStream} there is no need for + * doing any further conversions. + * + * @param is + * @return the {@code is} itself + */ + public static InputStream asInputStream(InputStream is) { + return is; + } + + /** + * Conversion to {@link InputStream}. When the argument looks like an input stream, let's + * wrap it. + * + * @param inputStreamLike any guest object with {@code read} method + * @return proper + */ + public static InputStream asInputStream(InputStreamLike inputStreamLike) { + return new GuestInputStream(inputStreamLike); + } + + /** + * Conversion interface. Any Enso/Truffle object with invocable {@write} member that takes three + * arguments is eligible for being treated as host Java {@link OutputStream}. There are two + * overloaded {@link #asOutputStream conversion methods}. The hosted Java interop system + * of Truffle will pick the more suitable one depending on the type of argument. + * + * @see #asOutputStream + */ + public static interface OutputStreamLike { + public void write(byte[] arr, int off, int len) throws IOException; + } + + /** + * No conversion conversion. When the argument is already {@link OutputStream} there is no need + * for doing any further conversions. + * + * @param os + * @return the {@code is} itself + */ + public static OutputStream asOutputStream(OutputStream os) { + return os; + } + + /** + * Conversion to {@link OutputStream}. When the argument looks like an output stream, + * let's wrap it. + * + * @param outputStreamLike any guest object with {@code write} method + * @return proper + */ + public static OutputStream asOutputStream(OutputStreamLike outputStreamLike) { + return new GuestOutputStream(outputStreamLike); + } + public static byte[] peek(InputStream stream, int n) throws IOException { assert n >= 0; assert stream.markSupported(); @@ -25,4 +100,64 @@ public static byte[] peek(InputStream stream, int n) throws IOException { } return buffer; } + + private static class GuestInputStream extends InputStream { + private final InputStreamLike inputStreamLike; + + private GuestInputStream(InputStreamLike inputStreamLike) { + this.inputStreamLike = inputStreamLike; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + return inputStreamLike.read(b, off, len); + } + + @Override + public int read() throws IOException { + byte[] arr = new byte[1]; + int read = read(arr, 0, 1); + if (read == -1) { + return -1; + } + if (read != 1) { + throw new IOException(); + } + return arr[0]; + } + + @Override + public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + + @Override + public int available() throws IOException { + try { + return inputStreamLike.available(); + } catch (Error | Exception e) { + return 0; + } + } + } + + private static final class GuestOutputStream extends OutputStream { + + private final OutputStreamLike outputStreamLike; + + private GuestOutputStream(OutputStreamLike os) { + this.outputStreamLike = os; + } + + @Override + public void write(int b) throws IOException { + byte[] arr = new byte[] {(byte) b}; + write(arr, 0, 1); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + outputStreamLike.write(b, off, len); + } + } } diff --git a/std-bits/base/src/main/java/org/enso/base/XML_Utils.java b/std-bits/base/src/main/java/org/enso/base/XML_Utils.java index 8e4ba23adba2..392f4565eac3 100644 --- a/std-bits/base/src/main/java/org/enso/base/XML_Utils.java +++ b/std-bits/base/src/main/java/org/enso/base/XML_Utils.java @@ -1,8 +1,14 @@ package org.enso.base; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.DOMConfiguration; +import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.bootstrap.DOMImplementationRegistry; @@ -10,6 +16,7 @@ import org.w3c.dom.ls.LSOutput; import org.w3c.dom.ls.LSSerializer; import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -62,7 +69,25 @@ public static String innerXML(Node element) return out.toString(); } - public static void setCustomErrorHandler(DocumentBuilder documentBuilder) { + public static Document parseStream(InputStream is) + throws ParserConfigurationException, SAXException, IOException { + return doParse(new InputSource(is)); + } + + public static Document parseString(String text) + throws ParserConfigurationException, SAXException, IOException { + return doParse(new InputSource(new StringReader(text))); + } + + private static Document doParse(InputSource is) + throws ParserConfigurationException, SAXException, IOException { + var factory = DocumentBuilderFactory.newInstance(); + var builder = factory.newDocumentBuilder(); + configureErrorHandler(builder); + return builder.parse(is); + } + + private static void configureErrorHandler(DocumentBuilder documentBuilder) { documentBuilder.setErrorHandler( new ErrorHandler() { @Override diff --git a/std-bits/base/src/main/java/org/enso/base/file_system/File_Utils.java b/std-bits/base/src/main/java/org/enso/base/file_system/File_Utils.java new file mode 100644 index 000000000000..2f48160518b3 --- /dev/null +++ b/std-bits/base/src/main/java/org/enso/base/file_system/File_Utils.java @@ -0,0 +1,23 @@ +package org.enso.base.file_system; + +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.PathMatcher; + +public final class File_Utils { + private File_Utils() {} + + public static Path toPath(String path) { + return Path.of(path); + } + + public static PathMatcher matchPath(String filter) { + var fs = FileSystems.getDefault(); + var matcher = fs.getPathMatcher(filter); + return matcher; + } + + public static boolean matches(PathMatcher matcher, String pathStr) { + return matcher.matches(Path.of(pathStr)); + } +} diff --git a/test/Base_Tests/src/Data/Map_Spec.enso b/test/Base_Tests/src/Data/Map_Spec.enso index ea0f3662d4b7..975b8f7f88af 100644 --- a/test/Base_Tests/src/Data/Map_Spec.enso +++ b/test/Base_Tests/src/Data/Map_Spec.enso @@ -5,8 +5,8 @@ import Standard.Base.Errors.No_Such_Key.No_Such_Key from Standard.Test import all -polyglot java import java.nio.file.Path as JavaPath polyglot java import java.util.Map as JavaMap +polyglot java import org.enso.base.file_system.File_Utils ## Type that violates reflexivity type My_Nan @@ -105,7 +105,7 @@ add_specs suite_builder = empty_map_fn = entry.get 1 pending = entry.get 2 add_common_specs suite_builder lang pending empty_map_fn - + suite_builder.group "Enso maps" group_builder-> @@ -278,11 +278,11 @@ add_specs suite_builder = map.get (js_str "A") . should_equal 42 group_builder.specify "should support host objects as keys" <| - # JavaPath has proper implementation of hashCode - map = Map.singleton (JavaPath.of "/home/user/file.txt") 42 + # java.nio.path.Path has proper implementation of hashCode + map = Map.singleton (File_Utils.toPath "/home/user/file.txt") 42 map.get "X" . should_equal Nothing map.get "A" . should_equal Nothing - map.get (JavaPath.of "/home/user/file.txt") . should_equal 42 + map.get (File_Utils.toPath "/home/user/file.txt") . should_equal 42 group_builder.specify "should support Python objects as keys" pending=pending_python_missing <| py_obj = py_wrapper 42 @@ -464,14 +464,14 @@ add_common_specs suite_builder prefix:Text (pending : (Text | Nothing)) (empty_m suite_builder.group prefix+": Common polyglot Map operations" pending=pending group_builder-> group_builder.specify "should get the default comparator for polyglot maps" <| Comparable.from empty_map . should_equal Default_Comparator - + group_builder.specify "should compare two hash maps" <| (empty_map.insert "a" 1).should_equal (empty_map.insert "a" 1) (empty_map.insert "b" 2).should_not_equal (empty_map.insert "a" 1) empty_map.should_equal empty_map empty_map.should_not_equal (empty_map.insert "a" 1) (empty_map.insert "a" 1 . insert "b" 2).should_equal (empty_map.insert "b" 2 . insert "a" 1) - + group_builder.specify "should allow checking for non emptiness" <| non_empty = empty_map . insert "foo" 1234 empty_map.not_empty . should_be_false @@ -481,7 +481,7 @@ add_common_specs suite_builder prefix:Text (pending : (Text | Nothing)) (empty_m non_empty = empty_map.insert "a" "b" . insert "x" "y" empty_map.size . should_equal 0 non_empty.size . should_equal 2 - + group_builder.specify "should allow checking for emptiness" <| non_empty = empty_map . insert "foo" 1234 empty_map.is_empty . should_be_true @@ -558,7 +558,11 @@ add_common_specs suite_builder prefix:Text (pending : (Text | Nothing)) (empty_m empty_map.insert Nothing 1 . insert Nothing 2 . get Nothing . should_equal 2 empty_map.insert Nothing 1 . should_equal (empty_map.insert Nothing 1) empty_map.insert Nothing 1 . insert Nothing 2 . at Nothing . should_equal 2 + + group_builder.specify "should handle JavaScript null as keys" <| empty_map.insert js_null 1 . at Nothing . should_equal 1 + + group_builder.specify "should handle Python None as keys" pending=pending_python_missing <| empty_map.insert py_none 1 . at Nothing . should_equal 1 group_builder.specify "should define a well-defined text conversion" <| diff --git a/test/Base_Tests/src/Main.enso b/test/Base_Tests/src/Main.enso index 8b5c42e25c27..80e6ef962052 100644 --- a/test/Base_Tests/src/Main.enso +++ b/test/Base_Tests/src/Main.enso @@ -85,6 +85,7 @@ import project.Runtime.Stack_Traces_Spec import project.System.Environment_Spec import project.System.File_Spec import project.System.File_Read_Spec +import project.System.Input_Stream_Spec import project.System.Process_Spec import project.System.Reporting_Stream_Decoder_Spec import project.System.Reporting_Stream_Encoder_Spec @@ -112,6 +113,7 @@ main filter=Nothing = File_Spec.add_specs suite_builder Temporary_File_Spec.add_specs suite_builder File_Read_Spec.add_specs suite_builder + Input_Stream_Spec.add_specs suite_builder Reporting_Stream_Decoder_Spec.add_specs suite_builder Reporting_Stream_Encoder_Spec.add_specs suite_builder Http_Header_Spec.add_specs suite_builder diff --git a/test/Base_Tests/src/Semantic/Equals_Spec.enso b/test/Base_Tests/src/Semantic/Equals_Spec.enso index fd68009445c7..6a85c61ea1ab 100644 --- a/test/Base_Tests/src/Semantic/Equals_Spec.enso +++ b/test/Base_Tests/src/Semantic/Equals_Spec.enso @@ -5,8 +5,8 @@ from Standard.Test import all polyglot java import java.math.BigInteger as Java_Big_Integer -polyglot java import java.nio.file.Path as Java_Path polyglot java import java.util.Random as Java_Random +polyglot java import org.enso.base.file_system.File_Utils polyglot java import org.enso.base_test_helpers.IntHolder polyglot java import org.enso.base_test_helpers.IntHolderEquals @@ -180,8 +180,8 @@ add_specs suite_builder = ((CustomEqType.C1 0) == (CustomEqType.C2 7 3)).should_be_false group_builder.specify "should dispatch to equals on host values" <| - path1 = Java_Path.of "home" "user" . resolve "file.txt" - path2 = Java_Path.of "home" "user" "file.txt" + path1 = File_Utils.toPath "home" . resolve "user" . resolve "file.txt" + path2 = File_Utils.toPath "home" . resolve "user" . resolve "file.txt" (path1 == path2).should_be_true path3 = path1.resolve "subfile.txt" (path3 == path2).should_be_false diff --git a/test/Base_Tests/src/System/Input_Stream_Spec.enso b/test/Base_Tests/src/System/Input_Stream_Spec.enso index 4d1423c1296f..8121dbf587e6 100644 --- a/test/Base_Tests/src/System/Input_Stream_Spec.enso +++ b/test/Base_Tests/src/System/Input_Stream_Spec.enso @@ -6,12 +6,33 @@ import Standard.Base.System.Input_Stream.Input_Stream from Standard.Test import all polyglot java import org.enso.base_test_helpers.RangeStream +polyglot java import org.enso.base.Stream_Utils main filter=Nothing = suite = Test.build suite_builder-> add_specs suite_builder suite.run_with_filter filter + +foreign js is_like data available = """ + let at = 0 + let is = { + read : function(arr, off, len) { + let cnt = 0; + while (len-- > 0) { + arr[off++] = data[at++]; + cnt++; + } + return cnt; + } + } + if (available) { + is.available = function() { + return data.length - at; + }; + } + return is; + add_specs suite_builder = suite_builder.group "Input Stream" group_builder-> group_builder.specify "should be peekable if backed by memory" <| Managed_Resource.bracket (Input_Stream.from_bytes [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) (.close) stream-> @@ -61,3 +82,33 @@ add_specs suite_builder = suite_builder.group "Input Stream" group_builder-> promoted_stream.peek_bytes 10 . should_equal [100, 101, 102, 103, 104] # The read still succeeds - ensuring there isn't some early EOF promoted_stream.read_n_bytes 10 . should_equal [100, 101, 102, 103, 104] + + group_builder.specify "read without available" <| + stream_like = is_like [20, 5, 1, 10] False + is = Stream_Utils.asInputStream stream_like + is.available . should_equal 0 + + is.read . should_equal 20 + is.read . should_equal 5 + + is.available . should_equal 0 + + is.read . should_equal 1 + is.read . should_equal 10 + + is.available . should_equal 0 + + group_builder.specify "read with available" <| + stream_like = is_like [20, 6, 8, 23] True + is = Stream_Utils.asInputStream stream_like + is.available . should_equal 4 + + is.read . should_equal 20 + is.read . should_equal 6 + + is.available . should_equal 2 + + is.read . should_equal 8 + is.read . should_equal 23 + + is.available . should_equal 0