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

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

Issue 10826090: Optimize away most implicit const getter functions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months 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
« runtime/vm/parser.cc ('K') | « runtime/vm/parser.cc ('k') | no next file » | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 5
6 #include "vm/ast_printer.h" 6 #include "vm/ast_printer.h"
7 #include "vm/class_finalizer.h" 7 #include "vm/class_finalizer.h"
8 #include "vm/longjump.h" 8 #include "vm/longjump.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/parser.h" 10 #include "vm/parser.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 script.Tokenize(String::Handle(String::New(""))); 123 script.Tokenize(String::Handle(String::New("")));
124 124
125 Parser::ParseCompilationUnit(lib, script); 125 Parser::ParseCompilationUnit(lib, script);
126 EXPECT(ClassFinalizer::FinalizePendingClasses()); 126 EXPECT(ClassFinalizer::FinalizePendingClasses());
127 CheckField(lib, "A", "f1", false, false); 127 CheckField(lib, "A", "f1", false, false);
128 CheckField(lib, "A", "f2", false, true); 128 CheckField(lib, "A", "f2", false, true);
129 CheckField(lib, "A", "f3", false, true); 129 CheckField(lib, "A", "f3", false, true);
130 CheckField(lib, "A", "f4", false, true); 130 CheckField(lib, "A", "f4", false, true);
131 CheckField(lib, "A", "s1", true, false); 131 CheckField(lib, "A", "s1", true, false);
132 CheckField(lib, "A", "s2", true, false); 132 CheckField(lib, "A", "s2", true, false);
133 // No field entries are added for static const fields. 133 CheckField(lib, "A", "s3", true, true);
134 String& fieldname = String::Handle(String::New("s3"));
135 const String& classname = String::Handle(Symbols::New("A"));
136 const Class& cls = Class::Handle(lib.LookupClass(classname));
137 const Field& field = Field::Handle(cls.LookupStaticField(fieldname));
138 EXPECT(!field.IsNull());
139 Object& val = Object::Handle(field.value());
140 // The static const field initializer is not evaluated and the field
141 // value is not initialized until the field is referenced by code that
142 // is compiled.
143 EXPECT(val.raw() == Object::sentinel());
144
145 CheckFunction(lib, "A", "bar", true); 134 CheckFunction(lib, "A", "bar", true);
146 CheckFunction(lib, "A", "foo", true); 135 CheckFunction(lib, "A", "foo", true);
147 } 136 }
148 137
149 138
150 TEST_CASE(Parser_TopLevel) { 139 TEST_CASE(Parser_TopLevel) {
151 const char* script_chars = 140 const char* script_chars =
152 "class A extends B { \n" 141 "class A extends B { \n"
153 " static bar(var i, [var d = 5]) { return 77; } \n" 142 " static bar(var i, [var d = 5]) { return 77; } \n"
154 " static foo() { return 42; } \n" 143 " static foo() { return 42; } \n"
(...skipping 16 matching lines...) Expand all
171 Parser::ParseCompilationUnit(lib, script); 160 Parser::ParseCompilationUnit(lib, script);
172 EXPECT(ClassFinalizer::FinalizePendingClasses()); 161 EXPECT(ClassFinalizer::FinalizePendingClasses());
173 162
174 DumpFunction(lib, "A", "foo"); 163 DumpFunction(lib, "A", "foo");
175 DumpFunction(lib, "A", "bar"); 164 DumpFunction(lib, "A", "bar");
176 DumpFunction(lib, "A", "baz"); 165 DumpFunction(lib, "A", "baz");
177 DumpFunction(lib, "B", "bam"); 166 DumpFunction(lib, "B", "bam");
178 } 167 }
179 168
180 } // namespace dart 169 } // namespace dart
OLDNEW
« runtime/vm/parser.cc ('K') | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698