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 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/compiler_stats.h" | 10 #include "vm/compiler_stats.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); | 24 DEFINE_FLAG(bool, enable_asserts, false, "Enable assert statements."); |
25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); | 25 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); |
26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); | 26 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); | 27 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); |
28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); | 28 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); |
29 | 29 |
30 // All references to Dart names are listed here. | 30 // All references to Dart names are listed here. |
31 static const char* kAssertionErrorName = "AssertionError"; | 31 static const char* kAssertionErrorName = "AssertionError"; |
32 static const char* kFallThroughErrorName = "FallThroughError"; | 32 static const char* kFallThroughErrorName = "FallThroughError"; |
| 33 static const char* kStaticResolutionExceptionName = "StaticResolutionException"; |
33 static const char* kThrowNewName = "_throwNew"; | 34 static const char* kThrowNewName = "_throwNew"; |
34 static const char* kListLiteralFactoryClassName = "_ListLiteralFactory"; | 35 static const char* kListLiteralFactoryClassName = "_ListLiteralFactory"; |
35 static const char* kListLiteralFactoryName = "List.fromLiteral"; | 36 static const char* kListLiteralFactoryName = "List.fromLiteral"; |
36 static const char* kMapLiteralFactoryClassName = "_MapLiteralFactory"; | 37 static const char* kMapLiteralFactoryClassName = "_MapLiteralFactory"; |
37 static const char* kMapLiteralFactoryName = "Map.fromLiteral"; | 38 static const char* kMapLiteralFactoryName = "Map.fromLiteral"; |
38 static const char* kImmutableMapName = "ImmutableMap"; | 39 static const char* kImmutableMapName = "ImmutableMap"; |
39 static const char* kImmutableMapConstructorName = "ImmutableMap._create"; | 40 static const char* kImmutableMapConstructorName = "ImmutableMap._create"; |
40 static const char* kStringClassName = "StringBase"; | 41 static const char* kStringClassName = "StringBase"; |
41 static const char* kInterpolateName = "_interpolate"; | 42 static const char* kInterpolateName = "_interpolate"; |
42 static const char* kThisName = "this"; | 43 static const char* kThisName = "this"; |
(...skipping 5742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5785 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); | 5786 ASSERT(func.kind() != RawFunction::kConstImplicitGetter); |
5786 closure = new StaticGetterNode(call_pos, | 5787 closure = new StaticGetterNode(call_pos, |
5787 Class::ZoneHandle(cls.raw()), | 5788 Class::ZoneHandle(cls.raw()), |
5788 func_name); | 5789 func_name); |
5789 return new ClosureCallNode(call_pos, closure, arguments); | 5790 return new ClosureCallNode(call_pos, closure, arguments); |
5790 } | 5791 } |
5791 } else { | 5792 } else { |
5792 closure = GenerateStaticFieldLookup(field, call_pos); | 5793 closure = GenerateStaticFieldLookup(field, call_pos); |
5793 return new ClosureCallNode(call_pos, closure, arguments); | 5794 return new ClosureCallNode(call_pos, closure, arguments); |
5794 } | 5795 } |
5795 ErrorMsg(ident_pos, "unresolved static method '%s'", func_name.ToCString()); | 5796 // Could not resolve static method: throw an exception if the arguments |
| 5797 // do not match or compile time error otherwise. |
| 5798 const Function& test_func = Function::Handle( |
| 5799 Resolver::ResolveStaticByName(cls, func_name, Resolver::kIsQualified)); |
| 5800 if (test_func.IsNull()) { |
| 5801 ErrorMsg(ident_pos, "unresolved static method '%s'", |
| 5802 func_name.ToCString()); |
| 5803 } else { |
| 5804 ArgumentListNode* arguments = new ArgumentListNode(ident_pos); |
| 5805 arguments->Add(new LiteralNode( |
| 5806 token_index_, Integer::ZoneHandle(Integer::New(ident_pos)))); |
| 5807 return MakeStaticCall(kStaticResolutionExceptionName, |
| 5808 kThrowNewName, |
| 5809 arguments); |
| 5810 } |
5796 } | 5811 } |
5797 CheckFunctionIsCallable(call_pos, func); | 5812 CheckFunctionIsCallable(call_pos, func); |
5798 return new StaticCallNode(call_pos, func, arguments); | 5813 return new StaticCallNode(call_pos, func, arguments); |
5799 } | 5814 } |
5800 | 5815 |
5801 | 5816 |
5802 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { | 5817 AstNode* Parser::ParseInstanceCall(AstNode* receiver, const String& func_name) { |
5803 const intptr_t call_pos = token_index_; | 5818 const intptr_t call_pos = token_index_; |
5804 if (CurrentToken() != Token::kLPAREN) { | 5819 if (CurrentToken() != Token::kLPAREN) { |
5805 ErrorMsg(call_pos, "left parenthesis expected"); | 5820 ErrorMsg(call_pos, "left parenthesis expected"); |
(...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7767 void Parser::SkipQualIdent() { | 7782 void Parser::SkipQualIdent() { |
7768 ASSERT(IsIdentifier()); | 7783 ASSERT(IsIdentifier()); |
7769 ConsumeToken(); | 7784 ConsumeToken(); |
7770 if (CurrentToken() == Token::kPERIOD) { | 7785 if (CurrentToken() == Token::kPERIOD) { |
7771 ConsumeToken(); // Consume the kPERIOD token. | 7786 ConsumeToken(); // Consume the kPERIOD token. |
7772 ExpectIdentifier("identifier expected after '.'"); | 7787 ExpectIdentifier("identifier expected after '.'"); |
7773 } | 7788 } |
7774 } | 7789 } |
7775 | 7790 |
7776 } // namespace dart | 7791 } // namespace dart |
OLD | NEW |