// Copyright 2012 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/v8.h" #include "src/code-factory.h" #include "src/codegen.h" #include "src/compiler.h" #include "src/debug.h" #include "src/full-codegen.h" #include "src/liveedit.h" #include "src/macro-assembler.h" #include "src/prettyprinter.h" #include "src/scopeinfo.h" #include "src/scopes.h" #include "src/snapshot.h" namespace v8 { namespace internal { void BreakableStatementChecker::Check(Statement* stmt) { Visit(stmt); } void BreakableStatementChecker::Check(Expression* expr) { Visit(expr); } void BreakableStatementChecker::VisitVariableDeclaration( VariableDeclaration* decl) { } void BreakableStatementChecker::VisitFunctionDeclaration( FunctionDeclaration* decl) { } void BreakableStatementChecker::VisitModuleDeclaration( ModuleDeclaration* decl) { } void BreakableStatementChecker::VisitImportDeclaration( ImportDeclaration* decl) { } void BreakableStatementChecker::VisitExportDeclaration( ExportDeclaration* decl) { } void BreakableStatementChecker::VisitModuleLiteral(ModuleLiteral* module) { } void BreakableStatementChecker::VisitModuleVariable(ModuleVariable* module) { } void BreakableStatementChecker::VisitModulePath(ModulePath* module) { } void BreakableStatementChecker::VisitModuleUrl(ModuleUrl* module) { } void BreakableStatementChecker::VisitModuleStatement(ModuleStatement* stmt) { } void BreakableStatementChecker::VisitBlock(Block* stmt) { } void BreakableStatementChecker::VisitExpressionStatement( ExpressionStatement* stmt) { // Check if expression is breakable. Visit(stmt->expression()); } void BreakableStatementChecker::VisitEmptyStatement(EmptyStatement* stmt) { } void BreakableStatementChecker::VisitIfStatement(IfStatement* stmt) { // If the condition is breakable the if statement is breakable. Visit(stmt->condition()); } void BreakableStatementChecker::VisitContinueStatement( ContinueStatement* stmt) { } void BreakableStatementChecker::VisitBreakStatement(BreakStatement* stmt) { } void BreakableStatementChecker::VisitReturnStatement(ReturnStatement* stmt) { // Return is breakable if the expression is. Visit(stmt->expression()); } void BreakableStatementChecker::VisitWithStatement(WithStatement* stmt) { Visit(stmt->expression()); } void BreakableStatementChecker::VisitSwitchStatement(SwitchStatement* stmt) { // Switch statements breakable if the tag expression is. Visit(stmt->tag()); } void BreakableStatementChecker::VisitDoWhileStatement(DoWhileStatement* stmt) { // Mark do while as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitWhileStatement(WhileStatement* stmt) { // Mark while statements breakable if the condition expression is. Visit(stmt->cond()); } void BreakableStatementChecker::VisitForStatement(ForStatement* stmt) { // Mark for statements breakable if the condition expression is. if (stmt->cond() != NULL) { Visit(stmt->cond()); } } void BreakableStatementChecker::VisitForInStatement(ForInStatement* stmt) { // Mark for in statements breakable if the enumerable expression is. Visit(stmt->enumerable()); } void BreakableStatementChecker::VisitForOfStatement(ForOfStatement* stmt) { // For-of is breakable because of the next() call. is_breakable_ = true; } void BreakableStatementChecker::VisitTryCatchStatement( TryCatchStatement* stmt) { // Mark try catch as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitTryFinallyStatement( TryFinallyStatement* stmt) { // Mark try finally as breakable to avoid adding a break slot in front of it. is_breakable_ = true; } void BreakableStatementChecker::VisitDebuggerStatement( DebuggerStatement* stmt) { // The debugger statement is breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCaseClause(CaseClause* clause) { } void BreakableStatementChecker::VisitFunctionLiteral(FunctionLiteral* expr) { } void BreakableStatementChecker::VisitClassLiteral(ClassLiteral* expr) { if (expr->extends() != NULL) { Visit(expr->extends()); } } void BreakableStatementChecker::VisitNativeFunctionLiteral( NativeFunctionLiteral* expr) { } void BreakableStatementChecker::VisitConditional(Conditional* expr) { } void BreakableStatementChecker::VisitVariableProxy(VariableProxy* expr) { } void BreakableStatementChecker::VisitLiteral(Literal* expr) { } void BreakableStatementChecker::VisitRegExpLiteral(RegExpLiteral* expr) { } void BreakableStatementChecker::VisitObjectLiteral(ObjectLiteral* expr) { } void BreakableStatementChecker::VisitArrayLiteral(ArrayLiteral* expr) { } void BreakableStatementChecker::VisitAssignment(Assignment* expr) { // If assigning to a property (including a global property) the assignment is // breakable. VariableProxy* proxy = expr->target()->AsVariableProxy(); Property* prop = expr->target()->AsProperty(); if (prop != NULL || (proxy != NULL && proxy->var()->IsUnallocated())) { is_breakable_ = true; return; } // Otherwise the assignment is breakable if the assigned value is. Visit(expr->value()); } void BreakableStatementChecker::VisitYield(Yield* expr) { // Yield is breakable if the expression is. Visit(expr->expression()); } void BreakableStatementChecker::VisitThrow(Throw* expr) { // Throw is breakable if the expression is. Visit(expr->exception()); } void BreakableStatementChecker::VisitProperty(Property* expr) { // Property load is breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCall(Call* expr) { // Function calls both through IC and call stub are breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCallNew(CallNew* expr) { // Function calls through new are breakable. is_breakable_ = true; } void BreakableStatementChecker::VisitCallRuntime(CallRuntime* expr) { } void BreakableStatementChecker::VisitUnaryOperation(UnaryOperation* expr) { Visit(expr->expression()); } void BreakableStatementChecker::VisitCountOperation(CountOperation* expr) { Visit(expr->expression()); } void BreakableStatementChecker::VisitBinaryOperation(BinaryOperation* expr) { Visit(expr->left()); if (expr->op() != Token::AND && expr->op() != Token::OR) { Visit(expr->right()); } } void BreakableStatementChecker::VisitCompareOperation(CompareOperation* expr) { Visit(expr->left()); Visit(expr->right()); } void BreakableStatementChecker::VisitThisFunction(ThisFunction* expr) { } void BreakableStatementChecker::VisitSuperReference(SuperReference* expr) {} #define __ ACCESS_MASM(masm()) bool FullCodeGenerator::MakeCode(CompilationInfo* info) { Isolate* isolate = info->isolate(); TimerEventScope timer(info->isolate()); Handle