OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/parser.h" | 5 #include "vm/parser.h" |
6 #include "vm/flags.h" | 6 #include "vm/flags.h" |
7 | 7 |
8 #ifndef DART_PRECOMPILED_RUNTIME | 8 #ifndef DART_PRECOMPILED_RUNTIME |
9 | 9 |
10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "vm/hash_table.h" | 21 #include "vm/hash_table.h" |
22 #include "vm/heap.h" | 22 #include "vm/heap.h" |
23 #include "vm/isolate.h" | 23 #include "vm/isolate.h" |
24 #include "vm/kernel_binary_flowgraph.h" | 24 #include "vm/kernel_binary_flowgraph.h" |
25 #include "vm/longjump.h" | 25 #include "vm/longjump.h" |
26 #include "vm/native_arguments.h" | 26 #include "vm/native_arguments.h" |
27 #include "vm/native_entry.h" | 27 #include "vm/native_entry.h" |
28 #include "vm/object.h" | 28 #include "vm/object.h" |
29 #include "vm/object_store.h" | 29 #include "vm/object_store.h" |
30 #include "vm/os.h" | 30 #include "vm/os.h" |
| 31 #include "vm/precompiler.h" |
31 #include "vm/regexp_assembler.h" | 32 #include "vm/regexp_assembler.h" |
32 #include "vm/resolver.h" | 33 #include "vm/resolver.h" |
33 #include "vm/safepoint.h" | 34 #include "vm/safepoint.h" |
34 #include "vm/scanner.h" | 35 #include "vm/scanner.h" |
35 #include "vm/scopes.h" | 36 #include "vm/scopes.h" |
36 #include "vm/stack_frame.h" | 37 #include "vm/stack_frame.h" |
37 #include "vm/symbols.h" | 38 #include "vm/symbols.h" |
38 #include "vm/tags.h" | 39 #include "vm/tags.h" |
39 #include "vm/timeline.h" | 40 #include "vm/timeline.h" |
40 #include "vm/timer.h" | 41 #include "vm/timer.h" |
(...skipping 6225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6266 ExpectToken(Token::kLPAREN); | 6267 ExpectToken(Token::kLPAREN); |
6267 // Parse dotted name. | 6268 // Parse dotted name. |
6268 const GrowableObjectArray& pieces = GrowableObjectArray::Handle( | 6269 const GrowableObjectArray& pieces = GrowableObjectArray::Handle( |
6269 Z, GrowableObjectArray::New(allocation_space_)); | 6270 Z, GrowableObjectArray::New(allocation_space_)); |
6270 pieces.Add(*ExpectIdentifier("identifier expected"), allocation_space_); | 6271 pieces.Add(*ExpectIdentifier("identifier expected"), allocation_space_); |
6271 while (CurrentToken() == Token::kPERIOD) { | 6272 while (CurrentToken() == Token::kPERIOD) { |
6272 pieces.Add(Symbols::Dot(), allocation_space_); | 6273 pieces.Add(Symbols::Dot(), allocation_space_); |
6273 ConsumeToken(); | 6274 ConsumeToken(); |
6274 pieces.Add(*ExpectIdentifier("identifier expected"), allocation_space_); | 6275 pieces.Add(*ExpectIdentifier("identifier expected"), allocation_space_); |
6275 } | 6276 } |
| 6277 if (I->obfuscate()) { |
| 6278 // If we are obfuscating then we need to deobfuscate environment name. |
| 6279 Obfuscator::Deobfuscate(T, pieces); |
| 6280 } |
6276 AstNode* valueNode = NULL; | 6281 AstNode* valueNode = NULL; |
6277 if (CurrentToken() == Token::kEQ) { | 6282 if (CurrentToken() == Token::kEQ) { |
6278 ConsumeToken(); | 6283 ConsumeToken(); |
6279 CheckToken(Token::kSTRING, "string literal expected"); | 6284 CheckToken(Token::kSTRING, "string literal expected"); |
6280 valueNode = ParseStringLiteral(false); | 6285 valueNode = ParseStringLiteral(false); |
6281 ASSERT(valueNode->IsLiteralNode()); | 6286 ASSERT(valueNode->IsLiteralNode()); |
6282 ASSERT(valueNode->AsLiteralNode()->literal().IsString()); | 6287 ASSERT(valueNode->AsLiteralNode()->literal().IsString()); |
6283 } | 6288 } |
6284 ExpectToken(Token::kRPAREN); | 6289 ExpectToken(Token::kRPAREN); |
6285 CheckToken(Token::kSTRING, "library url expected"); | 6290 CheckToken(Token::kSTRING, "library url expected"); |
(...skipping 6358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12644 return NULL; | 12649 return NULL; |
12645 } | 12650 } |
12646 ASSERT(getter.kind() == RawFunction::kImplicitGetter); | 12651 ASSERT(getter.kind() == RawFunction::kImplicitGetter); |
12647 return new (Z) StaticGetterNode(field_ref_pos, NULL, field_owner, field_name); | 12652 return new (Z) StaticGetterNode(field_ref_pos, NULL, field_owner, field_name); |
12648 } | 12653 } |
12649 | 12654 |
12650 RawObject* Parser::EvaluateConstConstructorCall( | 12655 RawObject* Parser::EvaluateConstConstructorCall( |
12651 const Class& type_class, | 12656 const Class& type_class, |
12652 const TypeArguments& type_arguments, | 12657 const TypeArguments& type_arguments, |
12653 const Function& constructor, | 12658 const Function& constructor, |
12654 ArgumentListNode* arguments) { | 12659 ArgumentListNode* arguments, |
| 12660 bool obfuscate_symbol_instances /* = true */) { |
12655 NoReloadScope no_reload_scope(isolate(), thread()); | 12661 NoReloadScope no_reload_scope(isolate(), thread()); |
12656 NoOOBMessageScope no_msg_scope(thread()); | 12662 NoOOBMessageScope no_msg_scope(thread()); |
12657 // Factories and constructors are not generic functions. | 12663 // Factories and constructors are not generic functions. |
12658 const int kTypeArgsLen = 0; | 12664 const int kTypeArgsLen = 0; |
12659 // Factories have one extra argument: the type arguments. | 12665 // Factories have one extra argument: the type arguments. |
12660 // Constructors have one extra arguments: receiver. | 12666 // Constructors have one extra arguments: receiver. |
12661 const int kNumExtraArgs = 1; | 12667 const int kNumExtraArgs = 1; |
12662 const int num_arguments = arguments->length() + kNumExtraArgs; | 12668 const int num_arguments = arguments->length() + kNumExtraArgs; |
12663 const Array& arg_values = | 12669 const Array& arg_values = |
12664 Array::Handle(Z, Array::New(num_arguments, allocation_space_)); | 12670 Array::Handle(Z, Array::New(num_arguments, allocation_space_)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12699 } else { | 12705 } else { |
12700 thread()->long_jump_base()->Jump(1, Error::Cast(result)); | 12706 thread()->long_jump_base()->Jump(1, Error::Cast(result)); |
12701 UNREACHABLE(); | 12707 UNREACHABLE(); |
12702 return Object::null(); | 12708 return Object::null(); |
12703 } | 12709 } |
12704 } else { | 12710 } else { |
12705 if (constructor.IsFactory()) { | 12711 if (constructor.IsFactory()) { |
12706 // The factory method returns the allocated object. | 12712 // The factory method returns the allocated object. |
12707 instance ^= result.raw(); | 12713 instance ^= result.raw(); |
12708 } | 12714 } |
| 12715 if (obfuscate_symbol_instances && I->obfuscate() && |
| 12716 (instance.clazz() == I->object_store()->symbol_class())) { |
| 12717 Obfuscator::ObfuscateSymbolInstance(T, instance); |
| 12718 } |
12709 return TryCanonicalize(instance, TokenPos()); | 12719 return TryCanonicalize(instance, TokenPos()); |
12710 } | 12720 } |
12711 } | 12721 } |
12712 | 12722 |
12713 // Do a lookup for the identifier in the block scope and the class scope | 12723 // Do a lookup for the identifier in the block scope and the class scope |
12714 // return true if the identifier is found, false otherwise. | 12724 // return true if the identifier is found, false otherwise. |
12715 // If node is non NULL return an AST node corresponding to the identifier. | 12725 // If node is non NULL return an AST node corresponding to the identifier. |
12716 bool Parser::ResolveIdentInLocalScope(TokenPosition ident_pos, | 12726 bool Parser::ResolveIdentInLocalScope(TokenPosition ident_pos, |
12717 const String& ident, | 12727 const String& ident, |
12718 AstNode** node, | 12728 AstNode** node, |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13761 } | 13771 } |
13762 | 13772 |
13763 // Call Symbol class constructor to create a symbol instance. | 13773 // Call Symbol class constructor to create a symbol instance. |
13764 const Class& symbol_class = Class::Handle(I->object_store()->symbol_class()); | 13774 const Class& symbol_class = Class::Handle(I->object_store()->symbol_class()); |
13765 ASSERT(!symbol_class.IsNull()); | 13775 ASSERT(!symbol_class.IsNull()); |
13766 ArgumentListNode* constr_args = new (Z) ArgumentListNode(symbol_pos); | 13776 ArgumentListNode* constr_args = new (Z) ArgumentListNode(symbol_pos); |
13767 constr_args->Add(new (Z) LiteralNode(symbol_pos, symbol)); | 13777 constr_args->Add(new (Z) LiteralNode(symbol_pos, symbol)); |
13768 const Function& constr = Function::ZoneHandle( | 13778 const Function& constr = Function::ZoneHandle( |
13769 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor())); | 13779 Z, symbol_class.LookupConstructor(Symbols::SymbolCtor())); |
13770 ASSERT(!constr.IsNull()); | 13780 ASSERT(!constr.IsNull()); |
13771 const Object& result = Object::Handle( | 13781 const Object& result = |
13772 Z, EvaluateConstConstructorCall(symbol_class, TypeArguments::Handle(Z), | 13782 Object::Handle(Z, EvaluateConstConstructorCall( |
13773 constr, constr_args)); | 13783 symbol_class, TypeArguments::Handle(Z), constr, |
| 13784 constr_args, /*obfuscate_symbol_instances=*/false)); |
13774 if (result.IsUnhandledException()) { | 13785 if (result.IsUnhandledException()) { |
13775 ReportErrors(Error::Cast(result), script_, symbol_pos, | 13786 ReportErrors(Error::Cast(result), script_, symbol_pos, |
13776 "error executing const Symbol constructor"); | 13787 "error executing const Symbol constructor"); |
13777 } | 13788 } |
13778 symbol_instance ^= result.raw(); | 13789 symbol_instance ^= result.raw(); |
13779 CacheConstantValue(symbol_pos, symbol_instance); | 13790 CacheConstantValue(symbol_pos, symbol_instance); |
13780 return new (Z) LiteralNode(symbol_pos, symbol_instance); | 13791 return new (Z) LiteralNode(symbol_pos, symbol_instance); |
13781 } | 13792 } |
13782 | 13793 |
13783 RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr, | 13794 RawFunction* Parser::BuildConstructorClosureFunction(const Function& ctr, |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15102 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, | 15113 bool Parser::FieldHasFunctionLiteralInitializer(const Field& field, |
15103 TokenPosition* start, | 15114 TokenPosition* start, |
15104 TokenPosition* end) { | 15115 TokenPosition* end) { |
15105 UNREACHABLE(); | 15116 UNREACHABLE(); |
15106 return false; | 15117 return false; |
15107 } | 15118 } |
15108 | 15119 |
15109 } // namespace dart | 15120 } // namespace dart |
15110 | 15121 |
15111 #endif // DART_PRECOMPILED_RUNTIME | 15122 #endif // DART_PRECOMPILED_RUNTIME |
OLD | NEW |