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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 #include "bin/builtin.h" | 9 #include "bin/builtin.h" |
10 #include "bin/dartutils.h" | 10 #include "bin/dartutils.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 parsed_function.set_expression_temp_var( | 184 parsed_function.set_expression_temp_var( |
185 ParsedFunction::CreateExpressionTempVar(0)); | 185 ParsedFunction::CreateExpressionTempVar(0)); |
186 node_sequence_->scope()->AddVariable(parsed_function.expression_temp_var()); | 186 node_sequence_->scope()->AddVariable(parsed_function.expression_temp_var()); |
187 parsed_function.AllocateVariables(); | 187 parsed_function.AllocateVariables(); |
188 const Error& error = | 188 const Error& error = |
189 Error::Handle(Compiler::CompileParsedFunction(parsed_function)); | 189 Error::Handle(Compiler::CompileParsedFunction(parsed_function)); |
190 EXPECT(error.IsNull()); | 190 EXPECT(error.IsNull()); |
191 } | 191 } |
192 | 192 |
193 | 193 |
| 194 LocalVariable* CodeGenTest::CreateTempConstVariable(const char* name_part) { |
| 195 char name[64]; |
| 196 OS::SNPrint(name, 64, ":%s", name_part); |
| 197 LocalVariable* temp = |
| 198 new LocalVariable(0, |
| 199 String::ZoneHandle(String::NewSymbol(name)), |
| 200 Type::ZoneHandle(Type::DynamicType())); |
| 201 temp->set_is_final(); |
| 202 node_sequence_->scope()->AddVariable(temp); |
| 203 return temp; |
| 204 } |
| 205 |
| 206 |
194 bool CompilerTest::TestCompileScript(const Library& library, | 207 bool CompilerTest::TestCompileScript(const Library& library, |
195 const Script& script) { | 208 const Script& script) { |
196 Isolate* isolate = Isolate::Current(); | 209 Isolate* isolate = Isolate::Current(); |
197 ASSERT(isolate != NULL); | 210 ASSERT(isolate != NULL); |
198 const Error& error = Error::Handle(Compiler::Compile(library, script)); | 211 const Error& error = Error::Handle(Compiler::Compile(library, script)); |
199 return error.IsNull(); | 212 return error.IsNull(); |
200 } | 213 } |
201 | 214 |
202 | 215 |
203 bool CompilerTest::TestCompileFunction(const Function& function) { | 216 bool CompilerTest::TestCompileFunction(const Function& function) { |
204 Isolate* isolate = Isolate::Current(); | 217 Isolate* isolate = Isolate::Current(); |
205 ASSERT(isolate != NULL); | 218 ASSERT(isolate != NULL); |
206 ASSERT(ClassFinalizer::AllClassesFinalized()); | 219 ASSERT(ClassFinalizer::AllClassesFinalized()); |
207 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 220 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
208 return error.IsNull(); | 221 return error.IsNull(); |
209 } | 222 } |
210 | 223 |
211 } // namespace dart | 224 } // namespace dart |
OLD | NEW |