From a4d62bd05208eda2562aeaf7fc2ac06941df09f9 Mon Sep 17 00:00:00 2001 From: Vsevolod Pukhov Date: Thu, 11 May 2023 17:49:06 +0300 Subject: [PATCH] Add std.interop.js package and built-in types Signed-off-by: Vsevolod Pukhov --- binder/ETSBinder.h | 1 + checker/types/globalTypesHolder.cpp | 3 +++ checker/types/globalTypesHolder.h | 2 ++ compiler/scripts/signatures.yaml | 8 ++++++++ parser/ETSparser.cpp | 2 +- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/binder/ETSBinder.h b/binder/ETSBinder.h index 7f89722bf..2646d99b3 100644 --- a/binder/ETSBinder.h +++ b/binder/ETSBinder.h @@ -140,6 +140,7 @@ import * from "std/core"; import * from "std/math"; import * from "std/containers"; import * from "std/time"; +import * from "std/interop/js"; )"; private: diff --git a/checker/types/globalTypesHolder.cpp b/checker/types/globalTypesHolder.cpp index 35e0dae23..680b7552a 100644 --- a/checker/types/globalTypesHolder.cpp +++ b/checker/types/globalTypesHolder.cpp @@ -133,6 +133,9 @@ GlobalTypesHolder::GlobalTypesHolder(ArenaAllocator *allocator) : builtin_name_m builtin_name_mappings_.emplace("Type", GlobalTypeId::ETS_TYPE_BUILTIN); builtin_name_mappings_.emplace("Types", GlobalTypeId::ETS_TYPES_BUILTIN); builtin_name_mappings_.emplace("Promise", GlobalTypeId::ETS_PROMISE_BUILTIN); + // ETS interop js specific types + builtin_name_mappings_.emplace("JSRuntime", GlobalTypeId::ETS_INTEROP_JSRUNTIME_BUILTIN); + builtin_name_mappings_.emplace("JSValue", GlobalTypeId::ETS_INTEROP_JSVALUE_BUILTIN); } Type *GlobalTypesHolder::GlobalNumberType() diff --git a/checker/types/globalTypesHolder.h b/checker/types/globalTypesHolder.h index ecd27f3cc..4eed6da90 100644 --- a/checker/types/globalTypesHolder.h +++ b/checker/types/globalTypesHolder.h @@ -92,6 +92,8 @@ enum class GlobalTypeId { ETS_TYPE_BUILTIN, ETS_TYPES_BUILTIN, ETS_PROMISE_BUILTIN, + ETS_INTEROP_JSRUNTIME_BUILTIN, + ETS_INTEROP_JSVALUE_BUILTIN, COUNT, }; diff --git a/compiler/scripts/signatures.yaml b/compiler/scripts/signatures.yaml index a7e12f1d7..d5f3b163d 100644 --- a/compiler/scripts/signatures.yaml +++ b/compiler/scripts/signatures.yaml @@ -94,6 +94,8 @@ packages: ref: PKG_STD_CORE - name: 'std.math' ref: PKG_STD_MATH + - name: 'std.interop.js' + ref: PKG_STD_INTEROP_JS primitives: - name: u1 @@ -221,6 +223,12 @@ builtins: - name: Promise package: PKG_STD_CORE ref: BUILTIN_PROMISE + - name: JSRuntime + package: PKG_STD_INTEROP_JS + ref: BUILTIN_JSRUNTIME + - name: JSValue + package: PKG_STD_INTEROP_JS + ref: BUILTIN_JSVALUE signatures: - callee: BUILTIN_OBJECT diff --git a/parser/ETSparser.cpp b/parser/ETSparser.cpp index e000cd6ea..584c5ed60 100644 --- a/parser/ETSparser.cpp +++ b/parser/ETSparser.cpp @@ -231,7 +231,7 @@ static bool IsCompitableExtension(const std::string &extension) std::vector ETSParser::CollectExternalSources() { std::vector paths; - std::vector stdlib = {"std/core", "std/math", "std/containers", "std/time"}; + std::vector stdlib = {"std/core", "std/math", "std/containers", "std/time", "std/interop/js"}; #ifdef USE_UNIX_SYSCALL for (auto const &path : stdlib) { -- Gitee