本文整理汇总了C++中StatementNode类的典型用法代码示例。如果您正苦于以下问题:C++ StatementNode类的具体用法?C++ StatementNode怎么用?C++ StatementNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StatementNode类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SourceCodeKey
UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, ParserError& error)
{
SourceCodeKey key = SourceCodeKey(source, name.string(), SourceCodeKey::FunctionType, JSParseNormal);
CodeCacheMap::AddResult addResult = m_sourceCode.add(key, SourceCodeValue());
if (!addResult.isNewEntry)
return jsCast<UnlinkedFunctionExecutable*>(addResult.iterator->value.cell.get());
RefPtr<ProgramNode> program = parse<ProgramNode>(&globalData, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
if (!program) {
ASSERT(error.m_type != ParserError::ErrorNone);
m_sourceCode.remove(addResult.iterator);
return 0;
}
// This function assumes an input string that would result in a single anonymous function expression.
StatementNode* exprStatement = program->singleStatement();
ASSERT(exprStatement);
ASSERT(exprStatement->isExprStatement());
ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
ASSERT(funcExpr);
RELEASE_ASSERT(funcExpr->isFuncExprNode());
FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
ASSERT(body);
ASSERT(body->ident().isNull());
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&globalData, source, body);
functionExecutable->m_nameValue.set(globalData, functionExecutable, jsString(&globalData, name.string()));
addResult.iterator->value = SourceCodeValue(globalData, functionExecutable, m_sourceCode.age());
return functionExecutable;
}
示例2: visit
// (If <expression> <statement> (Else <statement>)?
void visit( IfStatementNode aNode ) {
std::cout << " (If ";
aNode.getCond()->accept( (*this) );
aNode.getTrueBranch()->accept( (*this) );
StatementNode* falseBranch = aNode.getFalseBranch();
if ( falseBranch != NULL ) {
std::cout << " Else ";
falseBranch->accept( (*this) );
}
std::cout << " )";
}
示例3: SemanticException
void StatementMientrasNode::ValidateSemantic()
{
if(Expression->ValidateSemantic()->Name!="Booleano")
{
throw SemanticException("Se esperaba Booleano ,Fila:"+to_string(Expression->Row)+",Columna:"+to_string(Expression->Column));
}
list<StatementNode*>::const_iterator iterator;
StatementNode* temp;
for (iterator = Statements->begin(); iterator != Statements->end(); ++iterator) {
temp=*iterator;
temp->ValidateSemantic();
}
}
示例4: ASSERT
FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception)
{
JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
RefPtr<ProgramNode> program = exec->globalData().parser->parse<ProgramNode>(lexicalGlobalObject, debugger, exec, source, 0, JSParseNormal, exception);
if (!program) {
ASSERT(*exception);
return 0;
}
// Uses of this function that would not result in a single function expression are invalid.
StatementNode* exprStatement = program->singleStatement();
ASSERT(exprStatement);
ASSERT(exprStatement->isExprStatement());
ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
ASSERT(funcExpr);
ASSERT(funcExpr->isFuncExprNode());
FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
ASSERT(body);
return FunctionExecutable::create(exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
}
示例5: SemanticException
void StatementParaNode::ValidateSemantic()
{
if(Variable->ValidateSemantic()->Name!="Entero")
{
throw SemanticException("Se esperaba Entero ,Fila:"+to_string(Variable->Row)+",Columna:"+to_string(Variable->Column));
}
if(FirstExpression->ValidateSemantic()->Name!="Entero")
{
throw SemanticException("Se esperaba Entero ,Fila:"+to_string(FirstExpression->Row)+",Columna:"+to_string(FirstExpression->Column));
}
if(SecondExpression->ValidateSemantic()->Name!="Entero")
{
throw SemanticException("Se esperaba Entero ,Fila:"+to_string(SecondExpression->Row)+",Columna:"+to_string(SecondExpression->Column));
}
list<StatementNode*>::const_iterator iterator;
StatementNode* temp;
for (iterator = Statements->begin(); iterator != Statements->end(); ++iterator) {
temp=*iterator;
temp->ValidateSemantic();
}
}
示例6: key
// FIXME: There's no need to add the function's name to the key here. It's already in the source code.
UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(VM& vm, const Identifier& name, const SourceCode& source, ParserError& error)
{
bool isArrowFunctionContext = false;
SourceCodeKey key(
source, name.string(), SourceCodeType::FunctionType,
JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict,
JSParserCommentMode::Classic,
DerivedContextType::None,
EvalContextType::None,
isArrowFunctionContext);
SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
if (cache) {
UnlinkedFunctionExecutable* executable = jsCast<UnlinkedFunctionExecutable*>(cache->cell.get());
source.provider()->setSourceURLDirective(executable->sourceURLDirective());
source.provider()->setSourceMappingURLDirective(executable->sourceMappingURLDirective());
return executable;
}
JSTextPosition positionBeforeLastNewline;
std::unique_ptr<ProgramNode> program = parse<ProgramNode>(
&vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict, JSParserCommentMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded,
error, &positionBeforeLastNewline);
if (!program) {
RELEASE_ASSERT(error.isValid());
return nullptr;
}
// This function assumes an input string that would result in a single function declaration.
StatementNode* statement = program->singleStatement();
ASSERT(statement);
ASSERT(statement->isBlock());
if (!statement || !statement->isBlock())
return nullptr;
StatementNode* funcDecl = static_cast<BlockNode*>(statement)->singleStatement();
ASSERT(funcDecl);
ASSERT(funcDecl->isFuncDeclNode());
if (!funcDecl || !funcDecl->isFuncDeclNode())
return nullptr;
FunctionMetadataNode* metadata = static_cast<FuncDeclNode*>(funcDecl)->metadata();
ASSERT(metadata);
if (!metadata)
return nullptr;
metadata->overrideName(name);
metadata->setEndPosition(positionBeforeLastNewline);
// The Function constructor only has access to global variables, so no variables will be under TDZ.
VariableEnvironment emptyTDZVariables;
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, UnlinkedNormalFunction, ConstructAbility::CanConstruct, JSParserCommentMode::Classic, emptyTDZVariables, DerivedContextType::None);
functionExecutable->setSourceURLDirective(source.provider()->sourceURL());
functionExecutable->setSourceMappingURLDirective(source.provider()->sourceMappingURL());
m_sourceCode.addCache(key, SourceCodeValue(vm, functionExecutable, m_sourceCode.age()));
return functionExecutable;
}
示例7: ASSERT
PassRefPtr<FunctionExecutable> FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
{
RefPtr<ProgramNode> program = exec->globalData().parser->parse<ProgramNode>(&exec->globalData(), debugger, exec, source, errLine, errMsg);
if (!program)
return 0;
StatementNode* exprStatement = program->singleStatement();
ASSERT(exprStatement);
ASSERT(exprStatement->isExprStatement());
if (!exprStatement || !exprStatement->isExprStatement())
return 0;
ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
ASSERT(funcExpr);
ASSERT(funcExpr->isFuncExprNode());
if (!funcExpr || !funcExpr->isFuncExprNode())
return 0;
FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
ASSERT(body);
return FunctionExecutable::create(&exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
}
示例8: SourceCodeKey
// FIXME: There's no need to add the function's name to the key here. It's already in the source code.
UnlinkedFunctionExecutable* CodeCache::getFunctionExecutableFromGlobalCode(VM& vm, const Identifier& name, const SourceCode& source, ParserError& error)
{
SourceCodeKey key = SourceCodeKey(
source, name.string(), SourceCodeKey::FunctionType,
JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict);
SourceCodeValue* cache = m_sourceCode.findCacheAndUpdateAge(key);
if (cache)
return jsCast<UnlinkedFunctionExecutable*>(cache->cell.get());
JSTextPosition positionBeforeLastNewline;
std::unique_ptr<ProgramNode> program = parse<ProgramNode>(
&vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict, JSParserCodeType::Program,
error, &positionBeforeLastNewline);
if (!program) {
RELEASE_ASSERT(error.isValid());
return nullptr;
}
// This function assumes an input string that would result in a single function declaration.
StatementNode* statement = program->singleStatement();
ASSERT(statement);
ASSERT(statement->isBlock());
if (!statement || !statement->isBlock())
return nullptr;
StatementNode* funcDecl = static_cast<BlockNode*>(statement)->singleStatement();
ASSERT(funcDecl);
ASSERT(funcDecl->isFuncDeclNode());
if (!funcDecl || !funcDecl->isFuncDeclNode())
return nullptr;
FunctionBodyNode* body = static_cast<FuncDeclNode*>(funcDecl)->body();
ASSERT(body);
if (!body)
return nullptr;
body->setEndPosition(positionBeforeLastNewline);
// The Function constructor only has access to global variables, so no variables will be under TDZ.
VariableEnvironment emptyTDZVariables;
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, body, UnlinkedNormalFunction, ConstructAbility::CanConstruct, emptyTDZVariables);
functionExecutable->m_nameValue.set(vm, functionExecutable, jsString(&vm, name.string()));
m_sourceCode.addCache(key, SourceCodeValue(vm, functionExecutable, m_sourceCode.age()));
return functionExecutable;
}
示例9: m_vm
BuiltinExecutables::BuiltinExecutables(VM& vm)
: m_vm(vm)
#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length)))
JSC_FOREACH_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef EXPOSE_BUILTIN_STRINGS
{
}
UnlinkedFunctionExecutable* BuiltinExecutables::createDefaultConstructor(ConstructorKind constructorKind, const Identifier& name)
{
static NeverDestroyed<const String> baseConstructorCode(ASCIILiteral("(function () { })"));
static NeverDestroyed<const String> derivedConstructorCode(ASCIILiteral("(function () { super(...arguments); })"));
switch (constructorKind) {
case ConstructorKind::None:
break;
case ConstructorKind::Base:
return createExecutable(m_vm, makeSource(baseConstructorCode), name, constructorKind, ConstructAbility::CanConstruct);
case ConstructorKind::Extends:
return createExecutable(m_vm, makeSource(derivedConstructorCode), name, constructorKind, ConstructAbility::CanConstruct);
}
ASSERT_NOT_REACHED();
return nullptr;
}
UnlinkedFunctionExecutable* BuiltinExecutables::createBuiltinExecutable(const SourceCode& code, const Identifier& name, ConstructAbility constructAbility)
{
return createExecutable(m_vm, code, name, ConstructorKind::None, constructAbility);
}
UnlinkedFunctionExecutable* createBuiltinExecutable(VM& vm, const SourceCode& code, const Identifier& name, ConstructAbility constructAbility)
{
return BuiltinExecutables::createExecutable(vm, code, name, ConstructorKind::None, constructAbility);
}
UnlinkedFunctionExecutable* BuiltinExecutables::createExecutable(VM& vm, const SourceCode& source, const Identifier& name, ConstructorKind constructorKind, ConstructAbility constructAbility)
{
JSTextPosition positionBeforeLastNewline;
ParserError error;
bool isParsingDefaultConstructor = constructorKind != ConstructorKind::None;
JSParserBuiltinMode builtinMode = isParsingDefaultConstructor ? JSParserBuiltinMode::NotBuiltin : JSParserBuiltinMode::Builtin;
UnlinkedFunctionKind kind = isParsingDefaultConstructor ? UnlinkedNormalFunction : UnlinkedBuiltinFunction;
RefPtr<SourceProvider> sourceOverride = isParsingDefaultConstructor ? source.provider() : nullptr;
std::unique_ptr<ProgramNode> program = parse<ProgramNode>(
&vm, source, Identifier(), builtinMode,
JSParserStrictMode::NotStrict, SourceParseMode::ProgramMode, SuperBinding::NotNeeded, error,
&positionBeforeLastNewline, constructorKind);
if (!program) {
dataLog("Fatal error compiling builtin function '", name.string(), "': ", error.message());
CRASH();
}
StatementNode* exprStatement = program->singleStatement();
RELEASE_ASSERT(exprStatement);
RELEASE_ASSERT(exprStatement->isExprStatement());
ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
RELEASE_ASSERT(funcExpr);
RELEASE_ASSERT(funcExpr->isFuncExprNode());
FunctionMetadataNode* metadata = static_cast<FuncExprNode*>(funcExpr)->metadata();
RELEASE_ASSERT(!program->hasCapturedVariables());
metadata->setEndPosition(positionBeforeLastNewline);
RELEASE_ASSERT(metadata);
RELEASE_ASSERT(metadata->ident().isNull());
// This function assumes an input string that would result in a single anonymous function expression.
metadata->setEndPosition(positionBeforeLastNewline);
RELEASE_ASSERT(metadata);
metadata->overrideName(name);
VariableEnvironment dummyTDZVariables;
UnlinkedFunctionExecutable* functionExecutable = UnlinkedFunctionExecutable::create(&vm, source, metadata, kind, constructAbility, dummyTDZVariables, DerivedContextType::None, WTFMove(sourceOverride));
return functionExecutable;
}