• Home
  • Raw
  • Download

Lines Matching refs:ir

94     auto *blockStmt = AllocNode<ir::BlockStatement>(Allocator(), std::move(statements));  in ParseProgram()
116 ir::ModifierFlags ParserImpl::GetAccessability(ir::ModifierFlags modifiers) in GetAccessability()
118 if ((modifiers & ir::ModifierFlags::PUBLIC) != 0) { in GetAccessability()
119 return ir::ModifierFlags::PUBLIC; in GetAccessability()
122 if ((modifiers & ir::ModifierFlags::PRIVATE) != 0) { in GetAccessability()
123 return ir::ModifierFlags::PRIVATE; in GetAccessability()
126 if ((modifiers & ir::ModifierFlags::PROTECTED) != 0) { in GetAccessability()
127 return ir::ModifierFlags::PROTECTED; in GetAccessability()
130 if ((modifiers & ir::ModifierFlags::INTERNAL) != 0) { in GetAccessability()
131 return ir::ModifierFlags::INTERNAL; in GetAccessability()
134 return ir::ModifierFlags::NONE; in GetAccessability()
150 ir::ModifierFlags ParserImpl::ParseModifiers() in ParseModifiers()
152 ir::ModifierFlags resultStatus = ir::ModifierFlags::NONE; in ParseModifiers()
153 ir::ModifierFlags prevStatus = ir::ModifierFlags::ALL; in ParseModifiers()
166 ir::ModifierFlags actualStatus = ir::ModifierFlags::NONE; in ParseModifiers()
167 ir::ModifierFlags nextStatus = ir::ModifierFlags::NONE; in ParseModifiers()
171 actualStatus = ir::ModifierFlags::STATIC; in ParseModifiers()
172 nextStatus = ir::ModifierFlags::ASYNC; in ParseModifiers()
176 actualStatus = ir::ModifierFlags::ASYNC; in ParseModifiers()
177 nextStatus = ir::ModifierFlags::NONE; in ParseModifiers()
211 void ParserImpl::CheckAccessorPair(const ArenaVector<ir::AstNode *> &properties, const ir::Expressi… in CheckAccessorPair()
212 ir::MethodDefinitionKind methodKind, ir::ModifierFlags access) in CheckAccessorPair()
219 const ir::Expression *key = it->AsMethodDefinition()->Key(); in CheckAccessorPair()
243 ir::ModifierFlags getAccess = ir::ModifierFlags::NONE; in CheckAccessorPair()
244 ir::ModifierFlags setAccess = ir::ModifierFlags::NONE; in CheckAccessorPair()
246 if (methodKind == ir::MethodDefinitionKind::GET) { in CheckAccessorPair()
254 if ((setAccess == ir::ModifierFlags::NONE && getAccess > ir::ModifierFlags::PUBLIC) || in CheckAccessorPair()
255 (setAccess != ir::ModifierFlags::NONE && getAccess > setAccess)) { in CheckAccessorPair()
284 …keywordType == lexer::TokenType::KEYW_GET ? ir::MethodDefinitionKind::GET : ir::MethodDefinitionKi… in ParseClassAccessor()
298 void ParserImpl::ThrowErrorIfStaticConstructor([[maybe_unused]] ir::ModifierFlags flags) {} in ThrowErrorIfStaticConstructor()
302 if (((desc->modifiers & ir::ModifierFlags::ASYNC) != 0 || desc->isGenerator) && in ValidateClassKey()
303 …(desc->methodKind == ir::MethodDefinitionKind::GET || desc->methodKind == ir::MethodDefinitionKind… in ValidateClassKey()
316 if ((desc->modifiers & ir::ModifierFlags::STATIC) == 0) { in ValidateClassKey()
317 if ((desc->modifiers & ir::ModifierFlags::ASYNC) != 0 || in ValidateClassKey()
318 desc->methodKind == ir::MethodDefinitionKind::GET || in ValidateClassKey()
319 desc->methodKind == ir::MethodDefinitionKind::SET || desc->isGenerator) { in ValidateClassKey()
323 desc->methodKind = ir::MethodDefinitionKind::CONSTRUCTOR; in ValidateClassKey()
333 } else if (propNameStr.Is("prototype") && (desc->modifiers & ir::ModifierFlags::STATIC) != 0) { in ValidateClassKey()
338 std::tuple<bool, bool, bool> ParserImpl::ParseComputedClassFieldOrIndexSignature(ir::Expression **p… in ParseComputedClassFieldOrIndexSignature()
351 ir::Expression *ParserImpl::ParseClassKey(ClassElementDescriptor *desc) in ParseClassKey()
353 ir::Expression *propName = nullptr; in ParseClassKey()
362 propName = AllocNode<ir::Identifier>(lexer_->GetToken().Ident(), Allocator()); in ParseClassKey()
374 …if (lexer_->GetToken().Ident().Is("prototype") && (desc->modifiers & ir::ModifierFlags::STATIC) !=… in ParseClassKey()
378 propName = AllocNode<ir::StringLiteral>(lexer_->GetToken().String()); in ParseClassKey()
386 propName = AllocNode<ir::BigIntLiteral>(lexer_->GetToken().BigInt()); in ParseClassKey()
388 propName = AllocNode<ir::NumberLiteral>(lexer_->GetToken().GetNumber()); in ParseClassKey()
413 void ParserImpl::ValidateClassMethodStart(ClassElementDescriptor *desc, [[maybe_unused]] ir::TypeNo… in ValidateClassMethodStart()
420 if ((desc->modifiers & ir::ModifierFlags::ASYNC) != 0) { in ValidateClassMethodStart()
430 [[maybe_unused]] const ArenaVector<ir::AstNode *> &properties, in ValidateClassSetter()
431 … [[maybe_unused]] ir::Expression *propName, ir::ScriptFunction *func) in ValidateClassSetter()
439 [[maybe_unused]] const ArenaVector<ir::AstNode *> &properties, in ValidateClassGetter()
440 … [[maybe_unused]] ir::Expression *propName, ir::ScriptFunction *func) in ValidateClassGetter()
447 ir::MethodDefinition *ParserImpl::ParseClassMethod(ClassElementDescriptor *desc, in ParseClassMethod()
448 const ArenaVector<ir::AstNode *> &properties, in ParseClassMethod()
449ir::Expression *propName, lexer::SourcePosition *propEnd) in ParseClassMethod()
451 if (desc->methodKind != ir::MethodDefinitionKind::SET && in ParseClassMethod()
456 ir::ScriptFunction *func = ParseFunction(desc->newStatus); in ParseClassMethod()
458 auto *funcExpr = AllocNode<ir::FunctionExpression>(func); in ParseClassMethod()
461 if (desc->methodKind == ir::MethodDefinitionKind::SET) { in ParseClassMethod()
463 } else if (desc->methodKind == ir::MethodDefinitionKind::GET) { in ParseClassMethod()
468 func->AddFlag(ir::ScriptFunctionFlags::METHOD); in ParseClassMethod()
469 …auto *method = AllocNode<ir::MethodDefinition>(desc->methodKind, propName, funcExpr, desc->modifie… in ParseClassMethod()
476 ir::ClassElement *ParserImpl::ParseClassProperty(ClassElementDescriptor *desc, in ParseClassProperty()
477 … const ArenaVector<ir::AstNode *> &properties, ir::Expression *propName, in ParseClassProperty()
478 ir::TypeNode *typeAnnotation) in ParseClassProperty()
481 ir::ClassElement *property = nullptr; in ParseClassProperty()
484 if ((desc->modifiers & ir::ModifierFlags::DECLARE) != 0) { in ParseClassProperty()
493 ir::Expression *value = nullptr; in ParseClassProperty()
498 if (InAmbientContext() || (desc->modifiers & ir::ModifierFlags::DECLARE) != 0) { in ParseClassProperty()
507 …AllocNode<ir::ClassProperty>(propName, value, typeAnnotation, desc->modifiers, Allocator(), desc->… in ParseClassProperty()
547 void ParserImpl::AddPrivateElement(const ir::ClassElement *elem) in AddPrivateElement()
554 ir::ClassElement *ParserImpl::ParseClassStaticBlock() in ParseClassStaticBlock()
565 ArenaVector<ir::Expression *> params(Allocator()->Adapter()); in ParseClassStaticBlock()
567 ArenaVector<ir::Statement *> statements = ParseStatementList(); in ParseClassStaticBlock()
569 auto *body = AllocNode<ir::BlockStatement>(Allocator(), std::move(statements)); in ParseClassStaticBlock()
571 … AllocNode<ir::ScriptFunction>(ir::FunctionSignature(nullptr, std::move(params), nullptr), body, in ParseClassStaticBlock()
572ir::ScriptFunctionFlags::EXPRESSION | ir::ScriptFunctionFlags::STATIC_BLOCK, in ParseClassStaticBlock()
573 ir::ModifierFlags::STATIC, false, context_.GetLanguge()); in ParseClassStaticBlock()
575 auto *funcExpr = AllocNode<ir::FunctionExpression>(func); in ParseClassStaticBlock()
576 auto *staticBlock = AllocNode<ir::ClassStaticBlock>(funcExpr, Allocator()); in ParseClassStaticBlock()
585 ir::AstNode *ParserImpl::ParseClassElement(const ArenaVector<ir::AstNode *> &properties, in ParseClassElement()
586 [[maybe_unused]] ir::ClassDefinitionModifiers modifiers, in ParseClassElement()
587 [[maybe_unused]] ir::ModifierFlags flags, in ParseClassElement()
588 [[maybe_unused]] ir::Identifier *identNode) in ParseClassElement()
597 desc.methodKind = ir::MethodDefinitionKind::METHOD; in ParseClassElement()
599 desc.hasSuperClass = (modifiers & ir::ClassDefinitionModifiers::HAS_SUPER) != 0U; in ParseClassElement()
607 if ((desc.modifiers & ir::ModifierFlags::STATIC) == 0) { in ParseClassElement()
611 ir::Expression *propName = ParseClassKey(&desc); in ParseClassElement()
613 ir::ClassElement *property = ParseClassProperty(&desc, properties, propName, nullptr); in ParseClassElement()
636 ir::MethodDefinition *ParserImpl::BuildImplicitConstructor(ir::ClassDefinitionModifiers modifiers, in BuildImplicitConstructor()
639 ArenaVector<ir::Expression *> params(Allocator()->Adapter()); in BuildImplicitConstructor()
640 ArenaVector<ir::Statement *> statements(Allocator()->Adapter()); in BuildImplicitConstructor()
642 if ((modifiers & ir::ClassDefinitionModifiers::HAS_SUPER) != 0U) { in BuildImplicitConstructor()
644 params.push_back(AllocNode<ir::SpreadElement>(ir::AstNodeType::REST_ELEMENT, Allocator(), in BuildImplicitConstructor()
645 … AllocNode<ir::Identifier>(argsStr, Allocator()))); in BuildImplicitConstructor()
646 ArenaVector<ir::Expression *> callArgs(Allocator()->Adapter()); in BuildImplicitConstructor()
647 auto *superExpr = AllocNode<ir::SuperExpression>(); in BuildImplicitConstructor()
648 … callArgs.push_back(AllocNode<ir::SpreadElement>(ir::AstNodeType::SPREAD_ELEMENT, Allocator(), in BuildImplicitConstructor()
649 … AllocNode<ir::Identifier>(argsStr, Allocator()))); in BuildImplicitConstructor()
651 … auto *callExpr = AllocNode<ir::CallExpression>(superExpr, std::move(callArgs), nullptr, false); in BuildImplicitConstructor()
652 statements.push_back(AllocNode<ir::ExpressionStatement>(callExpr)); in BuildImplicitConstructor()
655 auto *body = AllocNode<ir::BlockStatement>(Allocator(), std::move(statements)); in BuildImplicitConstructor()
656 …auto *func = AllocNode<ir::ScriptFunction>(ir::FunctionSignature(nullptr, std::move(params), nullp… in BuildImplicitConstructor()
657 ir::ScriptFunctionFlags::CONSTRUCTOR | in BuildImplicitConstructor()
658ir::ScriptFunctionFlags::IMPLICIT_SUPER_CALL_NEEDED, in BuildImplicitConstructor()
661 auto *funcExpr = AllocNode<ir::FunctionExpression>(func); in BuildImplicitConstructor()
662 auto *key = AllocNode<ir::Identifier>("constructor", Allocator()); in BuildImplicitConstructor()
664 if ((modifiers & ir::ClassDefinitionModifiers::SET_CTOR_ID) != 0U) { in BuildImplicitConstructor()
668 … auto *ctor = AllocNode<ir::MethodDefinition>(ir::MethodDefinitionKind::CONSTRUCTOR, key, funcExpr, in BuildImplicitConstructor()
669 ir::ModifierFlags::NONE, Allocator(), false); in BuildImplicitConstructor()
676 void ParserImpl::CreateImplicitConstructor(ir::MethodDefinition *&ctor, in CreateImplicitConstructor()
677 [[maybe_unused]] ArenaVector<ir::AstNode *> &properties, in CreateImplicitConstructor()
678 ir::ClassDefinitionModifiers modifiers, in CreateImplicitConstructor()
688 ir::Identifier *ParserImpl::ParseClassIdent(ir::ClassDefinitionModifiers modifiers) in ParseClassIdent()
695 …static_cast<ir::ClassDefinitionModifiers>(modifiers & ir::ClassDefinitionModifiers::DECLARATION_ID… in ParseClassIdent()
697 if (idRequired == ir::ClassDefinitionModifiers::DECLARATION_ID_REQUIRED) { in ParseClassIdent()
704 bool ParserImpl::CheckClassElement(ir::AstNode *property, ir::MethodDefinition *&ctor, in CheckClassElement()
705 [[maybe_unused]] ArenaVector<ir::AstNode *> &properties) in CheckClassElement()
711 ir::MethodDefinition *def = property->AsMethodDefinition(); in CheckClassElement()
724 ir::Expression *ParserImpl::ParseSuperClassReference() in ParseSuperClassReference()
734 std::tuple<ir::Expression *, ir::TSTypeParameterInstantiation *> ParserImpl::ParseSuperClass() in ParseSuperClass()
740 ir::ClassDefinition *ParserImpl::ParseClassDefinition(ir::ClassDefinitionModifiers modifiers, ir::M… in ParseClassDefinition()
744 ir::Identifier *identNode = ParseClassIdent(modifiers); in ParseClassDefinition()
746 if (identNode == nullptr && (modifiers & ir::ClassDefinitionModifiers::DECLARATION) != 0U) { in ParseClassDefinition()
756 modifiers |= ir::ClassDefinitionModifiers::HAS_SUPER; in ParseClassDefinition()
763 ArenaVector<ir::TSClassImplements *> implements(Allocator()->Adapter()); in ParseClassDefinition()
764 auto *classDefinition = AllocNode<ir::ClassDefinition>( in ParseClassDefinition()
773 ParserImpl::ClassBody ParserImpl::ParseClassBody(ir::ClassDefinitionModifiers modifiers, ir::Modifi… in ParseClassBody()
774 ir::Identifier *identNode) in ParseClassBody()
781 ir::MethodDefinition *ctor = nullptr; in ParseClassBody()
782 ArenaVector<ir::AstNode *> properties(Allocator()->Adapter()); in ParseClassBody()
792 ir::AstNode *property = ParseClassElement(properties, modifiers, flags, identNode); in ParseClassBody()
808 void ParserImpl::ValidateRestParameter(ir::Expression *param) in ValidateRestParameter()
822 ArenaVector<ir::Expression *> ParserImpl::ParseFunctionParams() in ParseFunctionParams()
828 ArenaVector<ir::Expression *> params(Allocator()->Adapter()); in ParseFunctionParams()
831 ir::Expression *parameter = ParseFunctionParameter(); in ParseFunctionParams()
848 ir::Expression *ParserImpl::CreateParameterThis([[maybe_unused]] util::StringView className) in CreateParameterThis()
853 std::tuple<bool, ir::BlockStatement *, lexer::SourcePosition, bool> ParserImpl::ParseFunctionBody( in ParseFunctionBody()
854 …[[maybe_unused]] const ArenaVector<ir::Expression *> &params, [[maybe_unused]] ParserStatus newSta… in ParseFunctionBody()
861 ir::BlockStatement *body = ParseBlockStatement(); in ParseFunctionBody()
866 FunctionSignature ParserImpl::ParseFunctionSignature(ParserStatus status, ir::Identifier *className) in ParseFunctionSignature()
868 ir::TSTypeParameterDeclaration *typeParamDecl = ParseFunctionTypeParameters(); in ParseFunctionSignature()
876 ir::Expression *parameterThis = nullptr; in ParseFunctionSignature()
890 ir::TypeNode *returnTypeAnnotation = ParseFunctionReturnType(status); in ParseFunctionSignature()
891 ir::ScriptFunctionFlags throwMarker = ParseFunctionThrowMarker(true); in ParseFunctionSignature()
893 auto res = ir::FunctionSignature(typeParamDecl, std::move(params), returnTypeAnnotation); in ParseFunctionSignature()
897 ir::ScriptFunction *ParserImpl::ParseFunction(ParserStatus newStatus) in ParseFunction()
910 functionContext.AddFlag(ir::ScriptFunctionFlags::OVERLOAD); in ParseFunction()
914 …auto *funcNode = AllocNode<ir::ScriptFunction>(std::move(signature), body, functionContext.Flags(), in ParseFunction()
921 ir::SpreadElement *ParserImpl::ParseSpreadElement(ExpressionParseFlags flags) in ParseSpreadElement()
928 ir::Expression *argument {}; in ParseSpreadElement()
942 auto nodeType = inPattern ? ir::AstNodeType::REST_ELEMENT : ir::AstNodeType::SPREAD_ELEMENT; in ParseSpreadElement()
943 auto *spreadElementNode = AllocNode<ir::SpreadElement>(nodeType, Allocator(), argument); in ParseSpreadElement()
974 ir::Expression *ParserImpl::ParseFunctionParameter() in ParseFunctionParameter()
985 void ParserImpl::ValidateLvalueAssignmentTarget(ir::Expression *node) in ValidateLvalueAssignmentTarget()
988 case ir::AstNodeType::IDENTIFIER: { in ValidateLvalueAssignmentTarget()
992 case ir::AstNodeType::MEMBER_EXPRESSION: { in ValidateLvalueAssignmentTarget()
1001 void ParserImpl::ValidateAssignmentTarget(ExpressionParseFlags flags, ir::Expression *node) in ValidateAssignmentTarget()
1004 case ir::AstNodeType::ARRAY_PATTERN: in ValidateAssignmentTarget()
1005 case ir::AstNodeType::OBJECT_PATTERN: { in ValidateAssignmentTarget()
1008 case ir::AstNodeType::ARRAY_EXPRESSION: in ValidateAssignmentTarget()
1009 case ir::AstNodeType::OBJECT_EXPRESSION: { in ValidateAssignmentTarget()
1022 void ParserImpl::ValidateArrowParameterBindings(const ir::Expression *node) in ValidateArrowParameterBindings()
1025 case ir::AstNodeType::IDENTIFIER: { in ValidateArrowParameterBindings()
1029 case ir::AstNodeType::OMITTED_EXPRESSION: { in ValidateArrowParameterBindings()
1032 case ir::AstNodeType::REST_ELEMENT: { in ValidateArrowParameterBindings()
1036 case ir::AstNodeType::PROPERTY: { in ValidateArrowParameterBindings()
1039 case ir::AstNodeType::OBJECT_PATTERN: { in ValidateArrowParameterBindings()
1047 case ir::AstNodeType::ARRAY_PATTERN: { in ValidateArrowParameterBindings()
1055 case ir::AstNodeType::ASSIGNMENT_PATTERN: { in ValidateArrowParameterBindings()
1065 void ParserImpl::ThrowParameterModifierError(ir::ModifierFlags status) const in ThrowParameterModifierError()
1068 (status & ir::ModifierFlags::STATIC) != 0 ? "static" in ThrowParameterModifierError()
1069 : (status & ir::ModifierFlags::ASYNC) != 0 ? "async" in ThrowParameterModifierError()
1075 ir::Identifier *ParserImpl::ExpectIdentifier(bool isReference, bool isUserDefinedType) in ExpectIdentifier()
1089 auto *ident = AllocNode<ir::Identifier>(lexer_->GetToken().Ident(), Allocator()); in ExpectIdentifier()