| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 3253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3264 Zone* zone_; \ | 3264 Zone* zone_; \ |
| 3265 bool stack_overflow_ | 3265 bool stack_overflow_ |
| 3266 | 3266 |
| 3267 | 3267 |
| 3268 // ---------------------------------------------------------------------------- | 3268 // ---------------------------------------------------------------------------- |
| 3269 // AstNode factory | 3269 // AstNode factory |
| 3270 | 3270 |
| 3271 class AstNodeFactory final BASE_EMBEDDED { | 3271 class AstNodeFactory final BASE_EMBEDDED { |
| 3272 public: | 3272 public: |
| 3273 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3273 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
| 3274 : zone_(ast_value_factory->zone()), | 3274 : local_zone_(ast_value_factory->zone()), |
| 3275 parser_zone_(ast_value_factory->zone()), |
| 3275 ast_value_factory_(ast_value_factory) {} | 3276 ast_value_factory_(ast_value_factory) {} |
| 3276 | 3277 |
| 3277 VariableDeclaration* NewVariableDeclaration( | 3278 VariableDeclaration* NewVariableDeclaration( |
| 3278 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, | 3279 VariableProxy* proxy, VariableMode mode, Scope* scope, int pos, |
| 3279 bool is_class_declaration = false, int declaration_group_start = -1) { | 3280 bool is_class_declaration = false, int declaration_group_start = -1) { |
| 3280 return new (zone_) | 3281 return new (parser_zone_) |
| 3281 VariableDeclaration(zone_, proxy, mode, scope, pos, | 3282 VariableDeclaration(parser_zone_, proxy, mode, scope, pos, |
| 3282 is_class_declaration, declaration_group_start); | 3283 is_class_declaration, declaration_group_start); |
| 3283 } | 3284 } |
| 3284 | 3285 |
| 3285 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3286 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
| 3286 VariableMode mode, | 3287 VariableMode mode, |
| 3287 FunctionLiteral* fun, | 3288 FunctionLiteral* fun, |
| 3288 Scope* scope, | 3289 Scope* scope, |
| 3289 int pos) { | 3290 int pos) { |
| 3290 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); | 3291 return new (parser_zone_) |
| 3292 FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos); |
| 3291 } | 3293 } |
| 3292 | 3294 |
| 3293 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, | 3295 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, |
| 3294 const AstRawString* import_name, | 3296 const AstRawString* import_name, |
| 3295 const AstRawString* module_specifier, | 3297 const AstRawString* module_specifier, |
| 3296 Scope* scope, int pos) { | 3298 Scope* scope, int pos) { |
| 3297 return new (zone_) ImportDeclaration(zone_, proxy, import_name, | 3299 return new (parser_zone_) ImportDeclaration( |
| 3298 module_specifier, scope, pos); | 3300 parser_zone_, proxy, import_name, module_specifier, scope, pos); |
| 3299 } | 3301 } |
| 3300 | 3302 |
| 3301 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, | 3303 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, |
| 3302 Scope* scope, | 3304 Scope* scope, |
| 3303 int pos) { | 3305 int pos) { |
| 3304 return new (zone_) ExportDeclaration(zone_, proxy, scope, pos); | 3306 return new (parser_zone_) |
| 3307 ExportDeclaration(parser_zone_, proxy, scope, pos); |
| 3305 } | 3308 } |
| 3306 | 3309 |
| 3307 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, | 3310 Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity, |
| 3308 bool ignore_completion_value, int pos) { | 3311 bool ignore_completion_value, int pos) { |
| 3309 return new (zone_) | 3312 return new (local_zone_) |
| 3310 Block(zone_, labels, capacity, ignore_completion_value, pos); | 3313 Block(local_zone_, labels, capacity, ignore_completion_value, pos); |
| 3311 } | 3314 } |
| 3312 | 3315 |
| 3313 #define STATEMENT_WITH_LABELS(NodeType) \ | 3316 #define STATEMENT_WITH_LABELS(NodeType) \ |
| 3314 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 3317 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ |
| 3315 return new (zone_) NodeType(zone_, labels, pos); \ | 3318 return new (local_zone_) NodeType(local_zone_, labels, pos); \ |
| 3316 } | 3319 } |
| 3317 STATEMENT_WITH_LABELS(DoWhileStatement) | 3320 STATEMENT_WITH_LABELS(DoWhileStatement) |
| 3318 STATEMENT_WITH_LABELS(WhileStatement) | 3321 STATEMENT_WITH_LABELS(WhileStatement) |
| 3319 STATEMENT_WITH_LABELS(ForStatement) | 3322 STATEMENT_WITH_LABELS(ForStatement) |
| 3320 STATEMENT_WITH_LABELS(SwitchStatement) | 3323 STATEMENT_WITH_LABELS(SwitchStatement) |
| 3321 #undef STATEMENT_WITH_LABELS | 3324 #undef STATEMENT_WITH_LABELS |
| 3322 | 3325 |
| 3323 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, | 3326 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
| 3324 ZoneList<const AstRawString*>* labels, | 3327 ZoneList<const AstRawString*>* labels, |
| 3325 int pos) { | 3328 int pos) { |
| 3326 switch (visit_mode) { | 3329 switch (visit_mode) { |
| 3327 case ForEachStatement::ENUMERATE: { | 3330 case ForEachStatement::ENUMERATE: { |
| 3328 return new (zone_) ForInStatement(zone_, labels, pos); | 3331 return new (local_zone_) ForInStatement(local_zone_, labels, pos); |
| 3329 } | 3332 } |
| 3330 case ForEachStatement::ITERATE: { | 3333 case ForEachStatement::ITERATE: { |
| 3331 return new (zone_) ForOfStatement(zone_, labels, pos); | 3334 return new (local_zone_) ForOfStatement(local_zone_, labels, pos); |
| 3332 } | 3335 } |
| 3333 } | 3336 } |
| 3334 UNREACHABLE(); | 3337 UNREACHABLE(); |
| 3335 return NULL; | 3338 return NULL; |
| 3336 } | 3339 } |
| 3337 | 3340 |
| 3338 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { | 3341 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { |
| 3339 return new (zone_) ExpressionStatement(zone_, expression, pos); | 3342 return new (local_zone_) ExpressionStatement(local_zone_, expression, pos); |
| 3340 } | 3343 } |
| 3341 | 3344 |
| 3342 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { | 3345 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { |
| 3343 return new (zone_) ContinueStatement(zone_, target, pos); | 3346 return new (local_zone_) ContinueStatement(local_zone_, target, pos); |
| 3344 } | 3347 } |
| 3345 | 3348 |
| 3346 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 3349 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { |
| 3347 return new (zone_) BreakStatement(zone_, target, pos); | 3350 return new (local_zone_) BreakStatement(local_zone_, target, pos); |
| 3348 } | 3351 } |
| 3349 | 3352 |
| 3350 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { | 3353 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { |
| 3351 return new (zone_) ReturnStatement(zone_, expression, pos); | 3354 return new (local_zone_) ReturnStatement(local_zone_, expression, pos); |
| 3352 } | 3355 } |
| 3353 | 3356 |
| 3354 WithStatement* NewWithStatement(Scope* scope, | 3357 WithStatement* NewWithStatement(Scope* scope, |
| 3355 Expression* expression, | 3358 Expression* expression, |
| 3356 Statement* statement, | 3359 Statement* statement, |
| 3357 int pos) { | 3360 int pos) { |
| 3358 return new (zone_) WithStatement(zone_, scope, expression, statement, pos); | 3361 return new (local_zone_) |
| 3362 WithStatement(local_zone_, scope, expression, statement, pos); |
| 3359 } | 3363 } |
| 3360 | 3364 |
| 3361 IfStatement* NewIfStatement(Expression* condition, | 3365 IfStatement* NewIfStatement(Expression* condition, |
| 3362 Statement* then_statement, | 3366 Statement* then_statement, |
| 3363 Statement* else_statement, | 3367 Statement* else_statement, |
| 3364 int pos) { | 3368 int pos) { |
| 3365 return new (zone_) | 3369 return new (local_zone_) IfStatement(local_zone_, condition, then_statement, |
| 3366 IfStatement(zone_, condition, then_statement, else_statement, pos); | 3370 else_statement, pos); |
| 3367 } | 3371 } |
| 3368 | 3372 |
| 3369 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, | 3373 TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope, |
| 3370 Variable* variable, | 3374 Variable* variable, |
| 3371 Block* catch_block, int pos) { | 3375 Block* catch_block, int pos) { |
| 3372 return new (zone_) | 3376 return new (local_zone_) TryCatchStatement(local_zone_, try_block, scope, |
| 3373 TryCatchStatement(zone_, try_block, scope, variable, catch_block, pos); | 3377 variable, catch_block, pos); |
| 3374 } | 3378 } |
| 3375 | 3379 |
| 3376 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, | 3380 TryFinallyStatement* NewTryFinallyStatement(Block* try_block, |
| 3377 Block* finally_block, int pos) { | 3381 Block* finally_block, int pos) { |
| 3378 return new (zone_) | 3382 return new (local_zone_) |
| 3379 TryFinallyStatement(zone_, try_block, finally_block, pos); | 3383 TryFinallyStatement(local_zone_, try_block, finally_block, pos); |
| 3380 } | 3384 } |
| 3381 | 3385 |
| 3382 DebuggerStatement* NewDebuggerStatement(int pos) { | 3386 DebuggerStatement* NewDebuggerStatement(int pos) { |
| 3383 return new (zone_) DebuggerStatement(zone_, pos); | 3387 return new (local_zone_) DebuggerStatement(local_zone_, pos); |
| 3384 } | 3388 } |
| 3385 | 3389 |
| 3386 EmptyStatement* NewEmptyStatement(int pos) { | 3390 EmptyStatement* NewEmptyStatement(int pos) { |
| 3387 return new(zone_) EmptyStatement(zone_, pos); | 3391 return new (local_zone_) EmptyStatement(local_zone_, pos); |
| 3388 } | 3392 } |
| 3389 | 3393 |
| 3390 CaseClause* NewCaseClause( | 3394 CaseClause* NewCaseClause( |
| 3391 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3395 Expression* label, ZoneList<Statement*>* statements, int pos) { |
| 3392 return new (zone_) CaseClause(zone_, label, statements, pos); | 3396 return new (local_zone_) CaseClause(local_zone_, label, statements, pos); |
| 3393 } | 3397 } |
| 3394 | 3398 |
| 3395 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3399 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
| 3396 return new (zone_) | 3400 return new (local_zone_) |
| 3397 Literal(zone_, ast_value_factory_->NewString(string), pos); | 3401 Literal(local_zone_, ast_value_factory_->NewString(string), pos); |
| 3398 } | 3402 } |
| 3399 | 3403 |
| 3400 // A JavaScript symbol (ECMA-262 edition 6). | 3404 // A JavaScript symbol (ECMA-262 edition 6). |
| 3401 Literal* NewSymbolLiteral(const char* name, int pos) { | 3405 Literal* NewSymbolLiteral(const char* name, int pos) { |
| 3402 return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); | 3406 return new (local_zone_) |
| 3407 Literal(local_zone_, ast_value_factory_->NewSymbol(name), pos); |
| 3403 } | 3408 } |
| 3404 | 3409 |
| 3405 Literal* NewNumberLiteral(double number, int pos, bool with_dot = false) { | 3410 Literal* NewNumberLiteral(double number, int pos, bool with_dot = false) { |
| 3406 return new (zone_) | 3411 return new (local_zone_) Literal( |
| 3407 Literal(zone_, ast_value_factory_->NewNumber(number, with_dot), pos); | 3412 local_zone_, ast_value_factory_->NewNumber(number, with_dot), pos); |
| 3408 } | 3413 } |
| 3409 | 3414 |
| 3410 Literal* NewSmiLiteral(int number, int pos) { | 3415 Literal* NewSmiLiteral(int number, int pos) { |
| 3411 return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); | 3416 return new (local_zone_) |
| 3417 Literal(local_zone_, ast_value_factory_->NewSmi(number), pos); |
| 3412 } | 3418 } |
| 3413 | 3419 |
| 3414 Literal* NewBooleanLiteral(bool b, int pos) { | 3420 Literal* NewBooleanLiteral(bool b, int pos) { |
| 3415 return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); | 3421 return new (local_zone_) |
| 3422 Literal(local_zone_, ast_value_factory_->NewBoolean(b), pos); |
| 3416 } | 3423 } |
| 3417 | 3424 |
| 3418 Literal* NewNullLiteral(int pos) { | 3425 Literal* NewNullLiteral(int pos) { |
| 3419 return new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); | 3426 return new (local_zone_) |
| 3427 Literal(local_zone_, ast_value_factory_->NewNull(), pos); |
| 3420 } | 3428 } |
| 3421 | 3429 |
| 3422 Literal* NewUndefinedLiteral(int pos) { | 3430 Literal* NewUndefinedLiteral(int pos) { |
| 3423 return new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); | 3431 return new (local_zone_) |
| 3432 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); |
| 3424 } | 3433 } |
| 3425 | 3434 |
| 3426 Literal* NewTheHoleLiteral(int pos) { | 3435 Literal* NewTheHoleLiteral(int pos) { |
| 3427 return new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); | 3436 return new (local_zone_) |
| 3437 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); |
| 3428 } | 3438 } |
| 3429 | 3439 |
| 3430 ObjectLiteral* NewObjectLiteral( | 3440 ObjectLiteral* NewObjectLiteral( |
| 3431 ZoneList<ObjectLiteral::Property*>* properties, | 3441 ZoneList<ObjectLiteral::Property*>* properties, |
| 3432 int literal_index, | 3442 int literal_index, |
| 3433 int boilerplate_properties, | 3443 int boilerplate_properties, |
| 3434 bool has_function, | 3444 bool has_function, |
| 3435 bool is_strong, | 3445 bool is_strong, |
| 3436 int pos) { | 3446 int pos) { |
| 3437 return new (zone_) ObjectLiteral(zone_, properties, literal_index, | 3447 return new (local_zone_) |
| 3438 boilerplate_properties, has_function, | 3448 ObjectLiteral(local_zone_, properties, literal_index, |
| 3439 is_strong, pos); | 3449 boilerplate_properties, has_function, is_strong, pos); |
| 3440 } | 3450 } |
| 3441 | 3451 |
| 3442 ObjectLiteral::Property* NewObjectLiteralProperty( | 3452 ObjectLiteral::Property* NewObjectLiteralProperty( |
| 3443 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3453 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
| 3444 bool is_static, bool is_computed_name) { | 3454 bool is_static, bool is_computed_name) { |
| 3445 return new (zone_) | 3455 return new (local_zone_) |
| 3446 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); | 3456 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); |
| 3447 } | 3457 } |
| 3448 | 3458 |
| 3449 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, | 3459 ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key, |
| 3450 Expression* value, | 3460 Expression* value, |
| 3451 bool is_static, | 3461 bool is_static, |
| 3452 bool is_computed_name) { | 3462 bool is_computed_name) { |
| 3453 return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value, | 3463 return new (local_zone_) ObjectLiteral::Property( |
| 3454 is_static, is_computed_name); | 3464 ast_value_factory_, key, value, is_static, is_computed_name); |
| 3455 } | 3465 } |
| 3456 | 3466 |
| 3457 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, | 3467 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, |
| 3458 const AstRawString* flags, | 3468 const AstRawString* flags, |
| 3459 int literal_index, | 3469 int literal_index, |
| 3460 bool is_strong, | 3470 bool is_strong, |
| 3461 int pos) { | 3471 int pos) { |
| 3462 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, | 3472 return new (local_zone_) RegExpLiteral(local_zone_, pattern, flags, |
| 3463 is_strong, pos); | 3473 literal_index, is_strong, pos); |
| 3464 } | 3474 } |
| 3465 | 3475 |
| 3466 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3476 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3467 int literal_index, | 3477 int literal_index, |
| 3468 bool is_strong, | 3478 bool is_strong, |
| 3469 int pos) { | 3479 int pos) { |
| 3470 return new (zone_) | 3480 return new (local_zone_) |
| 3471 ArrayLiteral(zone_, values, -1, literal_index, is_strong, pos); | 3481 ArrayLiteral(local_zone_, values, -1, literal_index, is_strong, pos); |
| 3472 } | 3482 } |
| 3473 | 3483 |
| 3474 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3484 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3475 int first_spread_index, int literal_index, | 3485 int first_spread_index, int literal_index, |
| 3476 bool is_strong, int pos) { | 3486 bool is_strong, int pos) { |
| 3477 return new (zone_) ArrayLiteral(zone_, values, first_spread_index, | 3487 return new (local_zone_) ArrayLiteral( |
| 3478 literal_index, is_strong, pos); | 3488 local_zone_, values, first_spread_index, literal_index, is_strong, pos); |
| 3479 } | 3489 } |
| 3480 | 3490 |
| 3481 VariableProxy* NewVariableProxy(Variable* var, | 3491 VariableProxy* NewVariableProxy(Variable* var, |
| 3482 int start_position = RelocInfo::kNoPosition, | 3492 int start_position = RelocInfo::kNoPosition, |
| 3483 int end_position = RelocInfo::kNoPosition) { | 3493 int end_position = RelocInfo::kNoPosition) { |
| 3484 return new (zone_) VariableProxy(zone_, var, start_position, end_position); | 3494 return new (parser_zone_) |
| 3495 VariableProxy(parser_zone_, var, start_position, end_position); |
| 3485 } | 3496 } |
| 3486 | 3497 |
| 3487 VariableProxy* NewVariableProxy(const AstRawString* name, | 3498 VariableProxy* NewVariableProxy(const AstRawString* name, |
| 3488 Variable::Kind variable_kind, | 3499 Variable::Kind variable_kind, |
| 3489 int start_position = RelocInfo::kNoPosition, | 3500 int start_position = RelocInfo::kNoPosition, |
| 3490 int end_position = RelocInfo::kNoPosition) { | 3501 int end_position = RelocInfo::kNoPosition) { |
| 3491 DCHECK_NOT_NULL(name); | 3502 DCHECK_NOT_NULL(name); |
| 3492 return new (zone_) | 3503 return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind, |
| 3493 VariableProxy(zone_, name, variable_kind, start_position, end_position); | 3504 start_position, end_position); |
| 3494 } | 3505 } |
| 3495 | 3506 |
| 3496 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3507 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
| 3497 return new (zone_) Property(zone_, obj, key, pos); | 3508 return new (local_zone_) Property(local_zone_, obj, key, pos); |
| 3498 } | 3509 } |
| 3499 | 3510 |
| 3500 Call* NewCall(Expression* expression, | 3511 Call* NewCall(Expression* expression, |
| 3501 ZoneList<Expression*>* arguments, | 3512 ZoneList<Expression*>* arguments, |
| 3502 int pos) { | 3513 int pos) { |
| 3503 return new (zone_) Call(zone_, expression, arguments, pos); | 3514 return new (local_zone_) Call(local_zone_, expression, arguments, pos); |
| 3504 } | 3515 } |
| 3505 | 3516 |
| 3506 CallNew* NewCallNew(Expression* expression, | 3517 CallNew* NewCallNew(Expression* expression, |
| 3507 ZoneList<Expression*>* arguments, | 3518 ZoneList<Expression*>* arguments, |
| 3508 int pos) { | 3519 int pos) { |
| 3509 return new (zone_) CallNew(zone_, expression, arguments, pos); | 3520 return new (local_zone_) CallNew(local_zone_, expression, arguments, pos); |
| 3510 } | 3521 } |
| 3511 | 3522 |
| 3512 CallRuntime* NewCallRuntime(const AstRawString* name, | 3523 CallRuntime* NewCallRuntime(const AstRawString* name, |
| 3513 const Runtime::Function* function, | 3524 const Runtime::Function* function, |
| 3514 ZoneList<Expression*>* arguments, | 3525 ZoneList<Expression*>* arguments, |
| 3515 int pos) { | 3526 int pos) { |
| 3516 return new (zone_) CallRuntime(zone_, name, function, arguments, pos); | 3527 return new (local_zone_) |
| 3528 CallRuntime(local_zone_, name, function, arguments, pos); |
| 3517 } | 3529 } |
| 3518 | 3530 |
| 3519 UnaryOperation* NewUnaryOperation(Token::Value op, | 3531 UnaryOperation* NewUnaryOperation(Token::Value op, |
| 3520 Expression* expression, | 3532 Expression* expression, |
| 3521 int pos) { | 3533 int pos) { |
| 3522 return new (zone_) UnaryOperation(zone_, op, expression, pos); | 3534 return new (local_zone_) UnaryOperation(local_zone_, op, expression, pos); |
| 3523 } | 3535 } |
| 3524 | 3536 |
| 3525 BinaryOperation* NewBinaryOperation(Token::Value op, | 3537 BinaryOperation* NewBinaryOperation(Token::Value op, |
| 3526 Expression* left, | 3538 Expression* left, |
| 3527 Expression* right, | 3539 Expression* right, |
| 3528 int pos) { | 3540 int pos) { |
| 3529 return new (zone_) BinaryOperation(zone_, op, left, right, pos); | 3541 return new (local_zone_) BinaryOperation(local_zone_, op, left, right, pos); |
| 3530 } | 3542 } |
| 3531 | 3543 |
| 3532 CountOperation* NewCountOperation(Token::Value op, | 3544 CountOperation* NewCountOperation(Token::Value op, |
| 3533 bool is_prefix, | 3545 bool is_prefix, |
| 3534 Expression* expr, | 3546 Expression* expr, |
| 3535 int pos) { | 3547 int pos) { |
| 3536 return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); | 3548 return new (local_zone_) |
| 3549 CountOperation(local_zone_, op, is_prefix, expr, pos); |
| 3537 } | 3550 } |
| 3538 | 3551 |
| 3539 CompareOperation* NewCompareOperation(Token::Value op, | 3552 CompareOperation* NewCompareOperation(Token::Value op, |
| 3540 Expression* left, | 3553 Expression* left, |
| 3541 Expression* right, | 3554 Expression* right, |
| 3542 int pos) { | 3555 int pos) { |
| 3543 return new (zone_) CompareOperation(zone_, op, left, right, pos); | 3556 return new (local_zone_) |
| 3557 CompareOperation(local_zone_, op, left, right, pos); |
| 3544 } | 3558 } |
| 3545 | 3559 |
| 3546 Spread* NewSpread(Expression* expression, int pos) { | 3560 Spread* NewSpread(Expression* expression, int pos) { |
| 3547 return new (zone_) Spread(zone_, expression, pos); | 3561 return new (local_zone_) Spread(local_zone_, expression, pos); |
| 3548 } | 3562 } |
| 3549 | 3563 |
| 3550 Conditional* NewConditional(Expression* condition, | 3564 Conditional* NewConditional(Expression* condition, |
| 3551 Expression* then_expression, | 3565 Expression* then_expression, |
| 3552 Expression* else_expression, | 3566 Expression* else_expression, |
| 3553 int position) { | 3567 int position) { |
| 3554 return new (zone_) Conditional(zone_, condition, then_expression, | 3568 return new (local_zone_) Conditional( |
| 3555 else_expression, position); | 3569 local_zone_, condition, then_expression, else_expression, position); |
| 3556 } | 3570 } |
| 3557 | 3571 |
| 3558 Assignment* NewAssignment(Token::Value op, | 3572 Assignment* NewAssignment(Token::Value op, |
| 3559 Expression* target, | 3573 Expression* target, |
| 3560 Expression* value, | 3574 Expression* value, |
| 3561 int pos) { | 3575 int pos) { |
| 3562 DCHECK(Token::IsAssignmentOp(op)); | 3576 DCHECK(Token::IsAssignmentOp(op)); |
| 3563 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); | 3577 Assignment* assign = |
| 3578 new (local_zone_) Assignment(local_zone_, op, target, value, pos); |
| 3564 if (assign->is_compound()) { | 3579 if (assign->is_compound()) { |
| 3565 DCHECK(Token::IsAssignmentOp(op)); | 3580 DCHECK(Token::IsAssignmentOp(op)); |
| 3566 assign->binary_operation_ = | 3581 assign->binary_operation_ = |
| 3567 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); | 3582 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); |
| 3568 } | 3583 } |
| 3569 return assign; | 3584 return assign; |
| 3570 } | 3585 } |
| 3571 | 3586 |
| 3572 Yield* NewYield(Expression *generator_object, | 3587 Yield* NewYield(Expression *generator_object, |
| 3573 Expression* expression, | 3588 Expression* expression, |
| 3574 Yield::Kind yield_kind, | 3589 Yield::Kind yield_kind, |
| 3575 int pos) { | 3590 int pos) { |
| 3576 if (!expression) expression = NewUndefinedLiteral(pos); | 3591 if (!expression) expression = NewUndefinedLiteral(pos); |
| 3577 return new (zone_) | 3592 return new (local_zone_) |
| 3578 Yield(zone_, generator_object, expression, yield_kind, pos); | 3593 Yield(local_zone_, generator_object, expression, yield_kind, pos); |
| 3579 } | 3594 } |
| 3580 | 3595 |
| 3581 Throw* NewThrow(Expression* exception, int pos) { | 3596 Throw* NewThrow(Expression* exception, int pos) { |
| 3582 return new (zone_) Throw(zone_, exception, pos); | 3597 return new (local_zone_) Throw(local_zone_, exception, pos); |
| 3583 } | 3598 } |
| 3584 | 3599 |
| 3585 FunctionLiteral* NewFunctionLiteral( | 3600 FunctionLiteral* NewFunctionLiteral( |
| 3586 const AstRawString* name, AstValueFactory* ast_value_factory, | 3601 const AstRawString* name, AstValueFactory* ast_value_factory, |
| 3587 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, | 3602 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, |
| 3588 int expected_property_count, int parameter_count, | 3603 int expected_property_count, int parameter_count, |
| 3589 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3604 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 3590 FunctionLiteral::FunctionType function_type, | 3605 FunctionLiteral::FunctionType function_type, |
| 3591 FunctionLiteral::IsFunctionFlag is_function, | 3606 FunctionLiteral::IsFunctionFlag is_function, |
| 3592 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, | 3607 FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind, |
| 3593 int position) { | 3608 int position) { |
| 3594 return new (zone_) FunctionLiteral( | 3609 return new (parser_zone_) FunctionLiteral( |
| 3595 zone_, name, ast_value_factory, scope, body, materialized_literal_count, | 3610 parser_zone_, name, ast_value_factory, scope, body, |
| 3596 expected_property_count, parameter_count, function_type, | 3611 materialized_literal_count, expected_property_count, parameter_count, |
| 3597 has_duplicate_parameters, is_function, eager_compile_hint, kind, | 3612 function_type, has_duplicate_parameters, is_function, |
| 3598 position); | 3613 eager_compile_hint, kind, position); |
| 3599 } | 3614 } |
| 3600 | 3615 |
| 3601 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, | 3616 ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope, |
| 3602 VariableProxy* proxy, Expression* extends, | 3617 VariableProxy* proxy, Expression* extends, |
| 3603 FunctionLiteral* constructor, | 3618 FunctionLiteral* constructor, |
| 3604 ZoneList<ObjectLiteral::Property*>* properties, | 3619 ZoneList<ObjectLiteral::Property*>* properties, |
| 3605 int start_position, int end_position) { | 3620 int start_position, int end_position) { |
| 3606 return new (zone_) | 3621 return new (parser_zone_) |
| 3607 ClassLiteral(zone_, name, scope, proxy, extends, constructor, | 3622 ClassLiteral(parser_zone_, name, scope, proxy, extends, constructor, |
| 3608 properties, start_position, end_position); | 3623 properties, start_position, end_position); |
| 3609 } | 3624 } |
| 3610 | 3625 |
| 3611 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3626 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
| 3612 v8::Extension* extension, | 3627 v8::Extension* extension, |
| 3613 int pos) { | 3628 int pos) { |
| 3614 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); | 3629 return new (parser_zone_) |
| 3630 NativeFunctionLiteral(parser_zone_, name, extension, pos); |
| 3615 } | 3631 } |
| 3616 | 3632 |
| 3617 ThisFunction* NewThisFunction(int pos) { | 3633 ThisFunction* NewThisFunction(int pos) { |
| 3618 return new (zone_) ThisFunction(zone_, pos); | 3634 return new (local_zone_) ThisFunction(local_zone_, pos); |
| 3619 } | 3635 } |
| 3620 | 3636 |
| 3621 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, | 3637 SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var, |
| 3622 Expression* home_object, | 3638 Expression* home_object, |
| 3623 int pos) { | 3639 int pos) { |
| 3624 return new (zone_) | 3640 return new (parser_zone_) |
| 3625 SuperPropertyReference(zone_, this_var, home_object, pos); | 3641 SuperPropertyReference(parser_zone_, this_var, home_object, pos); |
| 3626 } | 3642 } |
| 3627 | 3643 |
| 3628 SuperCallReference* NewSuperCallReference(VariableProxy* this_var, | 3644 SuperCallReference* NewSuperCallReference(VariableProxy* this_var, |
| 3629 VariableProxy* new_target_var, | 3645 VariableProxy* new_target_var, |
| 3630 VariableProxy* this_function_var, | 3646 VariableProxy* this_function_var, |
| 3631 int pos) { | 3647 int pos) { |
| 3632 return new (zone_) SuperCallReference(zone_, this_var, new_target_var, | 3648 return new (parser_zone_) SuperCallReference( |
| 3633 this_function_var, pos); | 3649 parser_zone_, this_var, new_target_var, this_function_var, pos); |
| 3634 } | 3650 } |
| 3635 | 3651 |
| 3652 Zone* zone() const { return local_zone_; } |
| 3653 |
| 3654 // Handles use of temporary zones when parsing inner function bodies. |
| 3655 class BodyScope { |
| 3656 public: |
| 3657 BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone) |
| 3658 : factory_(factory), prev_zone_(factory->local_zone_) { |
| 3659 if (use_temp_zone) { |
| 3660 factory->local_zone_ = temp_zone; |
| 3661 } |
| 3662 } |
| 3663 |
| 3664 ~BodyScope() { factory_->local_zone_ = prev_zone_; } |
| 3665 |
| 3666 private: |
| 3667 AstNodeFactory* factory_; |
| 3668 Zone* prev_zone_; |
| 3669 }; |
| 3670 |
| 3636 private: | 3671 private: |
| 3637 Zone* zone_; | 3672 // This zone may be deallocated upon returning from parsing a function body |
| 3673 // which we can guarantee is not going to be compiled or have its AST |
| 3674 // inspected. |
| 3675 // See ParseFunctionLiteral in parser.cc for preconditions. |
| 3676 Zone* local_zone_; |
| 3677 // ZoneObjects which need to persist until scope analysis must be allocated in |
| 3678 // the parser-level zone. |
| 3679 Zone* parser_zone_; |
| 3638 AstValueFactory* ast_value_factory_; | 3680 AstValueFactory* ast_value_factory_; |
| 3639 }; | 3681 }; |
| 3640 | 3682 |
| 3641 | 3683 |
| 3642 } } // namespace v8::internal | 3684 } } // namespace v8::internal |
| 3643 | 3685 |
| 3644 #endif // V8_AST_H_ | 3686 #endif // V8_AST_H_ |
| OLD | NEW |