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