diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index fcee9f460c42a61cb2f1b45cac30585e8f09cb62..095cbde9554cfcfb34f910216e01d80300e7d043 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -149,7 +149,6 @@ static constexpr std::string_view BUILTINS_TO_INIT[] = { compiler::Signatures::BUILTIN_OBJECT_CLASS, compiler::Signatures::BUILTIN_STRING_CLASS, compiler::Signatures::BUILTIN_BIGINT_CLASS, - compiler::Signatures::BUILTIN_EXCEPTION_CLASS, compiler::Signatures::BUILTIN_ERROR_CLASS, compiler::Signatures::BUILTIN_TYPE_CLASS, compiler::Signatures::BUILTIN_PROMISE_CLASS, @@ -617,11 +616,6 @@ ETSObjectType *ETSChecker::GlobalBuiltinTypeType() const return AsETSObjectType(&GlobalTypesHolder::GlobalTypeBuiltinType); } -ETSObjectType *ETSChecker::GlobalBuiltinExceptionType() const -{ - return AsETSObjectType(&GlobalTypesHolder::GlobalExceptionBuiltinType); -} - ETSObjectType *ETSChecker::GlobalBuiltinErrorType() const { return AsETSObjectType(&GlobalTypesHolder::GlobalErrorBuiltinType); diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 81fed860b6cb35c565669e0d6cccd15630130206..8ffefc53068d34bcb35f8ffd198961ba924e6139 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -144,7 +144,6 @@ public: ETSObjectType *GlobalBuiltinETSStringType() const; ETSObjectType *GlobalBuiltinETSBigIntType() const; ETSObjectType *GlobalBuiltinTypeType() const; - ETSObjectType *GlobalBuiltinExceptionType() const; ETSObjectType *GlobalBuiltinErrorType() const; ETSObjectType *GlobalStringBuilderBuiltinType() const; ETSObjectType *GlobalBuiltinPromiseType() const; diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index a9e62345acc15565b5e1a0a22c66b43345befd32..52712e22300d1adb8a442860b6e78f5a81d52267 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -1919,8 +1919,7 @@ void ETSChecker::CheckCyclicConstructorCall(Signature *signature) ETSObjectType *ETSChecker::CheckExceptionOrErrorType(checker::Type *type, const lexer::SourcePosition pos) { ES2PANDA_ASSERT(type != nullptr); - if (!type->IsETSObjectType() || (!Relation()->IsAssignableTo(type, GlobalBuiltinExceptionType()) && - !Relation()->IsAssignableTo(type, GlobalBuiltinErrorType()))) { + if (!type->IsETSObjectType() || !Relation()->IsAssignableTo(type, GlobalBuiltinErrorType())) { LogError(diagnostic::CATCH_OR_THROW_OF_INVALID_TYPE, {compiler::Signatures::BUILTIN_EXCEPTION_CLASS, compiler::Signatures::BUILTIN_ERROR_CLASS}, pos); return GlobalETSObjectType(); diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index a57b3008e1008d8123e14fbf635cf7f3a7f09885..8c4f4ceb4db1c091f1d5b0f10ff0b60abe2a22f7 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -146,14 +146,14 @@ void ETSGen::ApplyConversionAndStoreAccumulator(const ir::AstNode *const node, c StoreAccumulator(node, vreg); } -VReg ETSGen::StoreException(const ir::AstNode *node) +VReg ETSGen::StoreError(const ir::AstNode *node) { - VReg exception = AllocReg(); - Ra().Emit(node, exception); + VReg error = AllocReg(); + Ra().Emit(node, error); - SetAccumulatorType(Checker()->GlobalBuiltinExceptionType()); - SetVRegType(exception, GetAccumulatorType()); - return exception; + SetAccumulatorType(Checker()->GlobalBuiltinErrorType()); + SetVRegType(error, GetAccumulatorType()); + return error; } void ETSGen::StoreAccumulator(const ir::AstNode *const node, const VReg vreg) diff --git a/ets2panda/compiler/core/ETSGen.h b/ets2panda/compiler/core/ETSGen.h index 7b29d164a0544d94a6047990ad239a2dcbae598f..79bc976050eafc98b2116210ae330ff20df3063b 100644 --- a/ets2panda/compiler/core/ETSGen.h +++ b/ets2panda/compiler/core/ETSGen.h @@ -50,7 +50,7 @@ public: [[nodiscard]] const checker::Type *GetAccumulatorType() const; void CompileAndCheck(const ir::Expression *expr); - [[nodiscard]] VReg StoreException(const ir::AstNode *node); + [[nodiscard]] VReg StoreError(const ir::AstNode *node); void ApplyConversionAndStoreAccumulator(const ir::AstNode *node, VReg vreg, const checker::Type *targetType); void StoreAccumulator(const ir::AstNode *node, VReg vreg); void LoadAccumulator(const ir::AstNode *node, VReg vreg); diff --git a/ets2panda/compiler/core/dynamicContext.cpp b/ets2panda/compiler/core/dynamicContext.cpp index 529caf5327c5c922cd6e31c3dee52074e795a76e..b0d569eb54f27e64213165d790362c1e5a4a20de 100644 --- a/ets2panda/compiler/core/dynamicContext.cpp +++ b/ets2panda/compiler/core/dynamicContext.cpp @@ -233,12 +233,12 @@ void ETSTryContext::EmitFinalizer( etsg->SetLabel(tryStmt_, finalizerTable->LabelSet().CatchBegin()); - compiler::VReg exception = etsg->StoreException(tryStmt_); + compiler::VReg error = etsg->StoreError(tryStmt_); // Third compile of the finaly clause, executed if the statement executed abruptly tryStmt_->FinallyBlock()->Compile(etsg); - etsg->LoadAccumulator(tryStmt_, exception); - etsg->EmitThrow(tryStmt_, exception); + etsg->LoadAccumulator(tryStmt_, error); + etsg->EmitThrow(tryStmt_, error); etsg->SetLabel(tryStmt_, finalizerTable->LabelSet().CatchEnd()); }