| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return url; | 136 return url; |
| 137 } | 137 } |
| 138 return Api::Success(Isolate::Current()); | 138 return Api::Success(Isolate::Current()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 uword AssemblerTest::Assemble() { | 142 uword AssemblerTest::Assemble() { |
| 143 const String& function_name = String::ZoneHandle(Symbols::New(name_)); | 143 const String& function_name = String::ZoneHandle(Symbols::New(name_)); |
| 144 Function& function = Function::ZoneHandle( | 144 Function& function = Function::ZoneHandle( |
| 145 Function::New(function_name, RawFunction::kRegularFunction, | 145 Function::New(function_name, RawFunction::kRegularFunction, |
| 146 true, false, false, 0)); | 146 true, false, false, false, 0)); |
| 147 const Code& code = Code::Handle(Code::FinalizeCode(function, assembler_)); | 147 const Code& code = Code::Handle(Code::FinalizeCode(function, assembler_)); |
| 148 if (FLAG_disassemble) { | 148 if (FLAG_disassemble) { |
| 149 OS::Print("Code for test '%s' {\n", name_); | 149 OS::Print("Code for test '%s' {\n", name_); |
| 150 const Instructions& instructions = | 150 const Instructions& instructions = |
| 151 Instructions::Handle(code.instructions()); | 151 Instructions::Handle(code.instructions()); |
| 152 uword start = instructions.EntryPoint(); | 152 uword start = instructions.EntryPoint(); |
| 153 Disassembler::Disassemble(start, start + assembler_->CodeSize()); | 153 Disassembler::Disassemble(start, start + assembler_->CodeSize()); |
| 154 OS::Print("}\n"); | 154 OS::Print("}\n"); |
| 155 } | 155 } |
| 156 const Instructions& instructions = Instructions::Handle(code.instructions()); | 156 const Instructions& instructions = Instructions::Handle(code.instructions()); |
| 157 return instructions.EntryPoint(); | 157 return instructions.EntryPoint(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 | 160 |
| 161 CodeGenTest::CodeGenTest(const char* name) | 161 CodeGenTest::CodeGenTest(const char* name) |
| 162 : function_(Function::ZoneHandle()), | 162 : function_(Function::ZoneHandle()), |
| 163 node_sequence_(new SequenceNode(Scanner::kDummyTokenIndex, | 163 node_sequence_(new SequenceNode(Scanner::kDummyTokenIndex, |
| 164 new LocalScope(NULL, 0, 0))), | 164 new LocalScope(NULL, 0, 0))), |
| 165 default_parameter_values_(Array::ZoneHandle()) { | 165 default_parameter_values_(Array::ZoneHandle()) { |
| 166 ASSERT(name != NULL); | 166 ASSERT(name != NULL); |
| 167 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 167 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
| 168 function_ = Function::New( | 168 function_ = Function::New( |
| 169 function_name, RawFunction::kRegularFunction, true, false, false, 0); | 169 function_name, RawFunction::kRegularFunction, |
| 170 true, false, false, false, 0); |
| 170 function_.set_result_type(Type::Handle(Type::DynamicType())); | 171 function_.set_result_type(Type::Handle(Type::DynamicType())); |
| 171 // Add function to a class and that class to the class dictionary so that | 172 // Add function to a class and that class to the class dictionary so that |
| 172 // frame walking can be used. | 173 // frame walking can be used. |
| 173 Class& cls = Class::ZoneHandle(); | 174 Class& cls = Class::ZoneHandle(); |
| 174 const Script& script = Script::Handle(); | 175 const Script& script = Script::Handle(); |
| 175 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); | 176 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); |
| 176 const Array& functions = Array::Handle(Array::New(1)); | 177 const Array& functions = Array::Handle(Array::New(1)); |
| 177 functions.SetAt(0, function_); | 178 functions.SetAt(0, function_); |
| 178 cls.SetFunctions(functions); | 179 cls.SetFunctions(functions); |
| 179 Library& lib = Library::Handle(Library::CoreLibrary()); | 180 Library& lib = Library::Handle(Library::CoreLibrary()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 221 |
| 221 bool CompilerTest::TestCompileFunction(const Function& function) { | 222 bool CompilerTest::TestCompileFunction(const Function& function) { |
| 222 Isolate* isolate = Isolate::Current(); | 223 Isolate* isolate = Isolate::Current(); |
| 223 ASSERT(isolate != NULL); | 224 ASSERT(isolate != NULL); |
| 224 ASSERT(ClassFinalizer::AllClassesFinalized()); | 225 ASSERT(ClassFinalizer::AllClassesFinalized()); |
| 225 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 226 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| 226 return error.IsNull(); | 227 return error.IsNull(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 } // namespace dart | 230 } // namespace dart |
| OLD | NEW |