| 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 "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 8984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8995 // not optimizable. | 8995 // not optimizable. |
| 8996 current_function().SetIsOptimizable(false); | 8996 current_function().SetIsOptimizable(false); |
| 8997 field.set_value(Object::null_instance()); | 8997 field.set_value(Object::null_instance()); |
| 8998 // It is a compile-time error if evaluation of a compile-time constant | 8998 // It is a compile-time error if evaluation of a compile-time constant |
| 8999 // would raise an exception. | 8999 // would raise an exception. |
| 9000 AppendErrorMsg(error, field_ref_pos, | 9000 AppendErrorMsg(error, field_ref_pos, |
| 9001 "error initializing const field '%s'", | 9001 "error initializing const field '%s'", |
| 9002 String::Handle(field.name()).ToCString()); | 9002 String::Handle(field.name()).ToCString()); |
| 9003 } else { | 9003 } else { |
| 9004 isolate()->long_jump_base()->Jump(1, error); | 9004 isolate()->long_jump_base()->Jump(1, error); |
| 9005 UNREACHABLE(); |
| 9005 } | 9006 } |
| 9006 } | 9007 } |
| 9007 ASSERT(const_value.IsNull() || const_value.IsInstance()); | 9008 ASSERT(const_value.IsNull() || const_value.IsInstance()); |
| 9008 Instance& instance = Instance::Handle(); | 9009 Instance& instance = Instance::Handle(); |
| 9009 instance ^= const_value.raw(); | 9010 instance ^= const_value.raw(); |
| 9010 instance = TryCanonicalize(instance, field_ref_pos); | 9011 instance = TryCanonicalize(instance, field_ref_pos); |
| 9011 field.set_value(instance); | 9012 field.set_value(instance); |
| 9012 return NULL; // Constant | 9013 return NULL; // Constant |
| 9013 } else { | 9014 } else { |
| 9014 return new StaticGetterNode(field_ref_pos, | 9015 return new StaticGetterNode(field_ref_pos, |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10290 for (int i = 0; i < values.length(); i++) { | 10291 for (int i = 0; i < values.length(); i++) { |
| 10291 ASSERT(values[i]->IsLiteralNode()); | 10292 ASSERT(values[i]->IsLiteralNode()); |
| 10292 value_arr.SetAt(i, values[i]->AsLiteralNode()->literal()); | 10293 value_arr.SetAt(i, values[i]->AsLiteralNode()->literal()); |
| 10293 } | 10294 } |
| 10294 | 10295 |
| 10295 // Build argument array to pass to the interpolation function. | 10296 // Build argument array to pass to the interpolation function. |
| 10296 const Array& interpolate_arg = Array::Handle(isolate(), Array::New(1)); | 10297 const Array& interpolate_arg = Array::Handle(isolate(), Array::New(1)); |
| 10297 interpolate_arg.SetAt(0, value_arr); | 10298 interpolate_arg.SetAt(0, value_arr); |
| 10298 | 10299 |
| 10299 // Call interpolation function. | 10300 // Call interpolation function. |
| 10300 String& concatenated = String::ZoneHandle(isolate()); | 10301 Object& result = Object::Handle(isolate()); |
| 10301 { | 10302 { |
| 10302 PAUSETIMERSCOPE(isolate(), time_compilation); | 10303 PAUSETIMERSCOPE(isolate(), time_compilation); |
| 10303 concatenated ^= DartEntry::InvokeFunction(func, interpolate_arg); | 10304 result = DartEntry::InvokeFunction(func, interpolate_arg); |
| 10304 } | 10305 } |
| 10305 if (concatenated.IsUnhandledException()) { | 10306 if (result.IsUnhandledException()) { |
| 10306 ErrorMsg("Exception thrown in Parser::Interpolate"); | 10307 ErrorMsg("%s", Error::Cast(result).ToErrorCString()); |
| 10307 } | 10308 } |
| 10309 String& concatenated = String::ZoneHandle(isolate()); |
| 10310 concatenated ^= result.raw(); |
| 10308 concatenated = Symbols::New(concatenated); | 10311 concatenated = Symbols::New(concatenated); |
| 10309 return concatenated; | 10312 return concatenated; |
| 10310 } | 10313 } |
| 10311 | 10314 |
| 10312 | 10315 |
| 10313 // A string literal consists of the concatenation of the next n tokens | 10316 // A string literal consists of the concatenation of the next n tokens |
| 10314 // that satisfy the EBNF grammar: | 10317 // that satisfy the EBNF grammar: |
| 10315 // literal = kSTRING {{ interpol } kSTRING } | 10318 // literal = kSTRING {{ interpol } kSTRING } |
| 10316 // interpol = kINTERPOL_VAR | (kINTERPOL_START expression kINTERPOL_END) | 10319 // interpol = kINTERPOL_VAR | (kINTERPOL_START expression kINTERPOL_END) |
| 10317 // In other words, the scanner breaks down interpolated strings so that | 10320 // In other words, the scanner breaks down interpolated strings so that |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10951 void Parser::SkipQualIdent() { | 10954 void Parser::SkipQualIdent() { |
| 10952 ASSERT(IsIdentifier()); | 10955 ASSERT(IsIdentifier()); |
| 10953 ConsumeToken(); | 10956 ConsumeToken(); |
| 10954 if (CurrentToken() == Token::kPERIOD) { | 10957 if (CurrentToken() == Token::kPERIOD) { |
| 10955 ConsumeToken(); // Consume the kPERIOD token. | 10958 ConsumeToken(); // Consume the kPERIOD token. |
| 10956 ExpectIdentifier("identifier expected after '.'"); | 10959 ExpectIdentifier("identifier expected after '.'"); |
| 10957 } | 10960 } |
| 10958 } | 10961 } |
| 10959 | 10962 |
| 10960 } // namespace dart | 10963 } // namespace dart |
| OLD | NEW |