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

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

Issue 1870343002: - Refactor Symbol allocation to expect a thread parameter. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review feedback. Created 4 years, 8 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/ast_printer_test.cc ('k') | runtime/vm/ast_transformer.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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/ast.h" 6 #include "vm/ast.h"
7 #include "vm/heap.h" 7 #include "vm/heap.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
11 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 TEST_CASE(Ast) { 15 TEST_CASE(Ast) {
16 LocalVariable* v = new LocalVariable(TokenPosition::kNoSource, 16 LocalVariable* v = new LocalVariable(
17 String::ZoneHandle(Symbols::New("v")), 17 TokenPosition::kNoSource,
18 Type::ZoneHandle(Type::DynamicType())); 18 String::ZoneHandle(Symbols::New(thread, "v")),
19 Type::ZoneHandle(Type::DynamicType()));
19 AstNode* ll = new LoadLocalNode(TokenPosition::kNoSource, v); 20 AstNode* ll = new LoadLocalNode(TokenPosition::kNoSource, v);
20 EXPECT(ll->IsLoadLocalNode()); 21 EXPECT(ll->IsLoadLocalNode());
21 EXPECT(!ll->IsLiteralNode()); 22 EXPECT(!ll->IsLiteralNode());
22 LoadLocalNode* lln = ll->AsLoadLocalNode(); 23 LoadLocalNode* lln = ll->AsLoadLocalNode();
23 EXPECT(NULL != lln); 24 EXPECT(NULL != lln);
24 v->set_index(1); 25 v->set_index(1);
25 EXPECT_EQ(1, v->index()); 26 EXPECT_EQ(1, v->index());
26 27
27 LocalVariable* p = new LocalVariable(TokenPosition::kNoSource, 28 LocalVariable* p = new LocalVariable(
28 String::ZoneHandle(Symbols::New("p")), 29 TokenPosition::kNoSource,
29 Type::ZoneHandle(Type::DynamicType())); 30 String::ZoneHandle(Symbols::New(thread, "p")),
31 Type::ZoneHandle(Type::DynamicType()));
30 EXPECT(!p->HasIndex()); 32 EXPECT(!p->HasIndex());
31 p->set_index(-1); 33 p->set_index(-1);
32 EXPECT(p->HasIndex()); 34 EXPECT(p->HasIndex());
33 EXPECT_EQ(-1, p->index()); 35 EXPECT_EQ(-1, p->index());
34 36
35 ReturnNode* r = new ReturnNode(TokenPosition::kNoSource, lln); 37 ReturnNode* r = new ReturnNode(TokenPosition::kNoSource, lln);
36 EXPECT_EQ(lln, r->value()); 38 EXPECT_EQ(lln, r->value());
37 39
38 LiteralNode* l = new LiteralNode(TokenPosition::kNoSource, 40 LiteralNode* l = new LiteralNode(TokenPosition::kNoSource,
39 Smi::ZoneHandle(Smi::New(3))); 41 Smi::ZoneHandle(Smi::New(3)));
(...skipping 17 matching lines...) Expand all
57 new LiteralNode(TokenPosition(2), Smi::ZoneHandle(Smi::New(3))); 59 new LiteralNode(TokenPosition(2), Smi::ZoneHandle(Smi::New(3)));
58 ReturnNode* return_node = 60 ReturnNode* return_node =
59 new ReturnNode(TokenPosition(3), literal_node); 61 new ReturnNode(TokenPosition(3), literal_node);
60 sequence_node->Add(return_node); 62 sequence_node->Add(return_node);
61 GrowableArray<AstNode*> nodes; 63 GrowableArray<AstNode*> nodes;
62 sequence_node->CollectAllNodes(&nodes); 64 sequence_node->CollectAllNodes(&nodes);
63 EXPECT_EQ(3, nodes.length()); 65 EXPECT_EQ(3, nodes.length());
64 } 66 }
65 67
66 } // namespace dart 68 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast_printer_test.cc ('k') | runtime/vm/ast_transformer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698