Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: runtime/vm/parser.cc

Issue 745203002: - Make array immutable first, then canonicalize it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 10766 matching lines...) Expand 10 before | Expand all | Expand 10 after
10777 ReportError(elem->AsLiteralNode()->token_pos(), 10777 ReportError(elem->AsLiteralNode()->token_pos(),
10778 "list literal element at index %d must be " 10778 "list literal element at index %d must be "
10779 "a constant of type '%s'", 10779 "a constant of type '%s'",
10780 i, 10780 i,
10781 String::Handle(I, 10781 String::Handle(I,
10782 element_type.UserVisibleName()).ToCString()); 10782 element_type.UserVisibleName()).ToCString());
10783 } 10783 }
10784 } 10784 }
10785 const_list.SetAt(i, elem->AsLiteralNode()->literal()); 10785 const_list.SetAt(i, elem->AsLiteralNode()->literal());
10786 } 10786 }
10787 const_list.MakeImmutable();
10787 const_list ^= TryCanonicalize(const_list, literal_pos); 10788 const_list ^= TryCanonicalize(const_list, literal_pos);
10788 const_list.MakeImmutable();
10789 return new(I) LiteralNode(literal_pos, const_list); 10789 return new(I) LiteralNode(literal_pos, const_list);
10790 } else { 10790 } else {
10791 // Factory call at runtime. 10791 // Factory call at runtime.
10792 const Class& factory_class = 10792 const Class& factory_class =
10793 Class::Handle(I, Library::LookupCoreClass(Symbols::List())); 10793 Class::Handle(I, Library::LookupCoreClass(Symbols::List()));
10794 ASSERT(!factory_class.IsNull()); 10794 ASSERT(!factory_class.IsNull());
10795 const Function& factory_method = Function::ZoneHandle(I, 10795 const Function& factory_method = Function::ZoneHandle(I,
10796 factory_class.LookupFactory( 10796 factory_class.LookupFactory(
10797 Library::PrivateCoreLibName(Symbols::ListLiteralFactory()))); 10797 Library::PrivateCoreLibName(Symbols::ListLiteralFactory())));
10798 ASSERT(!factory_method.IsNull()); 10798 ASSERT(!factory_method.IsNull());
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
11002 "a constant of type '%s'", 11002 "a constant of type '%s'",
11003 ((i % 2) == 0) ? "key" : "value", 11003 ((i % 2) == 0) ? "key" : "value",
11004 i >> 1, 11004 i >> 1,
11005 String::Handle(I, 11005 String::Handle(I,
11006 arg_type.UserVisibleName()).ToCString()); 11006 arg_type.UserVisibleName()).ToCString());
11007 } 11007 }
11008 } 11008 }
11009 } 11009 }
11010 key_value_array.SetAt(i, arg->AsLiteralNode()->literal()); 11010 key_value_array.SetAt(i, arg->AsLiteralNode()->literal());
11011 } 11011 }
11012 key_value_array.MakeImmutable();
11012 key_value_array ^= TryCanonicalize(key_value_array, TokenPos()); 11013 key_value_array ^= TryCanonicalize(key_value_array, TokenPos());
11013 key_value_array.MakeImmutable();
11014 11014
11015 // Construct the map object. 11015 // Construct the map object.
11016 const Class& immutable_map_class = Class::Handle(I, 11016 const Class& immutable_map_class = Class::Handle(I,
11017 Library::LookupCoreClass(Symbols::ImmutableMap())); 11017 Library::LookupCoreClass(Symbols::ImmutableMap()));
11018 ASSERT(!immutable_map_class.IsNull()); 11018 ASSERT(!immutable_map_class.IsNull());
11019 // If the immutable map class extends other parameterized classes, we need 11019 // If the immutable map class extends other parameterized classes, we need
11020 // to adjust the type argument vector. This is currently not the case. 11020 // to adjust the type argument vector. This is currently not the case.
11021 ASSERT(immutable_map_class.NumTypeArguments() == 2); 11021 ASSERT(immutable_map_class.NumTypeArguments() == 2);
11022 ArgumentListNode* constr_args = new(I) ArgumentListNode(TokenPos()); 11022 ArgumentListNode* constr_args = new(I) ArgumentListNode(TokenPos());
11023 constr_args->Add(new(I) LiteralNode(literal_pos, key_value_array)); 11023 constr_args->Add(new(I) LiteralNode(literal_pos, key_value_array));
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
12118 void Parser::SkipQualIdent() { 12118 void Parser::SkipQualIdent() {
12119 ASSERT(IsIdentifier()); 12119 ASSERT(IsIdentifier());
12120 ConsumeToken(); 12120 ConsumeToken();
12121 if (CurrentToken() == Token::kPERIOD) { 12121 if (CurrentToken() == Token::kPERIOD) {
12122 ConsumeToken(); // Consume the kPERIOD token. 12122 ConsumeToken(); // Consume the kPERIOD token.
12123 ExpectIdentifier("identifier expected after '.'"); 12123 ExpectIdentifier("identifier expected after '.'");
12124 } 12124 }
12125 } 12125 }
12126 12126
12127 } // namespace dart 12127 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698