From feb978795f796bba10703b31f1bd2684205647ce Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 15 Jan 2024 15:21:56 +0300 Subject: [PATCH] Support instanceof for dynamic declarations Issue: #I8WD6G Testing: CI tests passed Signed-off-by: Vyacheslav Cherkashin --- ets2panda/checker/ets/arithmetic.cpp | 6 +- ets2panda/compiler/base/condition.cpp | 5 +- ets2panda/compiler/core/ETSCompiler.cpp | 7 +- ets2panda/compiler/core/ETSGen.cpp | 70 +- ets2panda/compiler/core/ETSGen.h | 11 + ets2panda/compiler/scripts/signatures.yaml | 12 +- ets2panda/compiler/templates/isa.h.erb | 12 +- ets2panda/ir/expressions/binaryExpression.cpp | 14 + ets2panda/ir/expressions/binaryExpression.h | 2 + .../instanceof_dyndecl_dynvalue-expected.txt | 1 + ...of.ets => instanceof_dyndecl_dynvalue.ets} | 20 +- .../instanceof_dyndecl_jsvalue-expected.txt | 1 + .../ets/instanceof_dyndecl_jsvalue.ets | 24 + .../instanceof_dynvalue_dynvalue-expected.txt | 1 + .../ets/instanceof_dynvalue_dynvalue.ets | 24 + .../instanceof_dynvalue_jsvalue-expected.txt | 1 + .../ets/instanceof_dynvalue_jsvalue.ets | 24 + ...instanceof_etsobject_dynvalue-expected.txt | 1 + .../ets/instanceof_etsobject_dynvalue.ets | 26 + .../instanceof_etsobject_jsvalue-expected.txt | 1 + .../ets/instanceof_etsobject_jsvalue.ets | 24 + .../instanceof_jsvalue_dynvalue-expected.txt | 1 + .../ets/instanceof_jsvalue_dynvalue.ets | 24 + .../instanceof_jsvalue_jsvalue-expected.txt | 1 + .../ets/instanceof_jsvalue_jsvalue.ets | 22 + .../instanceof_object_dynvalue-expected.txt | 1 + .../ets/instanceof_object_dynvalue.ets | 24 + .../instanceof_object_jsvalue-expected.txt | 1 + .../ets/instanceof_object_jsvalue.ets | 22 + .../ets/instanceof_object_long-expected.txt | 1 + .../compiler/ets/instanceof_object_long.ets | 22 + .../ets/instanceof_x_dyndecl-expected.txt | 2229 ++++++++++++++++ .../compiler/ets/instanceof_x_dyndecl.ets | 43 + .../ets/instanceof_x_etstype-expected.txt | 2323 +++++++++++++++++ .../compiler/ets/instanceof_x_etstype.ets | 44 + ...d.txt => instanceof_x_object-expected.txt} | 1970 +++++++------- .../test/compiler/ets/instanceof_x_object.ets | 43 + .../dynamic_decl_import-expected.txt | 4 +- .../dynamic_decl_import.ets | 4 +- .../modules/instanceof-expected.txt | 427 +++ .../modules/instanceof.ets | 24 + 41 files changed, 6594 insertions(+), 923 deletions(-) create mode 100644 ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt rename ets2panda/test/compiler/ets/{dynamic_instanceof.ets => instanceof_dyndecl_dynvalue.ets} (65%) create mode 100644 ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_object_dynvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_object_jsvalue.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_object_long-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_object_long.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_x_dyndecl.ets create mode 100644 ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt create mode 100644 ets2panda/test/compiler/ets/instanceof_x_etstype.ets rename ets2panda/test/compiler/ets/{dynamic_instanceof-expected.txt => instanceof_x_object-expected.txt} (58%) create mode 100644 ets2panda/test/compiler/ets/instanceof_x_object.ets create mode 100644 ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof-expected.txt create mode 100644 ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof.ets diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index ee308f3424..16371eaae5 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -496,10 +496,8 @@ std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::Sour ThrowTypeError("Bad operand type, the types of the operands must be same type.", pos); } - if (rightType->IsETSDynamicType() || leftType->IsETSDynamicType()) { - if (!(rightType->IsETSDynamicType() && leftType->IsETSDynamicType())) { - ThrowTypeError("Bad operand type, both types of the operands must be dynamic.", pos); - } + if (rightType->IsETSDynamicType() && !rightType->AsETSDynamicType()->HasDecl()) { + ThrowTypeError("Right-hand side of instanceof expression must represent a type.", pos); } tsType = GlobalETSBooleanType(); diff --git a/ets2panda/compiler/base/condition.cpp b/ets2panda/compiler/base/condition.cpp index 618de0ab7e..87a82b2d09 100644 --- a/ets2panda/compiler/base/condition.cpp +++ b/ets2panda/compiler/base/condition.cpp @@ -260,10 +260,7 @@ bool Condition::CompileBinaryExpr(ETSGen *etsg, const ir::BinaryExpression *binE RegScope rs(etsg); VReg lhs = etsg->AllocReg(); - binExpr->Left()->Compile(etsg); - etsg->ApplyConversionAndStoreAccumulator(binExpr->Left(), lhs, binExpr->OperationType()); - binExpr->Right()->Compile(etsg); - etsg->ApplyConversion(binExpr->Right(), binExpr->OperationType()); + binExpr->CompileOperands(etsg, lhs); etsg->Condition(binExpr, binExpr->OperatorType(), lhs, falseLabel); return true; } diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index e7c26b723e..fed84670eb 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -580,7 +580,7 @@ static void CompileInstanceof(compiler::ETSGen *etsg, const ir::BinaryExpression expr->Left()->Compile(etsg); etsg->ApplyConversionAndStoreAccumulator(expr->Left(), lhs, expr->OperationType()); - if (expr->Right()->TsType()->IsETSDynamicType()) { + if (expr->Left()->TsType()->IsETSDynamicType() || expr->Right()->TsType()->IsETSDynamicType()) { auto rhs = etsg->AllocReg(); expr->Right()->Compile(etsg); etsg->StoreAccumulator(expr, rhs); @@ -691,10 +691,7 @@ void ETSCompiler::Compile(const ir::BinaryExpression *expr) const return; } - expr->Left()->Compile(etsg); - etsg->ApplyConversionAndStoreAccumulator(expr->Left(), lhs, expr->OperationType()); - expr->Right()->Compile(etsg); - etsg->ApplyConversion(expr->Right(), expr->OperationType()); + expr->CompileOperands(etsg, lhs); if (expr->OperationType()->IsIntType()) { etsg->ApplyCast(expr->Right(), expr->OperationType()); } diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index 1d6a51b9ab..e2be1b7ff0 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -768,9 +768,73 @@ static bool IsAnyReferenceSupertype(checker::Type const *type) void ETSGen::IsInstanceDynamic(const ir::AstNode *const node, const VReg srcReg, [[maybe_unused]] const VReg tgtReg) { - ASSERT(Checker()->GetApparentType(GetVRegType(tgtReg))->IsETSDynamicType() && - GetVRegType(srcReg)->IsETSDynamicType()); - Ra().Emit(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF, srcReg, MoveAccToReg(node)); + ASSERT(node->IsBinaryExpression()); + ASSERT(node->AsBinaryExpression()->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF); + const checker::Type *lhsType = node->AsBinaryExpression()->Left()->TsType(); + const checker::Type *rhsType = node->AsBinaryExpression()->Right()->TsType(); + ASSERT(rhsType->IsETSDynamicType() || lhsType->IsETSDynamicType()); + + const RegScope rs(this); + if (rhsType->IsETSDynamicType()) { + ASSERT(node->AsBinaryExpression()->Right()->TsType()->AsETSDynamicType()->HasDecl()); + if (lhsType->IsETSDynamicType()) { + VReg dynTypeReg = MoveAccToReg(node); + // Semantics: + // let dyn_val: JSValue = ... + // dyn_value instanceof DynamicDecl + // Bytecode: + // call runtime intrinsic_dynamic + CallStatic2(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_DYNAMIC, srcReg, dynTypeReg); + } else if (lhsType == Checker()->GlobalETSObjectType()) { + // Semantics: + // let obj: Object = ... + // obj instanceof DynamicDecl + // Bytecode: + // if isinstance : + // checkcast + // return call runtime intrinsic_dynamic + // return false + Label *ifFalse = AllocLabel(); + Language lang = rhsType->AsETSDynamicType()->Language(); + VReg dynTypeReg = MoveAccToReg(node); + LoadAccumulator(node, srcReg); + Sa().Emit(node, Checker()->GlobalBuiltinDynamicType(lang)->AssemblerName()); + BranchIfFalse(node, ifFalse); + LoadAccumulator(node, srcReg); + Sa().Emit(node, Checker()->GlobalBuiltinDynamicType(lang)->AssemblerName()); + CallStatic2(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_DYNAMIC, srcReg, dynTypeReg); + SetLabel(node, ifFalse); + } else { + // Semantics: + // let obj: EtsType = ... + // obj instanceof DynamicDecl + // Bytecode: + // False + Sa().Emit(node, 0); + } + } else { + if (lhsType->IsETSDynamicType()) { + if (rhsType == Checker()->GlobalETSObjectType()) { + // Semantics: + // let dyn_val: JSValue = ... + // dyn_val instanceof Object + // Bytecode: + // True + Sa().Emit(node, 1); + } else { + // Semantics: + // let dyn_val: JSValue = ... + // dyn_val instanceof EtsType + // Bytecode: + // lda.type + call runtime instrinsic_static + Sa().Emit(node, rhsType->AsETSObjectType()->AssemblerName()); + VReg typeReg = MoveAccToReg(node); + CallStatic2(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_STATIC, srcReg, typeReg); + } + } else { + UNREACHABLE(); + } + } SetAccumulatorType(Checker()->GlobalETSBooleanType()); } diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 1daa3360f7..4f716ae05a 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -540,6 +540,16 @@ public: Ra().Emit(node, name, dummyReg_, dummyReg_); } + void CallStatic1(const ir::AstNode *const node, const util::StringView name, const VReg arg0) + { + Ra().Emit(node, name, arg0, dummyReg_); + } + + void CallStatic2(const ir::AstNode *const node, const util::StringView name, const VReg arg0, const VReg arg1) + { + Ra().Emit(node, name, arg0, arg1); + } + void CallThisStatic0(const ir::AstNode *const node, const VReg ctor, const util::StringView name) { Ra().Emit(node, name, ctor, dummyReg_); @@ -983,6 +993,7 @@ private: void CallImpl(const ir::AstNode *node, checker::Signature const *signature, const ArenaVector &arguments) { + ASSERT(signature != nullptr); RegScope rs(this); if (ResolveStringFromNullishBuiltin(node, signature, arguments)) { return; diff --git a/ets2panda/compiler/scripts/signatures.yaml b/ets2panda/compiler/scripts/signatures.yaml index 7e3cc445f8..0b1bd7bc19 100644 --- a/ets2panda/compiler/scripts/signatures.yaml +++ b/ets2panda/compiler/scripts/signatures.yaml @@ -1129,10 +1129,18 @@ signatures: ref: BUILTIN_JSRUNTIME_STRICT_EQUAL - callee: BUILTIN_JSRUNTIME - method_name: instanceOf + method_name: instanceOfDynamic params: [BUILTIN_JSVALUE, BUILTIN_JSVALUE] return_type: PRIMITIVE_BOOLEAN - ref: BUILTIN_JSRUNTIME_INSTANCE_OF + ref: BUILTIN_JSRUNTIME_INSTANCE_OF_DYNAMIC + + - callee: BUILTIN_JSRUNTIME + method_name: instanceOfStatic + # NOTE(v.cherkashin): + # Replace BUILTIN_OBJECT by BUILTIN_TYPE when issue #15273 was resolved + params: [BUILTIN_JSVALUE, BUILTIN_OBJECT] # 2nd argument is ClassClass + return_type: PRIMITIVE_BOOLEAN + ref: BUILTIN_JSRUNTIME_INSTANCE_OF_STATIC - callee: BUILTIN_BOX method_name: $CTOR diff --git a/ets2panda/compiler/templates/isa.h.erb b/ets2panda/compiler/templates/isa.h.erb index 588d7702cf..226519bcdf 100644 --- a/ets2panda/compiler/templates/isa.h.erb +++ b/ets2panda/compiler/templates/isa.h.erb @@ -126,9 +126,17 @@ private: class <%= class_name %> : public <%= base_class %> { public: - explicit <%= class_name %>(<%= ctor_args %>) : <%= base_class %>(node)<%= ops %> {} + explicit <%= class_name %>(<%= ctor_args %>) : <%= base_class %>(node)<%= ops %> + { +% insn.operands.each do |operand| +% if operand.id? && operand.name != :string_id + ASSERT(!string_id.Empty()); +% end +% end + } - Formats GetFormats() const override { + Formats GetFormats() const override + { return Span(<%= get_format_name(insn.mnemonic) %>); } diff --git a/ets2panda/ir/expressions/binaryExpression.cpp b/ets2panda/ir/expressions/binaryExpression.cpp index 212c099399..6bf4399ceb 100644 --- a/ets2panda/ir/expressions/binaryExpression.cpp +++ b/ets2panda/ir/expressions/binaryExpression.cpp @@ -65,6 +65,20 @@ void BinaryExpression::Compile(compiler::ETSGen *etsg) const etsg->GetAstCompiler()->Compile(this); } +void BinaryExpression::CompileOperands(compiler::ETSGen *etsg, compiler::VReg lhs) const +{ + left_->Compile(etsg); + + if (operator_ == lexer::TokenType::KEYW_INSTANCEOF) { + etsg->StoreAccumulator(left_, lhs); + } else { + etsg->ApplyConversionAndStoreAccumulator(left_, lhs, operationType_); + } + + right_->Compile(etsg); + etsg->ApplyConversion(right_, operationType_); +} + checker::Type *BinaryExpression::Check(checker::TSChecker *checker) { return checker->GetAnalyzer()->Check(this); diff --git a/ets2panda/ir/expressions/binaryExpression.h b/ets2panda/ir/expressions/binaryExpression.h index 5a16ef9e07..d6f9ea7c0e 100644 --- a/ets2panda/ir/expressions/binaryExpression.h +++ b/ets2panda/ir/expressions/binaryExpression.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_IR_EXPRESSION_BINARY_EXPRESSION_H #define ES2PANDA_IR_EXPRESSION_BINARY_EXPRESSION_H +#include "compiler/core/vReg.h" #include "ir/expression.h" #include "lexer/token/tokenType.h" @@ -157,6 +158,7 @@ public: void Dump(ir::SrcDumper *dumper) const override; void Compile(compiler::PandaGen *pg) const override; void Compile(compiler::ETSGen *etsg) const override; + void CompileOperands(compiler::ETSGen *etsg, compiler::VReg lhs) const; checker::Type *Check(checker::TSChecker *checker) override; checker::Type *Check(checker::ETSChecker *checker) override; diff --git a/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt new file mode 100644 index 0000000000..e781c4e753 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dyndecl_dynvalue.ets:24:12] diff --git a/ets2panda/test/compiler/ets/dynamic_instanceof.ets b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue.ets similarity index 65% rename from ets2panda/test/compiler/ets/dynamic_instanceof.ets rename to ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue.ets index 67dd69427a..c5f4f4c918 100644 --- a/ets2panda/test/compiler/ets/dynamic_instanceof.ets +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_dynvalue.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -17,19 +17,9 @@ flags: [dynamic-ast] ---*/ -import { A, B, jsfunc } from "dynamic_js_import_tests" +import { A } from "dynamic_js_import_tests" +import { ADeclared } from "dynamic_import_tests/modules/instanceof" -function foo(): int { - let a = new A(); - if (a instanceof A) { - return 1; - } else { - let x = jsfunc(); - let b = x instanceof B; - if (b) { - return 2; - } else { - return 3; - } - } +function fn(o: ADeclared): boolean { + return o instanceof A; } diff --git a/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt new file mode 100644 index 0000000000..b36abe05bb --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dyndecl_jsvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue.ets b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue.ets new file mode 100644 index 0000000000..2a81461d09 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dyndecl_jsvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { ADeclared } from "dynamic_import_tests/modules/instanceof" + +function fn_dyn_decl(o: ADeclared): boolean { + return o instanceof JSValue; +} diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt new file mode 100644 index 0000000000..01d89967b9 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dynvalue_dynvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue.ets b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue.ets new file mode 100644 index 0000000000..8ca37c3bec --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_dynvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { A, B } from "dynamic_js_import_tests" + +function fn(o: B): boolean { + return o instanceof A; +} diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt new file mode 100644 index 0000000000..e207a90d75 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_dynvalue_jsvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue.ets b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue.ets new file mode 100644 index 0000000000..f9278149ca --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_dynvalue_jsvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { A } from "dynamic_js_import_tests" + +function fn(o: A): boolean { + return o instanceof JSValue; +} diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt new file mode 100644 index 0000000000..995ed14f79 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_etsobject_dynvalue.ets:25:12] diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue.ets b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue.ets new file mode 100644 index 0000000000..9b7cfc0afb --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_dynvalue.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { A } from "dynamic_js_import_tests" + +class B {} + +function fn(o: B): boolean { + return o instanceof A; +} diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt new file mode 100644 index 0000000000..579f0aa567 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_etsobject_jsvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue.ets b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue.ets new file mode 100644 index 0000000000..d96765c6be --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_etsobject_jsvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +class A {} + +function fn(o: A): boolean { + return o instanceof JSValue; +} diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt new file mode 100644 index 0000000000..2487a7ed86 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_jsvalue_dynvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue.ets b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue.ets new file mode 100644 index 0000000000..7d534d8049 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_dynvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { A } from "dynamic_js_import_tests" + +function fn(o: JSValue): boolean { + return o instanceof A; +} diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt new file mode 100644 index 0000000000..04bfe221d1 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_jsvalue_jsvalue.ets:21:12] diff --git a/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue.ets b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue.ets new file mode 100644 index 0000000000..ab7ae309c6 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_jsvalue_jsvalue.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +function fn(o: JSValue): boolean { + return o instanceof JSValue; +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt new file mode 100644 index 0000000000..65b0bb51f3 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_dynvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_object_dynvalue.ets:23:12] diff --git a/ets2panda/test/compiler/ets/instanceof_object_dynvalue.ets b/ets2panda/test/compiler/ets/instanceof_object_dynvalue.ets new file mode 100644 index 0000000000..bddd3c6f00 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_dynvalue.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { A } from "dynamic_js_import_tests" + +function fn(o: Object): boolean { + return o instanceof A; +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt new file mode 100644 index 0000000000..bad900e767 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_jsvalue-expected.txt @@ -0,0 +1 @@ +TypeError: Right-hand side of instanceof expression must represent a type. [instanceof_object_jsvalue.ets:21:12] diff --git a/ets2panda/test/compiler/ets/instanceof_object_jsvalue.ets b/ets2panda/test/compiler/ets/instanceof_object_jsvalue.ets new file mode 100644 index 0000000000..0103287ad8 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_jsvalue.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +function fn(o: Object): boolean { + return o instanceof JSValue; +} diff --git a/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt b/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt new file mode 100644 index 0000000000..996afcec74 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_long-expected.txt @@ -0,0 +1 @@ +TypeError: Unresolved reference long [instanceof_object_long.ets:21:25] diff --git a/ets2panda/test/compiler/ets/instanceof_object_long.ets b/ets2panda/test/compiler/ets/instanceof_object_long.ets new file mode 100644 index 0000000000..4ebec908d6 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_object_long.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +function fn(o: Object): boolean { + return o instanceof long; +} diff --git a/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt new file mode 100644 index 0000000000..45cd828b0e --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_x_dyndecl-expected.txt @@ -0,0 +1,2229 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 24 + }, + "end": { + "line": 20, + "column": 49 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + "imported": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 49 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules", + "loc": { + "start": { + "line": 21, + "column": 38 + }, + "end": { + "line": 21, + "column": 79 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "imported": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 30 + } + } + }, + "imported": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 21 + }, + "end": { + "line": 21, + "column": 30 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 79 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_object", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 19 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_object", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 10 + }, + "end": { + "line": 25, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 30 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 30 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 25, + "column": 32 + }, + "end": { + "line": 25, + "column": 39 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 25 + }, + "end": { + "line": 26, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 12 + }, + "end": { + "line": 26, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 5 + }, + "end": { + "line": 26, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 25, + "column": 40 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 19 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 25, + "column": 19 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 25, + "column": 1 + }, + "end": { + "line": 27, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_ets_object", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 10 + }, + "end": { + "line": 29, + "column": 23 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_ets_object", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 10 + }, + "end": { + "line": 29, + "column": 23 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 29 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 24 + }, + "end": { + "line": 29, + "column": 29 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 29, + "column": 31 + }, + "end": { + "line": 29, + "column": 38 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 25 + }, + "end": { + "line": 30, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 5 + }, + "end": { + "line": 30, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 29, + "column": 39 + }, + "end": { + "line": 31, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 23 + }, + "end": { + "line": 31, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 23 + }, + "end": { + "line": 31, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 1 + }, + "end": { + "line": 31, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_jsvalue", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 10 + }, + "end": { + "line": 33, + "column": 20 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_jsvalue", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 10 + }, + "end": { + "line": 33, + "column": 20 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 24 + }, + "end": { + "line": 33, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 24 + }, + "end": { + "line": 33, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 24 + }, + "end": { + "line": 33, + "column": 32 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 21 + }, + "end": { + "line": 33, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 21 + }, + "end": { + "line": 33, + "column": 32 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 33, + "column": 34 + }, + "end": { + "line": 33, + "column": 41 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 12 + }, + "end": { + "line": 34, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 25 + }, + "end": { + "line": 34, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 12 + }, + "end": { + "line": 34, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 5 + }, + "end": { + "line": 34, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 33, + "column": 42 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 20 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 20 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 1 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_value", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 10 + }, + "end": { + "line": 37, + "column": 22 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_dyn_value", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 10 + }, + "end": { + "line": 37, + "column": 22 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 33 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 23 + }, + "end": { + "line": 37, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 23 + }, + "end": { + "line": 37, + "column": 33 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 37, + "column": 35 + }, + "end": { + "line": 37, + "column": 42 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 12 + }, + "end": { + "line": 38, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 25 + }, + "end": { + "line": 38, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 12 + }, + "end": { + "line": 38, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 5 + }, + "end": { + "line": 38, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 37, + "column": 43 + }, + "end": { + "line": 39, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 22 + }, + "end": { + "line": 39, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 22 + }, + "end": { + "line": 39, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 1 + }, + "end": { + "line": 39, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 10 + }, + "end": { + "line": 41, + "column": 21 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 10 + }, + "end": { + "line": 41, + "column": 21 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 25 + }, + "end": { + "line": 41, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 25 + }, + "end": { + "line": 41, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 25 + }, + "end": { + "line": 41, + "column": 35 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 22 + }, + "end": { + "line": 41, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 22 + }, + "end": { + "line": 41, + "column": 35 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 41, + "column": 37 + }, + "end": { + "line": 41, + "column": 44 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 12 + }, + "end": { + "line": 42, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 25 + }, + "end": { + "line": 42, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 12 + }, + "end": { + "line": 42, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 5 + }, + "end": { + "line": 42, + "column": 35 + } + } + } + ], + "loc": { + "start": { + "line": 41, + "column": 45 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 21 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 21 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 1 + }, + "end": { + "line": 43, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 11 + }, + "end": { + "line": 23, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 23, + "column": 11 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules/instanceof", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 44, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_x_dyndecl.ets b/ets2panda/test/compiler/ets/instanceof_x_dyndecl.ets new file mode 100644 index 0000000000..2c35b20e34 --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_x_dyndecl.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { AValue } from "dynamic_js_import_tests" +import { ADeclared, BDeclared } from "dynamic_import_tests/modules/instanceof" + +class A {} + +function fn_object(o: Object): boolean { + return o instanceof BDeclared; +} + +function fn_ets_object(o: A): boolean { + return o instanceof BDeclared; +} + +function fn_jsvalue(o: JSValue): boolean { + return o instanceof BDeclared; +} + +function fn_dyn_value(o: AValue): boolean { + return o instanceof BDeclared; +} + +function fn_dyn_decl(o: ADeclared): boolean { + return o instanceof BDeclared; +} diff --git a/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt new file mode 100644 index 0000000000..b1506f3e2c --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_x_etstype-expected.txt @@ -0,0 +1,2323 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 20, + "column": 24 + }, + "end": { + "line": 20, + "column": 49 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + "imported": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 16 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 49 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules", + "loc": { + "start": { + "line": 21, + "column": 27 + }, + "end": { + "line": 21, + "column": 68 + } + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "local": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "imported": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 10 + }, + "end": { + "line": 21, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 21, + "column": 1 + }, + "end": { + "line": 21, + "column": 68 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_object", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_object", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 10 + }, + "end": { + "line": 26, + "column": 19 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 23 + }, + "end": { + "line": 26, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 23 + }, + "end": { + "line": 26, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 23 + }, + "end": { + "line": 26, + "column": 30 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 20 + }, + "end": { + "line": 26, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 20 + }, + "end": { + "line": 26, + "column": 30 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 26, + "column": 32 + }, + "end": { + "line": 26, + "column": 39 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 12 + }, + "end": { + "line": 27, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 27, + "column": 25 + }, + "end": { + "line": 27, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 12 + }, + "end": { + "line": 27, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 5 + }, + "end": { + "line": 27, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 26, + "column": 40 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 19 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 26, + "column": 19 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 26, + "column": 1 + }, + "end": { + "line": 28, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_ets_object", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 10 + }, + "end": { + "line": 30, + "column": 23 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_ets_object", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 10 + }, + "end": { + "line": 30, + "column": 23 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 27 + }, + "end": { + "line": 30, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 27 + }, + "end": { + "line": 30, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 27 + }, + "end": { + "line": 30, + "column": 29 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 24 + }, + "end": { + "line": 30, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 24 + }, + "end": { + "line": 30, + "column": 29 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 30, + "column": 31 + }, + "end": { + "line": 30, + "column": 38 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 12 + }, + "end": { + "line": 31, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 31, + "column": 25 + }, + "end": { + "line": 31, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 12 + }, + "end": { + "line": 31, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 31, + "column": 5 + }, + "end": { + "line": 31, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 30, + "column": 39 + }, + "end": { + "line": 32, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 23 + }, + "end": { + "line": 32, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 23 + }, + "end": { + "line": 32, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 1 + }, + "end": { + "line": 32, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_jsvalue", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 10 + }, + "end": { + "line": 34, + "column": 20 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_jsvalue", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 10 + }, + "end": { + "line": 34, + "column": 20 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "JSValue", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 24 + }, + "end": { + "line": 34, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 24 + }, + "end": { + "line": 34, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 24 + }, + "end": { + "line": 34, + "column": 32 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 21 + }, + "end": { + "line": 34, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 21 + }, + "end": { + "line": 34, + "column": 32 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 34, + "column": 34 + }, + "end": { + "line": 34, + "column": 41 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 12 + }, + "end": { + "line": 35, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 35, + "column": 25 + }, + "end": { + "line": 35, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 12 + }, + "end": { + "line": 35, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 35, + "column": 5 + }, + "end": { + "line": 35, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 34, + "column": 42 + }, + "end": { + "line": 36, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 20 + }, + "end": { + "line": 36, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 20 + }, + "end": { + "line": 36, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 1 + }, + "end": { + "line": 36, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_value", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 10 + }, + "end": { + "line": 38, + "column": 22 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_dyn_value", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 10 + }, + "end": { + "line": 38, + "column": 22 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 26 + }, + "end": { + "line": 38, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 26 + }, + "end": { + "line": 38, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 26 + }, + "end": { + "line": 38, + "column": 33 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 23 + }, + "end": { + "line": 38, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 23 + }, + "end": { + "line": 38, + "column": 33 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 38, + "column": 35 + }, + "end": { + "line": 38, + "column": 42 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 12 + }, + "end": { + "line": 39, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 39, + "column": 25 + }, + "end": { + "line": 39, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 39, + "column": 12 + }, + "end": { + "line": 39, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 39, + "column": 5 + }, + "end": { + "line": 39, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 38, + "column": 43 + }, + "end": { + "line": 40, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 22 + }, + "end": { + "line": 40, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 22 + }, + "end": { + "line": 40, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 1 + }, + "end": { + "line": 40, + "column": 2 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 10 + }, + "end": { + "line": 42, + "column": 21 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 10 + }, + "end": { + "line": 42, + "column": 21 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 25 + }, + "end": { + "line": 42, + "column": 34 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 25 + }, + "end": { + "line": 42, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 25 + }, + "end": { + "line": 42, + "column": 35 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 22 + }, + "end": { + "line": 42, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 22 + }, + "end": { + "line": 42, + "column": 35 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 42, + "column": 37 + }, + "end": { + "line": 42, + "column": 44 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 43, + "column": 12 + }, + "end": { + "line": 43, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 43, + "column": 25 + }, + "end": { + "line": 43, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 43, + "column": 12 + }, + "end": { + "line": 43, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 43, + "column": 5 + }, + "end": { + "line": 43, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 42, + "column": 45 + }, + "end": { + "line": 44, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 21 + }, + "end": { + "line": 44, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 42, + "column": 21 + }, + "end": { + "line": 44, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 1 + }, + "end": { + "line": 44, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 11 + }, + "end": { + "line": 23, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 9 + }, + "end": { + "line": 23, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 23, + "column": 11 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "B", + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 7 + }, + "end": { + "line": 24, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 24, + "column": 11 + } + } + } + ], + "loc": { + "start": { + "line": 24, + "column": 9 + }, + "end": { + "line": 24, + "column": 11 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 1 + }, + "end": { + "line": 24, + "column": 11 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassStaticBlock", + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": true, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_js_import_tests0", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_js_import_tests", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules/instanceof", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "init", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 45, + "column": 1 + } + } +} diff --git a/ets2panda/test/compiler/ets/instanceof_x_etstype.ets b/ets2panda/test/compiler/ets/instanceof_x_etstype.ets new file mode 100644 index 0000000000..5d723962bb --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_x_etstype.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { AValue } from "dynamic_js_import_tests" +import { ADeclared } from "dynamic_import_tests/modules/instanceof" + +class A {} +class B {} + +function fn_object(o: Object): boolean { + return o instanceof B; +} + +function fn_ets_object(o: A): boolean { + return o instanceof B; +} + +function fn_jsvalue(o: JSValue): boolean { + return o instanceof B; +} + +function fn_dyn_value(o: AValue): boolean { + return o instanceof B; +} + +function fn_dyn_decl(o: ADeclared): boolean { + return o instanceof B; +} diff --git a/ets2panda/test/compiler/ets/dynamic_instanceof-expected.txt b/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt similarity index 58% rename from ets2panda/test/compiler/ets/dynamic_instanceof-expected.txt rename to ets2panda/test/compiler/ets/instanceof_x_object-expected.txt index dd0097eb28..ad76de5d7e 100644 --- a/ets2panda/test/compiler/ets/dynamic_instanceof-expected.txt +++ b/ets2panda/test/compiler/ets/instanceof_x_object-expected.txt @@ -9,11 +9,11 @@ "loc": { "start": { "line": 20, - "column": 30 + "column": 24 }, "end": { "line": 20, - "column": 55 + "column": 49 } } }, @@ -22,7 +22,7 @@ "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "A", + "name": "AValue", "decorators": [], "loc": { "start": { @@ -31,13 +31,13 @@ }, "end": { "line": 20, - "column": 11 + "column": 16 } } }, "imported": { "type": "Identifier", - "name": "A", + "name": "AValue", "decorators": [], "loc": { "start": { @@ -46,7 +46,7 @@ }, "end": { "line": 20, - "column": 11 + "column": 16 } } }, @@ -57,105 +57,91 @@ }, "end": { "line": 20, - "column": 11 + "column": 16 } } + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 }, - { - "type": "ImportSpecifier", - "local": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 13 - }, - "end": { - "line": 20, - "column": 14 - } - } - }, - "imported": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 20, - "column": 13 - }, - "end": { - "line": 20, - "column": 14 - } - } + "end": { + "line": 20, + "column": 49 + } + } + }, + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules", + "loc": { + "start": { + "line": 21, + "column": 27 }, - "loc": { - "start": { - "line": 20, - "column": 13 - }, - "end": { - "line": 20, - "column": 14 - } + "end": { + "line": 21, + "column": 68 } - }, + } + }, + "specifiers": [ { "type": "ImportSpecifier", "local": { "type": "Identifier", - "name": "jsfunc", + "name": "ADeclared", "decorators": [], "loc": { "start": { - "line": 20, - "column": 16 + "line": 21, + "column": 10 }, "end": { - "line": 20, - "column": 22 + "line": 21, + "column": 19 } } }, "imported": { "type": "Identifier", - "name": "jsfunc", + "name": "ADeclared", "decorators": [], "loc": { "start": { - "line": 20, - "column": 16 + "line": 21, + "column": 10 }, "end": { - "line": 20, - "column": 22 + "line": 21, + "column": 19 } } }, "loc": { "start": { - "line": 20, - "column": 16 + "line": 21, + "column": 10 }, "end": { - "line": 20, - "column": 22 + "line": 21, + "column": 19 } } } ], "loc": { "start": { - "line": 20, + "line": 21, "column": 1 }, "end": { - "line": 20, - "column": 55 + "line": 21, + "column": 68 } } }, @@ -278,16 +264,16 @@ "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "foo", + "name": "fn_object", "decorators": [], "loc": { "start": { - "line": 22, + "line": 25, "column": 10 }, "end": { - "line": 22, - "column": 13 + "line": 25, + "column": 19 } } }, @@ -302,556 +288,196 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "foo", + "name": "fn_object", "decorators": [], "loc": { "start": { - "line": 22, + "line": 25, "column": 10 }, "end": { - "line": 22, - "column": 13 + "line": 25, + "column": 19 } } }, "generator": false, "async": false, "expression": false, - "params": [], - "returnType": { - "type": "ETSPrimitiveType", - "loc": { - "start": { - "line": 22, - "column": 17 - }, - "end": { - "line": 22, - "column": 20 - } - } - }, - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "a", + "name": "Object", "decorators": [], "loc": { "start": { - "line": 23, - "column": 7 - }, - "end": { - "line": 23, - "column": 8 - } - } - }, - "init": { - "type": "ETSNewClassInstanceExpression", - "typeReference": { - "type": "ETSTypeReference", - "part": { - "type": "ETSTypeReferencePart", - "name": { - "type": "Identifier", - "name": "A", - "decorators": [], - "loc": { - "start": { - "line": 23, - "column": 15 - }, - "end": { - "line": 23, - "column": 16 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 15 - }, - "end": { - "line": 23, - "column": 17 - } - } - }, - "loc": { - "start": { - "line": 23, - "column": 15 - }, - "end": { - "line": 23, - "column": 17 - } - } - }, - "arguments": [], - "loc": { - "start": { - "line": 23, - "column": 11 + "line": 25, + "column": 23 }, "end": { - "line": 23, - "column": 19 + "line": 25, + "column": 29 } } }, "loc": { "start": { - "line": 23, - "column": 7 + "line": 25, + "column": 23 }, "end": { - "line": 23, - "column": 19 + "line": 25, + "column": 30 } } + }, + "loc": { + "start": { + "line": 25, + "column": 23 + }, + "end": { + "line": 25, + "column": 30 + } } - ], - "kind": "let", + }, + "decorators": [], "loc": { "start": { - "line": 23, - "column": 3 + "line": 25, + "column": 20 }, "end": { - "line": 23, - "column": 19 + "line": 25, + "column": 30 } } }, + "loc": { + "start": { + "line": 25, + "column": 20 + }, + "end": { + "line": 25, + "column": 30 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 25, + "column": 32 + }, + "end": { + "line": 25, + "column": 39 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ { - "type": "IfStatement", - "test": { + "type": "ReturnStatement", + "argument": { "type": "BinaryExpression", "operator": "instanceof", "left": { "type": "Identifier", - "name": "a", + "name": "o", "decorators": [], "loc": { "start": { - "line": 24, - "column": 7 + "line": 26, + "column": 12 }, "end": { - "line": 24, - "column": 8 + "line": 26, + "column": 13 } } }, "right": { "type": "Identifier", - "name": "A", + "name": "Object", "decorators": [], "loc": { "start": { - "line": 24, - "column": 20 + "line": 26, + "column": 25 }, "end": { - "line": 24, - "column": 21 + "line": 26, + "column": 31 } } }, - "loc": { - "start": { - "line": 24, - "column": 7 - }, - "end": { - "line": 24, - "column": 21 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 1, - "loc": { - "start": { - "line": 25, - "column": 12 - }, - "end": { - "line": 25, - "column": 13 - } - } - }, - "loc": { - "start": { - "line": 25, - "column": 5 - }, - "end": { - "line": 25, - "column": 14 - } - } - } - ], - "loc": { - "start": { - "line": 24, - "column": 23 - }, - "end": { - "line": 26, - "column": 4 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "x", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 10 - } - } - }, - "init": { - "type": "CallExpression", - "callee": { - "type": "Identifier", - "name": "jsfunc", - "decorators": [], - "loc": { - "start": { - "line": 27, - "column": 13 - }, - "end": { - "line": 27, - "column": 19 - } - } - }, - "arguments": [], - "optional": false, - "loc": { - "start": { - "line": 27, - "column": 13 - }, - "end": { - "line": 27, - "column": 21 - } - } - }, - "loc": { - "start": { - "line": 27, - "column": 9 - }, - "end": { - "line": 27, - "column": 21 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 27, - "column": 5 - }, - "end": { - "line": 27, - "column": 22 - } - } - }, - { - "type": "VariableDeclaration", - "declarations": [ - { - "type": "VariableDeclarator", - "id": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 10 - } - } - }, - "init": { - "type": "BinaryExpression", - "operator": "instanceof", - "left": { - "type": "Identifier", - "name": "x", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 13 - }, - "end": { - "line": 28, - "column": 14 - } - } - }, - "right": { - "type": "Identifier", - "name": "B", - "decorators": [], - "loc": { - "start": { - "line": 28, - "column": 26 - }, - "end": { - "line": 28, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 13 - }, - "end": { - "line": 28, - "column": 27 - } - } - }, - "loc": { - "start": { - "line": 28, - "column": 9 - }, - "end": { - "line": 28, - "column": 27 - } - } - } - ], - "kind": "let", - "loc": { - "start": { - "line": 28, - "column": 5 - }, - "end": { - "line": 28, - "column": 28 - } - } - }, - { - "type": "IfStatement", - "test": { - "type": "Identifier", - "name": "b", - "decorators": [], - "loc": { - "start": { - "line": 29, - "column": 9 - }, - "end": { - "line": 29, - "column": 10 - } - } - }, - "consequent": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 2, - "loc": { - "start": { - "line": 30, - "column": 14 - }, - "end": { - "line": 30, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 30, - "column": 7 - }, - "end": { - "line": 30, - "column": 16 - } - } - } - ], - "loc": { - "start": { - "line": 29, - "column": 12 - }, - "end": { - "line": 31, - "column": 6 - } - } - }, - "alternate": { - "type": "BlockStatement", - "statements": [ - { - "type": "ReturnStatement", - "argument": { - "type": "NumberLiteral", - "value": 3, - "loc": { - "start": { - "line": 32, - "column": 14 - }, - "end": { - "line": 32, - "column": 15 - } - } - }, - "loc": { - "start": { - "line": 32, - "column": 7 - }, - "end": { - "line": 32, - "column": 16 - } - } - } - ], - "loc": { - "start": { - "line": 31, - "column": 12 - }, - "end": { - "line": 33, - "column": 6 - } - } - }, - "loc": { - "start": { - "line": 29, - "column": 5 - }, - "end": { - "line": 33, - "column": 6 - } - } - } - ], "loc": { "start": { "line": 26, - "column": 10 + "column": 12 }, "end": { - "line": 34, - "column": 4 + "line": 26, + "column": 31 } } }, "loc": { "start": { - "line": 24, - "column": 3 + "line": 26, + "column": 5 }, "end": { - "line": 34, - "column": 4 + "line": 26, + "column": 32 } } } ], "loc": { "start": { - "line": 22, - "column": 21 + "line": 25, + "column": 40 }, "end": { - "line": 35, + "line": 27, "column": 2 } } }, "loc": { "start": { - "line": 22, - "column": 13 + "line": 25, + "column": 19 }, "end": { - "line": 35, + "line": 27, "column": 2 } } }, "loc": { "start": { - "line": 22, - "column": 13 + "line": 25, + "column": 19 }, "end": { - "line": 35, + "line": 27, "column": 2 } } @@ -860,73 +486,29 @@ "decorators": [], "loc": { "start": { - "line": 22, + "line": 25, "column": 1 }, "end": { - "line": 35, + "line": 27, "column": 2 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "$jsnew", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "invoke", + "name": "fn_ets_object", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 29, + "column": 23 } } }, @@ -941,16 +523,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "invoke", + "name": "fn_ets_object", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 29, + "column": 23 } } }, @@ -962,78 +544,176 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "obj", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 28 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 29, + "column": 27 + }, + "end": { + "line": 29, + "column": 29 + } + } + }, "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 29, + "column": 29 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 29, + "column": 29 } } - }, - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "qname", - "decorators": [], + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 29, + "column": 31 + }, + "end": { + "line": 29, + "column": 38 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 30, + "column": 25 + }, + "end": { + "line": 30, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 30, + "column": 12 + }, + "end": { + "line": 30, + "column": 31 + } + } + }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 30, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 30, + "column": 32 } } + } + ], + "loc": { + "start": { + "line": 29, + "column": 39 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 31, + "column": 2 } } - ], + }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 23 }, "end": { - "line": 1, - "column": 1 + "line": 31, + "column": 2 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 29, + "column": 23 }, "end": { - "line": 1, - "column": 1 + "line": 31, + "column": 2 } } }, @@ -1041,234 +721,264 @@ "decorators": [], "loc": { "start": { - "line": 1, + "line": 29, "column": 1 }, "end": { - "line": 1, - "column": 1 + "line": 31, + "column": 2 } } }, { - "type": "ClassStaticBlock", + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_jsvalue", + "decorators": [], + "loc": { + "start": { + "line": 33, + "column": 10 + }, + "end": { + "line": 33, + "column": 20 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { "type": "FunctionExpression", "function": { "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "", + "name": "fn_jsvalue", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 20 } } }, "generator": false, "async": false, - "expression": true, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { - "type": "Identifier", - "name": "JSRuntime", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "property": { + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "__initJSNewClass", + "name": "JSValue", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 31 } } }, - "computed": false, - "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 32 } } }, - "arguments": [ - { - "type": "StringLiteral", - "value": "L$jsnew;", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - } - ], - "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 32 } } }, + "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 21 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 32 } } + }, + "loc": { + "start": { + "line": 33, + "column": 21 + }, + "end": { + "line": 33, + "column": 32 + } } - ], + } + ], + "returnType": { + "type": "ETSPrimitiveType", "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 34 }, "end": { - "line": 1, - "column": 1 + "line": 33, + "column": 41 } } }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 12 + }, + "end": { + "line": 34, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 34, + "column": 25 + }, + "end": { + "line": 34, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 12 + }, + "end": { + "line": 34, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 34, + "column": 5 + }, + "end": { + "line": 34, + "column": 32 + } + } + } + ], + "loc": { + "start": { + "line": 33, + "column": 42 + }, + "end": { + "line": 35, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 33, + "column": 20 + }, + "end": { + "line": 35, + "column": 2 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 33, + "column": 20 }, "end": { - "line": 1, - "column": 1 + "line": 35, + "column": 2 } } }, + "overloads": [], + "decorators": [], "loc": { "start": { - "line": 1, + "line": 33, "column": 1 }, "end": { - "line": 1, - "column": 1 + "line": 35, + "column": 2 } } - } - ], - "loc": { - "start": { - "line": 1, - "column": 1 }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - { - "type": "ClassDeclaration", - "definition": { - "id": { - "type": "Identifier", - "name": "$jscall", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } - } - }, - "superClass": null, - "implements": [], - "body": [ { "type": "MethodDefinition", "key": { "type": "Identifier", - "name": "invoke", + "name": "fn_dyn_value", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 37, + "column": 22 } } }, @@ -1283,16 +993,16 @@ "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "invoke", + "name": "fn_dyn_value", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 37, + "column": 22 } } }, @@ -1304,78 +1014,176 @@ "type": "ETSParameterExpression", "name": { "type": "Identifier", - "name": "obj", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { + "type": "Identifier", + "name": "AValue", + "decorators": [], + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 32 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 33 + } + } + }, + "loc": { + "start": { + "line": 37, + "column": 26 + }, + "end": { + "line": 37, + "column": 33 + } + } + }, "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 23 }, "end": { - "line": 1, - "column": 1 + "line": 37, + "column": 33 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 23 }, "end": { - "line": 1, - "column": 1 + "line": 37, + "column": 33 } } - }, - { - "type": "ETSParameterExpression", - "name": { - "type": "Identifier", - "name": "qname", - "decorators": [], + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 37, + "column": 35 + }, + "end": { + "line": 37, + "column": 42 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 12 + }, + "end": { + "line": 38, + "column": 13 + } + } + }, + "right": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 38, + "column": 25 + }, + "end": { + "line": 38, + "column": 31 + } + } + }, + "loc": { + "start": { + "line": 38, + "column": 12 + }, + "end": { + "line": 38, + "column": 31 + } + } + }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 38, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 38, + "column": 32 } } + } + ], + "loc": { + "start": { + "line": 37, + "column": 43 }, - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "end": { + "line": 39, + "column": 2 } } - ], + }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 22 }, "end": { - "line": 1, - "column": 1 + "line": 39, + "column": 2 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 37, + "column": 22 }, "end": { - "line": 1, - "column": 1 + "line": 39, + "column": 2 } } }, @@ -1383,132 +1191,341 @@ "decorators": [], "loc": { "start": { - "line": 1, + "line": 37, "column": 1 }, "end": { - "line": 1, - "column": 1 + "line": 39, + "column": 2 } } }, { - "type": "ClassStaticBlock", + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "fn_dyn_decl", + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 10 + }, + "end": { + "line": 41, + "column": 21 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, "value": { "type": "FunctionExpression", "function": { "type": "ScriptFunction", "id": { "type": "Identifier", - "name": "", + "name": "fn_dyn_decl", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 41, + "column": 10 }, "end": { - "line": 1, - "column": 1 + "line": 41, + "column": 21 } } }, "generator": false, "async": false, - "expression": true, - "params": [], - "body": { - "type": "BlockStatement", - "statements": [ - { - "type": "ExpressionStatement", - "expression": { - "type": "CallExpression", - "callee": { - "type": "MemberExpression", - "object": { + "expression": false, + "params": [ + { + "type": "ETSParameterExpression", + "name": { + "type": "Identifier", + "name": "o", + "typeAnnotation": { + "type": "ETSTypeReference", + "part": { + "type": "ETSTypeReferencePart", + "name": { "type": "Identifier", - "name": "JSRuntime", + "name": "ADeclared", "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 41, + "column": 25 }, "end": { - "line": 1, - "column": 1 + "line": 41, + "column": 34 } } }, - "property": { - "type": "Identifier", - "name": "__initJSCallClass", - "decorators": [], - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "loc": { + "start": { + "line": 41, + "column": 25 + }, + "end": { + "line": 41, + "column": 35 } + } + }, + "loc": { + "start": { + "line": 41, + "column": 25 }, - "computed": false, - "optional": false, + "end": { + "line": 41, + "column": 35 + } + } + }, + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 22 + }, + "end": { + "line": 41, + "column": 35 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 22 + }, + "end": { + "line": 41, + "column": 35 + } + } + } + ], + "returnType": { + "type": "ETSPrimitiveType", + "loc": { + "start": { + "line": 41, + "column": 37 + }, + "end": { + "line": 41, + "column": 44 + } + } + }, + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ReturnStatement", + "argument": { + "type": "BinaryExpression", + "operator": "instanceof", + "left": { + "type": "Identifier", + "name": "o", + "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 42, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 42, + "column": 13 } } }, - "arguments": [ - { - "type": "StringLiteral", - "value": "L$jscall;", - "loc": { - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 1, - "column": 1 - } + "right": { + "type": "Identifier", + "name": "Object", + "decorators": [], + "loc": { + "start": { + "line": 42, + "column": 25 + }, + "end": { + "line": 42, + "column": 31 } } - ], - "optional": false, + }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 42, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 42, + "column": 31 } } }, "loc": { "start": { - "line": 1, - "column": 1 + "line": 42, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 42, + "column": 32 } } } - ], + ], + "loc": { + "start": { + "line": 41, + "column": 45 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 21 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 41, + "column": 21 + }, + "end": { + "line": 43, + "column": 2 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 41, + "column": 1 + }, + "end": { + "line": 43, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "A", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 7 + }, + "end": { + "line": 23, + "column": 8 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], "loc": { "start": { "line": 1, @@ -1542,37 +1559,39 @@ } } }, + "overloads": [], + "decorators": [], "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 11 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 11 } } } ], "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 9 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 11 } } }, "loc": { "start": { - "line": 1, + "line": 23, "column": 1 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 11 } } }, @@ -1633,6 +1652,42 @@ } } }, + { + "type": "ClassProperty", + "key": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "accessibility": "public", + "static": true, + "readonly": false, + "declare": false, + "optional": false, + "computed": false, + "definite": false, + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, { "type": "ClassStaticBlock", "value": { @@ -1807,6 +1862,153 @@ "column": 1 } } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "AssignmentExpression", + "operator": "=", + "left": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "$dynmodule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "dynamic_import_tests_modules1", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "right": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "JSRuntime", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "property": { + "type": "Identifier", + "name": "loadModule", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "dynamic_import_tests/modules/instanceof", + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } } ], "loc": { @@ -1977,7 +2179,7 @@ "column": 1 }, "end": { - "line": 36, + "line": 44, "column": 1 } } diff --git a/ets2panda/test/compiler/ets/instanceof_x_object.ets b/ets2panda/test/compiler/ets/instanceof_x_object.ets new file mode 100644 index 0000000000..93dde6e64f --- /dev/null +++ b/ets2panda/test/compiler/ets/instanceof_x_object.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +import { AValue } from "dynamic_js_import_tests" +import { ADeclared } from "dynamic_import_tests/modules/instanceof" + +class A {} + +function fn_object(o: Object): boolean { + return o instanceof Object; +} + +function fn_ets_object(o: A): boolean { + return o instanceof Object; +} + +function fn_jsvalue(o: JSValue): boolean { + return o instanceof Object; +} + +function fn_dyn_value(o: AValue): boolean { + return o instanceof Object; +} + +function fn_dyn_decl(o: ADeclared): boolean { + return o instanceof Object; +} diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import-expected.txt b/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import-expected.txt index 6d969d63fb..05161503b2 100644 --- a/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import-expected.txt +++ b/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import-expected.txt @@ -3185,8 +3185,8 @@ "column": 1 }, "end": { - "line": 40, - "column": 2 + "line": 41, + "column": 1 } } } diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import.ets b/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import.ets index 9a0d3a8396..589c492ad7 100644 --- a/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import.ets +++ b/ets2panda/test/parser/ets/dynamic_import_tests/dynamic_decl_import.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -37,4 +37,4 @@ function main(): void { A.f2 = f2 foo(obj) -} \ No newline at end of file +} diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof-expected.txt b/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof-expected.txt new file mode 100644 index 0000000000..327b214546 --- /dev/null +++ b/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof-expected.txt @@ -0,0 +1,427 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "method", + "accessibility": "public", + "static": true, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "_$init$_", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ADeclared", + "decorators": [], + "loc": { + "start": { + "line": 20, + "column": 22 + }, + "end": { + "line": 20, + "column": 31 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 21, + "column": 2 + }, + "end": { + "line": 21, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 32 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 16 + }, + "end": { + "line": 21, + "column": 2 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "BDeclared", + "decorators": [], + "loc": { + "start": { + "line": 23, + "column": 22 + }, + "end": { + "line": 23, + "column": 31 + } + } + }, + "superClass": null, + "implements": [], + "body": [ + { + "type": "MethodDefinition", + "key": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "kind": "constructor", + "static": false, + "optional": false, + "computed": false, + "value": { + "type": "FunctionExpression", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "constructor", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "overloads": [], + "decorators": [], + "loc": { + "start": { + "line": 24, + "column": 2 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 32 + }, + "end": { + "line": 24, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 24, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 25, + "column": 1 + } + } +} diff --git a/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof.ets b/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof.ets new file mode 100644 index 0000000000..73f81409b2 --- /dev/null +++ b/ets2panda/test/parser/ets/dynamic_import_tests/modules/instanceof.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +flags: [dynamic-ast] +---*/ + +export declare class ADeclared { +} + +export declare class BDeclared { +} -- Gitee