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

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

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.h » ('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 "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 11 matching lines...) Expand all
22 DECLARE_FLAG(bool, write_protect_code); 22 DECLARE_FLAG(bool, write_protect_code);
23 23
24 static RawLibrary* CreateDummyLibrary(const String& library_name) { 24 static RawLibrary* CreateDummyLibrary(const String& library_name) {
25 return Library::New(library_name); 25 return Library::New(library_name);
26 } 26 }
27 27
28 28
29 static RawClass* CreateDummyClass(const String& class_name, 29 static RawClass* CreateDummyClass(const String& class_name,
30 const Script& script) { 30 const Script& script) {
31 const Class& cls = Class::Handle( 31 const Class& cls = Class::Handle(
32 Class::New(class_name, script, Token::kNoSourcePos)); 32 Class::New(class_name, script, TokenPosition::kNoSource));
33 cls.set_is_synthesized_class(); // Dummy class for testing. 33 cls.set_is_synthesized_class(); // Dummy class for testing.
34 return cls.raw(); 34 return cls.raw();
35 } 35 }
36 36
37 37
38 VM_TEST_CASE(Class) { 38 VM_TEST_CASE(Class) {
39 // Allocate the class first. 39 // Allocate the class first.
40 const String& class_name = String::Handle(Symbols::New("MyClass")); 40 const String& class_name = String::Handle(Symbols::New("MyClass"));
41 const Script& script = Script::Handle(); 41 const Script& script = Script::Handle();
42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 42 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
(...skipping 18 matching lines...) Expand all
61 // parsed. 61 // parsed.
62 ClassFinalizer::FinalizeTypesInClass(cls); 62 ClassFinalizer::FinalizeTypesInClass(cls);
63 63
64 // Create and populate the function arrays. 64 // Create and populate the function arrays.
65 const Array& functions = Array::Handle(Array::New(6)); 65 const Array& functions = Array::Handle(Array::New(6));
66 Function& function = Function::Handle(); 66 Function& function = Function::Handle();
67 String& function_name = String::Handle(); 67 String& function_name = String::Handle();
68 function_name = Symbols::New("foo"); 68 function_name = Symbols::New("foo");
69 function = Function::New( 69 function = Function::New(
70 function_name, RawFunction::kRegularFunction, 70 function_name, RawFunction::kRegularFunction,
71 false, false, false, false, false, cls, 0); 71 false, false, false, false, false, cls, TokenPosition::kMinSource);
72 functions.SetAt(0, function); 72 functions.SetAt(0, function);
73 function_name = Symbols::New("bar"); 73 function_name = Symbols::New("bar");
74 function = Function::New( 74 function = Function::New(
75 function_name, RawFunction::kRegularFunction, 75 function_name, RawFunction::kRegularFunction,
76 false, false, false, false, false, cls, 0); 76 false, false, false, false, false, cls, TokenPosition::kMinSource);
77 77
78 const int kNumFixedParameters = 2; 78 const int kNumFixedParameters = 2;
79 const int kNumOptionalParameters = 3; 79 const int kNumOptionalParameters = 3;
80 const bool kAreOptionalPositional = true; 80 const bool kAreOptionalPositional = true;
81 function.set_num_fixed_parameters(kNumFixedParameters); 81 function.set_num_fixed_parameters(kNumFixedParameters);
82 function.SetNumOptionalParameters(kNumOptionalParameters, 82 function.SetNumOptionalParameters(kNumOptionalParameters,
83 kAreOptionalPositional); 83 kAreOptionalPositional);
84 functions.SetAt(1, function); 84 functions.SetAt(1, function);
85 85
86 function_name = Symbols::New("baz"); 86 function_name = Symbols::New("baz");
87 function = Function::New( 87 function = Function::New(
88 function_name, RawFunction::kRegularFunction, 88 function_name, RawFunction::kRegularFunction,
89 false, false, false, false, false, cls, 0); 89 false, false, false, false, false, cls, TokenPosition::kMinSource);
90 functions.SetAt(2, function); 90 functions.SetAt(2, function);
91 91
92 function_name = Symbols::New("Foo"); 92 function_name = Symbols::New("Foo");
93 function = Function::New( 93 function = Function::New(
94 function_name, RawFunction::kRegularFunction, 94 function_name, RawFunction::kRegularFunction,
95 true, false, false, false, false, cls, 0); 95 true, false, false, false, false, cls, TokenPosition::kMinSource);
96 96
97 functions.SetAt(3, function); 97 functions.SetAt(3, function);
98 function_name = Symbols::New("Bar"); 98 function_name = Symbols::New("Bar");
99 function = Function::New( 99 function = Function::New(
100 function_name, RawFunction::kRegularFunction, 100 function_name, RawFunction::kRegularFunction,
101 true, false, false, false, false, cls, 0); 101 true, false, false, false, false, cls, TokenPosition::kMinSource);
102 functions.SetAt(4, function); 102 functions.SetAt(4, function);
103 function_name = Symbols::New("BaZ"); 103 function_name = Symbols::New("BaZ");
104 function = Function::New( 104 function = Function::New(
105 function_name, RawFunction::kRegularFunction, 105 function_name, RawFunction::kRegularFunction,
106 true, false, false, false, false, cls, 0); 106 true, false, false, false, false, cls, TokenPosition::kMinSource);
107 functions.SetAt(5, function); 107 functions.SetAt(5, function);
108 108
109 // Setup the functions in the class. 109 // Setup the functions in the class.
110 cls.SetFunctions(functions); 110 cls.SetFunctions(functions);
111 111
112 // The class can now be finalized. 112 // The class can now be finalized.
113 cls.Finalize(); 113 cls.Finalize();
114 114
115 function_name = String::New("Foo"); 115 function_name = String::New("Foo");
116 function = cls.LookupDynamicFunction(function_name); 116 function = cls.LookupDynamicFunction(function_name);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 167
168 VM_TEST_CASE(TokenStream) { 168 VM_TEST_CASE(TokenStream) {
169 String& source = String::Handle(String::New("= ( 9 , .")); 169 String& source = String::Handle(String::New("= ( 9 , ."));
170 String& private_key = String::Handle(String::New("")); 170 String& private_key = String::Handle(String::New(""));
171 Scanner scanner(source, private_key); 171 Scanner scanner(source, private_key);
172 const Scanner::GrowableTokenStream& ts = scanner.GetStream(); 172 const Scanner::GrowableTokenStream& ts = scanner.GetStream();
173 EXPECT_EQ(6, ts.length()); 173 EXPECT_EQ(6, ts.length());
174 EXPECT_EQ(Token::kLPAREN, ts[1].kind); 174 EXPECT_EQ(Token::kLPAREN, ts[1].kind);
175 const TokenStream& token_stream = TokenStream::Handle( 175 const TokenStream& token_stream = TokenStream::Handle(
176 TokenStream::New(ts, private_key, false)); 176 TokenStream::New(ts, private_key, false));
177 TokenStream::Iterator iterator(token_stream, 0); 177 TokenStream::Iterator iterator(token_stream, TokenPosition::kMinSource);
178 // EXPECT_EQ(6, token_stream.Length()); 178 // EXPECT_EQ(6, token_stream.Length());
179 iterator.Advance(); // Advance to '(' token. 179 iterator.Advance(); // Advance to '(' token.
180 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind()); 180 EXPECT_EQ(Token::kLPAREN, iterator.CurrentTokenKind());
181 iterator.Advance(); 181 iterator.Advance();
182 iterator.Advance(); 182 iterator.Advance();
183 iterator.Advance(); // Advance to '.' token. 183 iterator.Advance(); // Advance to '.' token.
184 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind()); 184 EXPECT_EQ(Token::kPERIOD, iterator.CurrentTokenKind());
185 iterator.Advance(); // Advance to end of stream. 185 iterator.Advance(); // Advance to end of stream.
186 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind()); 186 EXPECT_EQ(Token::kEOS, iterator.CurrentTokenKind());
187 } 187 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 " var baz = \"${foo('}')}\";\n" 234 " var baz = \"${foo('}')}\";\n"
235 "}\n"; 235 "}\n";
236 Dart_Handle lib_h = TestCase::LoadTestScript(kScript, NULL); 236 Dart_Handle lib_h = TestCase::LoadTestScript(kScript, NULL);
237 EXPECT_VALID(lib_h); 237 EXPECT_VALID(lib_h);
238 Library& lib = Library::Handle(); 238 Library& lib = Library::Handle();
239 lib ^= Api::UnwrapHandle(lib_h); 239 lib ^= Api::UnwrapHandle(lib_h);
240 EXPECT(!lib.IsNull()); 240 EXPECT(!lib.IsNull());
241 const Class& cls = Class::Handle( 241 const Class& cls = Class::Handle(
242 lib.LookupClass(String::Handle(String::New("A")))); 242 lib.LookupClass(String::Handle(String::New("A"))));
243 EXPECT(!cls.IsNull()); 243 EXPECT(!cls.IsNull());
244 const intptr_t end_token_pos = cls.ComputeEndTokenPos(); 244 const TokenPosition end_token_pos = cls.ComputeEndTokenPos();
245 const Script& scr = Script::Handle(cls.script()); 245 const Script& scr = Script::Handle(cls.script());
246 intptr_t line; 246 intptr_t line;
247 intptr_t col; 247 intptr_t col;
248 scr.GetTokenLocation(end_token_pos, &line, &col); 248 scr.GetTokenLocation(end_token_pos, &line, &col);
249 EXPECT(line == 10 && col == 1); 249 EXPECT(line == 10 && col == 1);
250 } 250 }
251 251
252 252
253 VM_TEST_CASE(InstanceClass) { 253 VM_TEST_CASE(InstanceClass) {
254 // Allocate the class first. 254 // Allocate the class first.
(...skipping 20 matching lines...) Expand all
275 // No fields, functions, or super type for the OneFieldClass. 275 // No fields, functions, or super type for the OneFieldClass.
276 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0); 276 EXPECT_EQ(Array::Handle(empty_class.fields()).Length(), 0);
277 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0); 277 EXPECT_EQ(Array::Handle(empty_class.functions()).Length(), 0);
278 EXPECT_EQ(empty_class.super_type(), AbstractType::null()); 278 EXPECT_EQ(empty_class.super_type(), AbstractType::null());
279 ClassFinalizer::FinalizeTypesInClass(one_field_class); 279 ClassFinalizer::FinalizeTypesInClass(one_field_class);
280 280
281 const Array& one_fields = Array::Handle(Array::New(1)); 281 const Array& one_fields = Array::Handle(Array::New(1));
282 const String& field_name = String::Handle(Symbols::New("the_field")); 282 const String& field_name = String::Handle(Symbols::New("the_field"));
283 const Field& field = Field::Handle( 283 const Field& field = Field::Handle(
284 Field::New(field_name, false, false, false, true, one_field_class, 284 Field::New(field_name, false, false, false, true, one_field_class,
285 Object::dynamic_type(), 0)); 285 Object::dynamic_type(), TokenPosition::kMinSource));
286 one_fields.SetAt(0, field); 286 one_fields.SetAt(0, field);
287 one_field_class.SetFields(one_fields); 287 one_field_class.SetFields(one_fields);
288 one_field_class.Finalize(); 288 one_field_class.Finalize();
289 intptr_t header_size = sizeof(RawObject); 289 intptr_t header_size = sizeof(RawObject);
290 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment), 290 EXPECT_EQ(Utils::RoundUp((header_size + (1 * kWordSize)), kObjectAlignment),
291 one_field_class.instance_size()); 291 one_field_class.instance_size());
292 EXPECT_EQ(header_size, field.Offset()); 292 EXPECT_EQ(header_size, field.Offset());
293 EXPECT(!one_field_class.is_implemented()); 293 EXPECT(!one_field_class.is_implemented());
294 one_field_class.set_is_implemented(); 294 one_field_class.set_is_implemented();
295 EXPECT(one_field_class.is_implemented()); 295 EXPECT(one_field_class.is_implemented());
(...skipping 2159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 str = script.GetLine(last_dart_line); 2455 str = script.GetLine(last_dart_line);
2456 EXPECT_STREQ(" }", str.ToCString()); 2456 EXPECT_STREQ(" }", str.ToCString());
2457 2457
2458 script.Tokenize(String::Handle(String::New("ABC"))); 2458 script.Tokenize(String::Handle(String::New("ABC")));
2459 // Tokens: 0: kIDENT, 1: kLPAREN, 2: kRPAREN, 3: kLBRACE, 4: kNEWLINE, 2459 // Tokens: 0: kIDENT, 1: kLPAREN, 2: kRPAREN, 3: kLBRACE, 4: kNEWLINE,
2460 // 5: kRETURN, 6: kSTRING, 7: kSEMICOLON, 8: kNEWLINE, 2460 // 5: kRETURN, 6: kSTRING, 7: kSEMICOLON, 8: kNEWLINE,
2461 // 9: kRBRACE, 10: kNEWLINE 2461 // 9: kRBRACE, 10: kNEWLINE
2462 2462
2463 intptr_t line, col; 2463 intptr_t line, col;
2464 intptr_t fast_line; 2464 intptr_t fast_line;
2465 script.GetTokenLocation(0, &line, &col); 2465 script.GetTokenLocation(TokenPosition(0), &line, &col);
2466 EXPECT_EQ(first_dart_line, line); 2466 EXPECT_EQ(first_dart_line, line);
2467 EXPECT_EQ(col, col_offset + 1); 2467 EXPECT_EQ(col, col_offset + 1);
2468 2468
2469 // We allow asking for only the line number, which only scans the token stream 2469 // We allow asking for only the line number, which only scans the token stream
2470 // instead of rescanning the script. 2470 // instead of rescanning the script.
2471 script.GetTokenLocation(0, &fast_line, NULL); 2471 script.GetTokenLocation(TokenPosition(0), &fast_line, NULL);
2472 EXPECT_EQ(line, fast_line); 2472 EXPECT_EQ(line, fast_line);
2473 2473
2474 script.GetTokenLocation(5, &line, &col); // Token 'return' 2474 script.GetTokenLocation(TokenPosition(5), &line, &col); // Token 'return'
2475 EXPECT_EQ(4, line); // 'return' is in line 4. 2475 EXPECT_EQ(4, line); // 'return' is in line 4.
2476 EXPECT_EQ(5, col); // Four spaces before 'return'. 2476 EXPECT_EQ(5, col); // Four spaces before 'return'.
2477 2477
2478 // We allow asking for only the line number, which only scans the token stream 2478 // We allow asking for only the line number, which only scans the token stream
2479 // instead of rescanning the script. 2479 // instead of rescanning the script.
2480 script.GetTokenLocation(5, &fast_line, NULL); 2480 script.GetTokenLocation(TokenPosition(5), &fast_line, NULL);
2481 EXPECT_EQ(line, fast_line); 2481 EXPECT_EQ(line, fast_line);
2482 2482
2483 intptr_t first_idx, last_idx; 2483 TokenPosition first_idx, last_idx;
2484 script.TokenRangeAtLine(3, &first_idx, &last_idx); 2484 script.TokenRangeAtLine(3, &first_idx, &last_idx);
2485 EXPECT_EQ(0, first_idx); // Token 'main' is first token. 2485 EXPECT_EQ(0, first_idx.value()); // Token 'main' is first token.
2486 EXPECT_EQ(3, last_idx); // Token { is last token. 2486 EXPECT_EQ(3, last_idx.value()); // Token { is last token.
2487 script.TokenRangeAtLine(4, &first_idx, &last_idx); 2487 script.TokenRangeAtLine(4, &first_idx, &last_idx);
2488 EXPECT_EQ(5, first_idx); // Token 'return' is first token. 2488 EXPECT_EQ(5, first_idx.value()); // Token 'return' is first token.
2489 EXPECT_EQ(7, last_idx); // Token ; is last token. 2489 EXPECT_EQ(7, last_idx.value()); // Token ; is last token.
2490 script.TokenRangeAtLine(5, &first_idx, &last_idx); 2490 script.TokenRangeAtLine(5, &first_idx, &last_idx);
2491 EXPECT_EQ(9, first_idx); // Token } is first and only token. 2491 EXPECT_EQ(9, first_idx.value()); // Token } is first and only token.
2492 EXPECT_EQ(9, last_idx); 2492 EXPECT_EQ(9, last_idx.value());
2493 script.TokenRangeAtLine(1, &first_idx, &last_idx); 2493 script.TokenRangeAtLine(1, &first_idx, &last_idx);
2494 EXPECT_EQ(0, first_idx); 2494 EXPECT_EQ(0, first_idx.value());
2495 EXPECT_EQ(3, last_idx); 2495 EXPECT_EQ(3, last_idx.value());
2496 script.TokenRangeAtLine(6, &first_idx, &last_idx); 2496 script.TokenRangeAtLine(6, &first_idx, &last_idx);
2497 EXPECT_EQ(-1, first_idx); 2497 EXPECT_EQ(-1, first_idx.value());
2498 EXPECT_EQ(-1, last_idx); 2498 EXPECT_EQ(-1, last_idx.value());
2499 script.TokenRangeAtLine(1000, &first_idx, &last_idx); 2499 script.TokenRangeAtLine(1000, &first_idx, &last_idx);
2500 EXPECT_EQ(-1, first_idx); 2500 EXPECT_EQ(-1, first_idx.value());
2501 EXPECT_EQ(-1, last_idx); 2501 EXPECT_EQ(-1, last_idx.value());
2502 } 2502 }
2503 2503
2504 2504
2505 VM_TEST_CASE(Context) { 2505 VM_TEST_CASE(Context) {
2506 const int kNumVariables = 5; 2506 const int kNumVariables = 5;
2507 const Context& parent_context = Context::Handle(Context::New(0)); 2507 const Context& parent_context = Context::Handle(Context::New(0));
2508 const Context& context = Context::Handle(Context::New(kNumVariables)); 2508 const Context& context = Context::Handle(Context::New(kNumVariables));
2509 context.set_parent(parent_context); 2509 context.set_parent(parent_context);
2510 EXPECT_EQ(kNumVariables, context.num_variables()); 2510 EXPECT_EQ(kNumVariables, context.num_variables());
2511 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw()); 2511 EXPECT(Context::Handle(context.parent()).raw() == parent_context.raw());
(...skipping 18 matching lines...) Expand all
2530 LocalScope* parent_scope = 2530 LocalScope* parent_scope =
2531 new LocalScope(NULL, parent_scope_function_level, 0); 2531 new LocalScope(NULL, parent_scope_function_level, 0);
2532 2532
2533 const intptr_t local_scope_function_level = 1; 2533 const intptr_t local_scope_function_level = 1;
2534 LocalScope* local_scope = 2534 LocalScope* local_scope =
2535 new LocalScope(parent_scope, local_scope_function_level, 0); 2535 new LocalScope(parent_scope, local_scope_function_level, 0);
2536 2536
2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType()); 2537 const Type& dynamic_type = Type::ZoneHandle(Type::DynamicType());
2538 const String& a = String::ZoneHandle(Symbols::New("a")); 2538 const String& a = String::ZoneHandle(Symbols::New("a"));
2539 LocalVariable* var_a = 2539 LocalVariable* var_a =
2540 new LocalVariable(Token::kNoSourcePos, a, dynamic_type); 2540 new LocalVariable(TokenPosition::kNoSource, a, dynamic_type);
2541 parent_scope->AddVariable(var_a); 2541 parent_scope->AddVariable(var_a);
2542 2542
2543 const String& b = String::ZoneHandle(Symbols::New("b")); 2543 const String& b = String::ZoneHandle(Symbols::New("b"));
2544 LocalVariable* var_b = 2544 LocalVariable* var_b =
2545 new LocalVariable(Token::kNoSourcePos, b, dynamic_type); 2545 new LocalVariable(TokenPosition::kNoSource, b, dynamic_type);
2546 local_scope->AddVariable(var_b); 2546 local_scope->AddVariable(var_b);
2547 2547
2548 const String& c = String::ZoneHandle(Symbols::New("c")); 2548 const String& c = String::ZoneHandle(Symbols::New("c"));
2549 LocalVariable* var_c = 2549 LocalVariable* var_c =
2550 new LocalVariable(Token::kNoSourcePos, c, dynamic_type); 2550 new LocalVariable(TokenPosition::kNoSource, c, dynamic_type);
2551 parent_scope->AddVariable(var_c); 2551 parent_scope->AddVariable(var_c);
2552 2552
2553 bool test_only = false; // Please, insert alias. 2553 bool test_only = false; // Please, insert alias.
2554 var_a = local_scope->LookupVariable(a, test_only); 2554 var_a = local_scope->LookupVariable(a, test_only);
2555 EXPECT(var_a->is_captured()); 2555 EXPECT(var_a->is_captured());
2556 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level()); 2556 EXPECT_EQ(parent_scope_function_level, var_a->owner()->function_level());
2557 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias. 2557 EXPECT(local_scope->LocalLookupVariable(a) == var_a); // Alias.
2558 2558
2559 var_b = local_scope->LookupVariable(b, test_only); 2559 var_b = local_scope->LookupVariable(b, test_only);
2560 EXPECT(!var_b->is_captured()); 2560 EXPECT(!var_b->is_captured());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 // Allocate the class first. 2616 // Allocate the class first.
2617 const String& class_name = String::Handle(Symbols::New("MyClass")); 2617 const String& class_name = String::Handle(Symbols::New("MyClass"));
2618 const Script& script = Script::Handle(); 2618 const Script& script = Script::Handle();
2619 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 2619 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
2620 const Array& functions = Array::Handle(Array::New(1)); 2620 const Array& functions = Array::Handle(Array::New(1));
2621 2621
2622 const Context& context = Context::Handle(Context::New(0)); 2622 const Context& context = Context::Handle(Context::New(0));
2623 Function& parent = Function::Handle(); 2623 Function& parent = Function::Handle();
2624 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 2624 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
2625 parent = Function::New(parent_name, RawFunction::kRegularFunction, 2625 parent = Function::New(parent_name, RawFunction::kRegularFunction,
2626 false, false, false, false, false, cls, 0); 2626 false, false, false, false, false, cls,
2627 TokenPosition::kMinSource);
2627 functions.SetAt(0, parent); 2628 functions.SetAt(0, parent);
2628 cls.SetFunctions(functions); 2629 cls.SetFunctions(functions);
2629 2630
2630 Function& function = Function::Handle(); 2631 Function& function = Function::Handle();
2631 const String& function_name = String::Handle(Symbols::New("foo")); 2632 const String& function_name = String::Handle(Symbols::New("foo"));
2632 function = Function::NewClosureFunction(function_name, parent, 0); 2633 function = Function::NewClosureFunction(
2634 function_name, parent, TokenPosition::kMinSource);
2633 const Closure& closure = Closure::Handle(Closure::New(function, context)); 2635 const Closure& closure = Closure::Handle(Closure::New(function, context));
2634 const Class& closure_class = Class::Handle(closure.clazz()); 2636 const Class& closure_class = Class::Handle(closure.clazz());
2635 EXPECT_EQ(closure_class.id(), kClosureCid); 2637 EXPECT_EQ(closure_class.id(), kClosureCid);
2636 const Function& closure_function = Function::Handle(closure.function()); 2638 const Function& closure_function = Function::Handle(closure.function());
2637 EXPECT_EQ(closure_function.raw(), function.raw()); 2639 EXPECT_EQ(closure_function.raw(), function.raw());
2638 const Context& closure_context = Context::Handle(closure.context()); 2640 const Context& closure_context = Context::Handle(closure.context());
2639 EXPECT_EQ(closure_context.raw(), context.raw()); 2641 EXPECT_EQ(closure_context.raw(), context.raw());
2640 } 2642 }
2641 2643
2642 2644
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 const String& class_name = String::Handle(Symbols::New("ownerClass")); 2687 const String& class_name = String::Handle(Symbols::New("ownerClass"));
2686 const String& lib_name = String::Handle(Symbols::New("ownerLibrary")); 2688 const String& lib_name = String::Handle(Symbols::New("ownerLibrary"));
2687 const Script& script = Script::Handle(); 2689 const Script& script = Script::Handle();
2688 const Class& owner_class = 2690 const Class& owner_class =
2689 Class::Handle(CreateDummyClass(class_name, script)); 2691 Class::Handle(CreateDummyClass(class_name, script));
2690 const Library& owner_library = 2692 const Library& owner_library =
2691 Library::Handle(CreateDummyLibrary(lib_name)); 2693 Library::Handle(CreateDummyLibrary(lib_name));
2692 owner_class.set_library(owner_library); 2694 owner_class.set_library(owner_library);
2693 const String& function_name = String::ZoneHandle(Symbols::New(name)); 2695 const String& function_name = String::ZoneHandle(Symbols::New(name));
2694 return Function::New(function_name, RawFunction::kRegularFunction, 2696 return Function::New(function_name, RawFunction::kRegularFunction,
2695 true, false, false, false, false, owner_class, 0); 2697 true, false, false, false, false, owner_class,
2698 TokenPosition::kMinSource);
2696 } 2699 }
2697 2700
2698 2701
2699 // Test for Code and Instruction object creation. 2702 // Test for Code and Instruction object creation.
2700 VM_TEST_CASE(Code) { 2703 VM_TEST_CASE(Code) {
2701 extern void GenerateIncrement(Assembler* assembler); 2704 extern void GenerateIncrement(Assembler* assembler);
2702 Assembler _assembler_; 2705 Assembler _assembler_;
2703 GenerateIncrement(&_assembler_); 2706 GenerateIncrement(&_assembler_);
2704 const Function& function = Function::Handle(CreateFunction("Test_Code")); 2707 const Function& function = Function::Handle(CreateFunction("Test_Code"));
2705 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_)); 2708 Code& code = Code::Handle(Code::FinalizeCode(function, &_assembler_));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 EXPECT_EQ(150u, handlers.HandlerPCOffset(3)); 2831 EXPECT_EQ(150u, handlers.HandlerPCOffset(3));
2829 EXPECT(!handlers.NeedsStacktrace(3)); 2832 EXPECT(!handlers.NeedsStacktrace(3));
2830 EXPECT(handlers.HasCatchAll(3)); 2833 EXPECT(handlers.HasCatchAll(3));
2831 } 2834 }
2832 2835
2833 2836
2834 VM_TEST_CASE(PcDescriptors) { 2837 VM_TEST_CASE(PcDescriptors) {
2835 DescriptorList* builder = new DescriptorList(0); 2838 DescriptorList* builder = new DescriptorList(0);
2836 2839
2837 // kind, pc_offset, deopt_id, token_pos, try_index 2840 // kind, pc_offset, deopt_id, token_pos, try_index
2838 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 1, 20, 1); 2841 builder->AddDescriptor(RawPcDescriptors::kOther,
2839 builder->AddDescriptor(RawPcDescriptors::kDeopt, 20, 2, 30, 0); 2842 10, 1, TokenPosition(20), 1);
2840 builder->AddDescriptor(RawPcDescriptors::kOther, 30, 3, 40, 1); 2843 builder->AddDescriptor(RawPcDescriptors::kDeopt,
2841 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 4, 40, 2); 2844 20, 2, TokenPosition(30), 0);
2842 builder->AddDescriptor(RawPcDescriptors::kOther, 10, 5, 80, 3); 2845 builder->AddDescriptor(RawPcDescriptors::kOther,
2843 builder->AddDescriptor(RawPcDescriptors::kOther, 80, 6, 150, 3); 2846 30, 3, TokenPosition(40), 1);
2847 builder->AddDescriptor(RawPcDescriptors::kOther,
2848 10, 4, TokenPosition(40), 2);
2849 builder->AddDescriptor(RawPcDescriptors::kOther,
2850 10, 5, TokenPosition(80), 3);
2851 builder->AddDescriptor(RawPcDescriptors::kOther,
2852 80, 6, TokenPosition(150), 3);
2844 2853
2845 PcDescriptors& descriptors = PcDescriptors::Handle(); 2854 PcDescriptors& descriptors = PcDescriptors::Handle();
2846 descriptors ^= builder->FinalizePcDescriptors(0); 2855 descriptors ^= builder->FinalizePcDescriptors(0);
2847 2856
2848 extern void GenerateIncrement(Assembler* assembler); 2857 extern void GenerateIncrement(Assembler* assembler);
2849 Assembler _assembler_; 2858 Assembler _assembler_;
2850 GenerateIncrement(&_assembler_); 2859 GenerateIncrement(&_assembler_);
2851 Code& code = Code::Handle(Code::FinalizeCode( 2860 Code& code = Code::Handle(Code::FinalizeCode(
2852 Function::Handle(CreateFunction("Test_Code")), &_assembler_)); 2861 Function::Handle(CreateFunction("Test_Code")), &_assembler_));
2853 code.set_pc_descriptors(descriptors); 2862 code.set_pc_descriptors(descriptors);
2854 2863
2855 // Verify the PcDescriptor entries by accessing them. 2864 // Verify the PcDescriptor entries by accessing them.
2856 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); 2865 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors());
2857 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind); 2866 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind);
2858 2867
2859 EXPECT_EQ(true, iter.MoveNext()); 2868 EXPECT_EQ(true, iter.MoveNext());
2860 EXPECT_EQ(20, iter.TokenPos()); 2869 EXPECT_EQ(20, iter.TokenPos().value());
2861 EXPECT_EQ(1, iter.TryIndex()); 2870 EXPECT_EQ(1, iter.TryIndex());
2862 EXPECT_EQ(static_cast<uword>(10), iter.PcOffset()); 2871 EXPECT_EQ(static_cast<uword>(10), iter.PcOffset());
2863 EXPECT_EQ(1, iter.DeoptId()); 2872 EXPECT_EQ(1, iter.DeoptId());
2864 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); 2873 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2865 2874
2866 EXPECT_EQ(true, iter.MoveNext()); 2875 EXPECT_EQ(true, iter.MoveNext());
2867 EXPECT_EQ(30, iter.TokenPos()); 2876 EXPECT_EQ(30, iter.TokenPos().value());
2868 EXPECT_EQ(RawPcDescriptors::kDeopt, iter.Kind()); 2877 EXPECT_EQ(RawPcDescriptors::kDeopt, iter.Kind());
2869 2878
2870 EXPECT_EQ(true, iter.MoveNext()); 2879 EXPECT_EQ(true, iter.MoveNext());
2871 EXPECT_EQ(40, iter.TokenPos()); 2880 EXPECT_EQ(40, iter.TokenPos().value());
2872 2881
2873 EXPECT_EQ(true, iter.MoveNext()); 2882 EXPECT_EQ(true, iter.MoveNext());
2874 EXPECT_EQ(40, iter.TokenPos()); 2883 EXPECT_EQ(40, iter.TokenPos().value());
2875 2884
2876 EXPECT_EQ(true, iter.MoveNext()); 2885 EXPECT_EQ(true, iter.MoveNext());
2877 EXPECT_EQ(80, iter.TokenPos()); 2886 EXPECT_EQ(80, iter.TokenPos().value());
2878 2887
2879 EXPECT_EQ(true, iter.MoveNext()); 2888 EXPECT_EQ(true, iter.MoveNext());
2880 EXPECT_EQ(150, iter.TokenPos()); 2889 EXPECT_EQ(150, iter.TokenPos().value());
2881 2890
2882 EXPECT_EQ(3, iter.TryIndex()); 2891 EXPECT_EQ(3, iter.TryIndex());
2883 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset()); 2892 EXPECT_EQ(static_cast<uword>(80), iter.PcOffset());
2884 EXPECT_EQ(150, iter.TokenPos()); 2893 EXPECT_EQ(150, iter.TokenPos().value());
2885 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); 2894 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2886 2895
2887 EXPECT_EQ(false, iter.MoveNext()); 2896 EXPECT_EQ(false, iter.MoveNext());
2888 } 2897 }
2889 2898
2890 2899
2891 VM_TEST_CASE(PcDescriptorsLargeDeltas) { 2900 VM_TEST_CASE(PcDescriptorsLargeDeltas) {
2892 DescriptorList* builder = new DescriptorList(0); 2901 DescriptorList* builder = new DescriptorList(0);
2893 2902
2894 // kind, pc_offset, deopt_id, token_pos, try_index 2903 // kind, pc_offset, deopt_id, token_pos, try_index
2895 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 1, 200, 1); 2904 builder->AddDescriptor(RawPcDescriptors::kOther,
2896 builder->AddDescriptor(RawPcDescriptors::kDeopt, 200, 2, 300, 0); 2905 100, 1, TokenPosition(200), 1);
2897 builder->AddDescriptor(RawPcDescriptors::kOther, 300, 3, 400, 1); 2906 builder->AddDescriptor(RawPcDescriptors::kDeopt,
2898 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 4, 0, 2); 2907 200, 2, TokenPosition(300), 0);
2899 builder->AddDescriptor(RawPcDescriptors::kOther, 100, 5, 800, 3); 2908 builder->AddDescriptor(RawPcDescriptors::kOther,
2900 builder->AddDescriptor(RawPcDescriptors::kOther, 800, 6, 150, 3); 2909 300, 3, TokenPosition(400), 1);
2910 builder->AddDescriptor(RawPcDescriptors::kOther,
2911 100, 4, TokenPosition(0), 2);
2912 builder->AddDescriptor(RawPcDescriptors::kOther,
2913 100, 5, TokenPosition(800), 3);
2914 builder->AddDescriptor(RawPcDescriptors::kOther,
2915 800, 6, TokenPosition(150), 3);
2901 2916
2902 PcDescriptors& descriptors = PcDescriptors::Handle(); 2917 PcDescriptors& descriptors = PcDescriptors::Handle();
2903 descriptors ^= builder->FinalizePcDescriptors(0); 2918 descriptors ^= builder->FinalizePcDescriptors(0);
2904 2919
2905 extern void GenerateIncrement(Assembler* assembler); 2920 extern void GenerateIncrement(Assembler* assembler);
2906 Assembler _assembler_; 2921 Assembler _assembler_;
2907 GenerateIncrement(&_assembler_); 2922 GenerateIncrement(&_assembler_);
2908 Code& code = Code::Handle(Code::FinalizeCode( 2923 Code& code = Code::Handle(Code::FinalizeCode(
2909 Function::Handle(CreateFunction("Test_Code")), &_assembler_)); 2924 Function::Handle(CreateFunction("Test_Code")), &_assembler_));
2910 code.set_pc_descriptors(descriptors); 2925 code.set_pc_descriptors(descriptors);
2911 2926
2912 // Verify the PcDescriptor entries by accessing them. 2927 // Verify the PcDescriptor entries by accessing them.
2913 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); 2928 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors());
2914 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind); 2929 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind);
2915 2930
2916 EXPECT_EQ(true, iter.MoveNext()); 2931 EXPECT_EQ(true, iter.MoveNext());
2917 EXPECT_EQ(200, iter.TokenPos()); 2932 EXPECT_EQ(200, iter.TokenPos().value());
2918 EXPECT_EQ(1, iter.TryIndex()); 2933 EXPECT_EQ(1, iter.TryIndex());
2919 EXPECT_EQ(static_cast<uword>(100), iter.PcOffset()); 2934 EXPECT_EQ(static_cast<uword>(100), iter.PcOffset());
2920 EXPECT_EQ(1, iter.DeoptId()); 2935 EXPECT_EQ(1, iter.DeoptId());
2921 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); 2936 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2922 2937
2923 EXPECT_EQ(true, iter.MoveNext()); 2938 EXPECT_EQ(true, iter.MoveNext());
2924 EXPECT_EQ(300, iter.TokenPos()); 2939 EXPECT_EQ(300, iter.TokenPos().value());
2925 EXPECT_EQ(RawPcDescriptors::kDeopt, iter.Kind()); 2940 EXPECT_EQ(RawPcDescriptors::kDeopt, iter.Kind());
2926 2941
2927 EXPECT_EQ(true, iter.MoveNext()); 2942 EXPECT_EQ(true, iter.MoveNext());
2928 EXPECT_EQ(400, iter.TokenPos()); 2943 EXPECT_EQ(400, iter.TokenPos().value());
2929 2944
2930 EXPECT_EQ(true, iter.MoveNext()); 2945 EXPECT_EQ(true, iter.MoveNext());
2931 EXPECT_EQ(0, iter.TokenPos()); 2946 EXPECT_EQ(0, iter.TokenPos().value());
2932 2947
2933 EXPECT_EQ(true, iter.MoveNext()); 2948 EXPECT_EQ(true, iter.MoveNext());
2934 EXPECT_EQ(800, iter.TokenPos()); 2949 EXPECT_EQ(800, iter.TokenPos().value());
2935 2950
2936 EXPECT_EQ(true, iter.MoveNext()); 2951 EXPECT_EQ(true, iter.MoveNext());
2937 EXPECT_EQ(150, iter.TokenPos()); 2952 EXPECT_EQ(150, iter.TokenPos().value());
2938 2953
2939 EXPECT_EQ(3, iter.TryIndex()); 2954 EXPECT_EQ(3, iter.TryIndex());
2940 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset()); 2955 EXPECT_EQ(static_cast<uword>(800), iter.PcOffset());
2941 EXPECT_EQ(150, iter.TokenPos()); 2956 EXPECT_EQ(150, iter.TokenPos().value());
2942 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind()); 2957 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2943 2958
2944 EXPECT_EQ(false, iter.MoveNext()); 2959 EXPECT_EQ(false, iter.MoveNext());
2945 } 2960 }
2946 2961
2947 2962
2948 static RawClass* CreateTestClass(const char* name) { 2963 static RawClass* CreateTestClass(const char* name) {
2949 const String& class_name = String::Handle(Symbols::New(name)); 2964 const String& class_name = String::Handle(Symbols::New(name));
2950 const Class& cls = Class::Handle( 2965 const Class& cls = Class::Handle(
2951 CreateDummyClass(class_name, Script::Handle())); 2966 CreateDummyClass(class_name, Script::Handle()));
2952 return cls.raw(); 2967 return cls.raw();
2953 } 2968 }
2954 2969
2955 2970
2956 static RawField* CreateTestField(const char* name) { 2971 static RawField* CreateTestField(const char* name) {
2957 const Class& cls = Class::Handle(CreateTestClass("global:")); 2972 const Class& cls = Class::Handle(CreateTestClass("global:"));
2958 const String& field_name = String::Handle(Symbols::New(name)); 2973 const String& field_name = String::Handle(Symbols::New(name));
2959 const Field& field = 2974 const Field& field =
2960 Field::Handle(Field::New(field_name, true, false, false, true, cls, 2975 Field::Handle(Field::New(field_name, true, false, false, true, cls,
2961 Object::dynamic_type(), 0)); 2976 Object::dynamic_type(), TokenPosition::kMinSource));
2962 return field.raw(); 2977 return field.raw();
2963 } 2978 }
2964 2979
2965 2980
2966 VM_TEST_CASE(ClassDictionaryIterator) { 2981 VM_TEST_CASE(ClassDictionaryIterator) {
2967 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6")); 2982 Class& ae66 = Class::ZoneHandle(CreateTestClass("Ae6/6"));
2968 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4")); 2983 Class& re44 = Class::ZoneHandle(CreateTestClass("Re4/4"));
2969 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8")); 2984 Field& ce68 = Field::ZoneHandle(CreateTestField("Ce6/8"));
2970 Field& tee = Field::ZoneHandle(CreateTestField("TEE")); 2985 Field& tee = Field::ZoneHandle(CreateTestField("TEE"));
2971 String& url = String::ZoneHandle(String::New("SBB")); 2986 String& url = String::ZoneHandle(String::New("SBB"));
(...skipping 24 matching lines...) Expand all
2996 const bool is_external = false; 3011 const bool is_external = false;
2997 const bool is_native = false; 3012 const bool is_native = false;
2998 return Function::New(function_name, 3013 return Function::New(function_name,
2999 RawFunction::kRegularFunction, 3014 RawFunction::kRegularFunction,
3000 is_static, 3015 is_static,
3001 is_const, 3016 is_const,
3002 is_abstract, 3017 is_abstract,
3003 is_external, 3018 is_external,
3004 is_native, 3019 is_native,
3005 cls, 3020 cls,
3006 0); 3021 TokenPosition::kMinSource);
3007 } 3022 }
3008 3023
3009 3024
3010 VM_TEST_CASE(ICData) { 3025 VM_TEST_CASE(ICData) {
3011 Function& function = Function::Handle(GetDummyTarget("Bern")); 3026 Function& function = Function::Handle(GetDummyTarget("Bern"));
3012 const intptr_t id = 12; 3027 const intptr_t id = 12;
3013 const intptr_t num_args_tested = 1; 3028 const intptr_t num_args_tested = 1;
3014 const String& target_name = String::Handle(Symbols::New("Thun")); 3029 const String& target_name = String::Handle(Symbols::New("Thun"));
3015 const Array& args_descriptor = 3030 const Array& args_descriptor =
3016 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); 3031 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array()));
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3770 // Allocate the class first. 3785 // Allocate the class first.
3771 const String& class_name = String::Handle(Symbols::New("MyClass")); 3786 const String& class_name = String::Handle(Symbols::New("MyClass"));
3772 const Script& script = Script::Handle(); 3787 const Script& script = Script::Handle();
3773 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 3788 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
3774 const Array& functions = Array::Handle(Array::New(1)); 3789 const Array& functions = Array::Handle(Array::New(1));
3775 const Isolate* iso = Isolate::Current(); 3790 const Isolate* iso = Isolate::Current();
3776 3791
3777 Function& parent = Function::Handle(); 3792 Function& parent = Function::Handle();
3778 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 3793 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
3779 parent = Function::New(parent_name, RawFunction::kRegularFunction, 3794 parent = Function::New(parent_name, RawFunction::kRegularFunction,
3780 false, false, false, false, false, cls, 0); 3795 false, false, false, false, false, cls,
3796 TokenPosition::kMinSource);
3781 functions.SetAt(0, parent); 3797 functions.SetAt(0, parent);
3782 cls.SetFunctions(functions); 3798 cls.SetFunctions(functions);
3783 3799
3784 Function& function = Function::Handle(); 3800 Function& function = Function::Handle();
3785 const String& function_name = String::Handle(Symbols::New("foo")); 3801 const String& function_name = String::Handle(Symbols::New("foo"));
3786 function = Function::NewClosureFunction(function_name, parent, 0); 3802 function = Function::NewClosureFunction(function_name, parent,
3803 TokenPosition::kMinSource);
3787 // Add closure function to class. 3804 // Add closure function to class.
3788 iso->AddClosureFunction(function); 3805 iso->AddClosureFunction(function);
3789 3806
3790 // The closure should return a valid index. 3807 // The closure should return a valid index.
3791 intptr_t good_closure_index = iso->FindClosureIndex(function); 3808 intptr_t good_closure_index = iso->FindClosureIndex(function);
3792 EXPECT_GE(good_closure_index, 0); 3809 EXPECT_GE(good_closure_index, 0);
3793 // The parent function should return an invalid index. 3810 // The parent function should return an invalid index.
3794 intptr_t bad_closure_index = iso->FindClosureIndex(parent); 3811 intptr_t bad_closure_index = iso->FindClosureIndex(parent);
3795 EXPECT_EQ(bad_closure_index, -1); 3812 EXPECT_EQ(bad_closure_index, -1);
3796 3813
3797 // Retrieve closure function via index. 3814 // Retrieve closure function via index.
3798 Function& func_from_index = Function::Handle(); 3815 Function& func_from_index = Function::Handle();
3799 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index); 3816 func_from_index ^= iso->ClosureFunctionFromIndex(good_closure_index);
3800 // Same closure function. 3817 // Same closure function.
3801 EXPECT_EQ(func_from_index.raw(), function.raw()); 3818 EXPECT_EQ(func_from_index.raw(), function.raw());
3802 } 3819 }
3803 3820
3804 3821
3805 VM_TEST_CASE(FindInvocationDispatcherFunctionIndex) { 3822 VM_TEST_CASE(FindInvocationDispatcherFunctionIndex) {
3806 const String& class_name = String::Handle(Symbols::New("MyClass")); 3823 const String& class_name = String::Handle(Symbols::New("MyClass"));
3807 const Script& script = Script::Handle(); 3824 const Script& script = Script::Handle();
3808 const Class& cls = Class::Handle(CreateDummyClass(class_name, script)); 3825 const Class& cls = Class::Handle(CreateDummyClass(class_name, script));
3809 ClassFinalizer::FinalizeTypesInClass(cls); 3826 ClassFinalizer::FinalizeTypesInClass(cls);
3810 3827
3811 const Array& functions = Array::Handle(Array::New(1)); 3828 const Array& functions = Array::Handle(Array::New(1));
3812 Function& parent = Function::Handle(); 3829 Function& parent = Function::Handle();
3813 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 3830 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
3814 parent = Function::New(parent_name, RawFunction::kRegularFunction, 3831 parent = Function::New(parent_name, RawFunction::kRegularFunction,
3815 false, false, false, false, false, cls, 0); 3832 false, false, false, false, false, cls,
3833 TokenPosition::kMinSource);
3816 functions.SetAt(0, parent); 3834 functions.SetAt(0, parent);
3817 cls.SetFunctions(functions); 3835 cls.SetFunctions(functions);
3818 cls.Finalize(); 3836 cls.Finalize();
3819 3837
3820 // Add invocation dispatcher. 3838 // Add invocation dispatcher.
3821 const String& invocation_dispatcher_name = 3839 const String& invocation_dispatcher_name =
3822 String::Handle(Symbols::New("myMethod")); 3840 String::Handle(Symbols::New("myMethod"));
3823 const Array& args_desc = Array::Handle(ArgumentsDescriptor::New(1)); 3841 const Array& args_desc = Array::Handle(ArgumentsDescriptor::New(1));
3824 Function& invocation_dispatcher = Function::Handle(); 3842 Function& invocation_dispatcher = Function::Handle();
3825 invocation_dispatcher ^= 3843 invocation_dispatcher ^=
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
4678 String& test = String::Handle(); 4696 String& test = String::Handle();
4679 String& result = String::Handle(); 4697 String& result = String::Handle();
4680 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4698 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4681 test = String::New(tests[i].in); 4699 test = String::New(tests[i].in);
4682 result = String::IdentifierPrettyName(test); 4700 result = String::IdentifierPrettyName(test);
4683 EXPECT_STREQ(tests[i].out, result.ToCString()); 4701 EXPECT_STREQ(tests[i].out, result.ToCString());
4684 } 4702 }
4685 } 4703 }
4686 4704
4687 } // namespace dart 4705 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698