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/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 1886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 | 1897 |
1898 const bool saved_mode = SetAllowFunctionLiterals(false); | 1898 const bool saved_mode = SetAllowFunctionLiterals(false); |
1899 // "this" must not be accessible in initializer expressions. | 1899 // "this" must not be accessible in initializer expressions. |
1900 receiver->set_invisible(true); | 1900 receiver->set_invisible(true); |
1901 AstNode* init_expr = ParseConditionalExpr(); | 1901 AstNode* init_expr = ParseConditionalExpr(); |
1902 if (CurrentToken() == Token::kCASCADE) { | 1902 if (CurrentToken() == Token::kCASCADE) { |
1903 init_expr = ParseCascades(init_expr); | 1903 init_expr = ParseCascades(init_expr); |
1904 } | 1904 } |
1905 receiver->set_invisible(false); | 1905 receiver->set_invisible(false); |
1906 SetAllowFunctionLiterals(saved_mode); | 1906 SetAllowFunctionLiterals(saved_mode); |
| 1907 if (current_function().is_const() && !init_expr->IsPotentiallyConst()) { |
| 1908 ErrorMsg(field_pos, |
| 1909 "initializer expression must be compile time constant."); |
| 1910 } |
1907 Field& field = Field::ZoneHandle(cls.LookupInstanceField(field_name)); | 1911 Field& field = Field::ZoneHandle(cls.LookupInstanceField(field_name)); |
1908 if (field.IsNull()) { | 1912 if (field.IsNull()) { |
1909 ErrorMsg(field_pos, "unresolved reference to instance field '%s'", | 1913 ErrorMsg(field_pos, "unresolved reference to instance field '%s'", |
1910 field_name.ToCString()); | 1914 field_name.ToCString()); |
1911 } | 1915 } |
1912 CheckDuplicateFieldInit(field_pos, initialized_fields, &field); | 1916 CheckDuplicateFieldInit(field_pos, initialized_fields, &field); |
1913 AstNode* instance = new LoadLocalNode(field_pos, receiver); | 1917 AstNode* instance = new LoadLocalNode(field_pos, receiver); |
1914 EnsureExpressionTemp(); | 1918 EnsureExpressionTemp(); |
1915 return new StoreInstanceFieldNode(field_pos, instance, field, init_expr); | 1919 return new StoreInstanceFieldNode(field_pos, instance, field, init_expr); |
1916 } | 1920 } |
(...skipping 8057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9974 void Parser::SkipQualIdent() { | 9978 void Parser::SkipQualIdent() { |
9975 ASSERT(IsIdentifier()); | 9979 ASSERT(IsIdentifier()); |
9976 ConsumeToken(); | 9980 ConsumeToken(); |
9977 if (CurrentToken() == Token::kPERIOD) { | 9981 if (CurrentToken() == Token::kPERIOD) { |
9978 ConsumeToken(); // Consume the kPERIOD token. | 9982 ConsumeToken(); // Consume the kPERIOD token. |
9979 ExpectIdentifier("identifier expected after '.'"); | 9983 ExpectIdentifier("identifier expected after '.'"); |
9980 } | 9984 } |
9981 } | 9985 } |
9982 | 9986 |
9983 } // namespace dart | 9987 } // namespace dart |
OLD | NEW |