| 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 "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 10052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10063 expr = ResolveIdent(TokenPos(), *CurrentLiteral(), true); | 10063 expr = ResolveIdent(TokenPos(), *CurrentLiteral(), true); |
| 10064 ConsumeToken(); | 10064 ConsumeToken(); |
| 10065 } else { | 10065 } else { |
| 10066 ASSERT(CurrentToken() == Token::kINTERPOL_START); | 10066 ASSERT(CurrentToken() == Token::kINTERPOL_START); |
| 10067 ConsumeToken(); | 10067 ConsumeToken(); |
| 10068 expr = ParseExpr(kAllowConst, kConsumeCascades); | 10068 expr = ParseExpr(kAllowConst, kConsumeCascades); |
| 10069 ExpectToken(Token::kINTERPOL_END); | 10069 ExpectToken(Token::kINTERPOL_END); |
| 10070 } | 10070 } |
| 10071 // Check if this interpolated string is still considered a compile time | 10071 // Check if this interpolated string is still considered a compile time |
| 10072 // constant. If it is we need to evaluate if the current string part is | 10072 // constant. If it is we need to evaluate if the current string part is |
| 10073 // a constant or not. Only stings, numbers, booleans and null values | 10073 // a constant or not. Only strings, numbers, booleans and null values |
| 10074 // are allowed in compile time const interpolations. | 10074 // are allowed in compile time const interpolations. |
| 10075 if (is_compiletime_const) { | 10075 if (is_compiletime_const) { |
| 10076 const Object* const_expr = expr->EvalConstExpr(); | 10076 const Object* const_expr = expr->EvalConstExpr(); |
| 10077 if ((const_expr != NULL) && | 10077 if ((const_expr != NULL) && |
| 10078 (const_expr->IsNumber() || | 10078 (const_expr->IsNumber() || |
| 10079 const_expr->IsString() || | 10079 const_expr->IsString() || |
| 10080 const_expr->IsBool() || | 10080 const_expr->IsBool() || |
| 10081 const_expr->IsNull())) { | 10081 const_expr->IsNull())) { |
| 10082 // Change expr into a literal. | 10082 // Change expr into a literal. |
| 10083 expr = new LiteralNode(expr_pos, EvaluateConstExpr(expr)); | 10083 expr = new LiteralNode(expr_pos, EvaluateConstExpr(expr)); |
| 10084 } else { | 10084 } else { |
| 10085 is_compiletime_const = false; | 10085 is_compiletime_const = false; |
| 10086 } | 10086 } |
| 10087 } | 10087 } |
| 10088 values_list.Add(expr); | 10088 values_list.Add(expr); |
| 10089 } | 10089 } |
| 10090 } | 10090 } |
| 10091 if (is_compiletime_const) { | 10091 if (is_compiletime_const) { |
| 10092 primary = new LiteralNode(literal_start, Interpolate(values_list)); | 10092 primary = new LiteralNode(literal_start, Interpolate(values_list)); |
| 10093 } else { | 10093 } else { |
| 10094 ArgumentListNode* interpolate_arg = new ArgumentListNode(TokenPos()); | |
| 10095 ArrayNode* values = new ArrayNode( | 10094 ArrayNode* values = new ArrayNode( |
| 10096 TokenPos(), | 10095 TokenPos(), |
| 10097 Type::ZoneHandle(Type::ArrayType()), | 10096 Type::ZoneHandle(Type::ArrayType()), |
| 10098 values_list); | 10097 values_list); |
| 10099 interpolate_arg->Add(values); | 10098 primary = new StringInterpolateNode(TokenPos(), values); |
| 10100 primary = | |
| 10101 MakeStaticCall(Symbols::StringBase(), | |
| 10102 Library::PrivateCoreLibName(Symbols::Interpolate()), | |
| 10103 interpolate_arg); | |
| 10104 } | 10099 } |
| 10105 return primary; | 10100 return primary; |
| 10106 } | 10101 } |
| 10107 | 10102 |
| 10108 | 10103 |
| 10109 AstNode* Parser::ParsePrimary() { | 10104 AstNode* Parser::ParsePrimary() { |
| 10110 TRACE_PARSER("ParsePrimary"); | 10105 TRACE_PARSER("ParsePrimary"); |
| 10111 ASSERT(!is_top_level_); | 10106 ASSERT(!is_top_level_); |
| 10112 AstNode* primary = NULL; | 10107 AstNode* primary = NULL; |
| 10113 if (IsFunctionLiteral()) { | 10108 if (IsFunctionLiteral()) { |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10624 void Parser::SkipQualIdent() { | 10619 void Parser::SkipQualIdent() { |
| 10625 ASSERT(IsIdentifier()); | 10620 ASSERT(IsIdentifier()); |
| 10626 ConsumeToken(); | 10621 ConsumeToken(); |
| 10627 if (CurrentToken() == Token::kPERIOD) { | 10622 if (CurrentToken() == Token::kPERIOD) { |
| 10628 ConsumeToken(); // Consume the kPERIOD token. | 10623 ConsumeToken(); // Consume the kPERIOD token. |
| 10629 ExpectIdentifier("identifier expected after '.'"); | 10624 ExpectIdentifier("identifier expected after '.'"); |
| 10630 } | 10625 } |
| 10631 } | 10626 } |
| 10632 | 10627 |
| 10633 } // namespace dart | 10628 } // namespace dart |
| OLD | NEW |