| 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 "lib/invocation_mirror.h" | 5 #include "lib/invocation_mirror.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" |
| 8 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| 10 #include "vm/object_store.h" | 11 #include "vm/object_store.h" |
| 11 #include "vm/parser.h" | 12 #include "vm/parser.h" |
| 12 #include "vm/port.h" | 13 #include "vm/port.h" |
| 13 #include "vm/resolver.h" | 14 #include "vm/resolver.h" |
| 14 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 15 | 16 |
| 16 namespace dart { | 17 namespace dart { |
| 17 | 18 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 Exceptions::PropagateError(Error::Cast(id_obj)); | 99 Exceptions::PropagateError(Error::Cast(id_obj)); |
| 99 UNREACHABLE(); | 100 UNREACHABLE(); |
| 100 } | 101 } |
| 101 ASSERT(id_obj.IsSmi() || id_obj.IsMint()); | 102 ASSERT(id_obj.IsSmi() || id_obj.IsMint()); |
| 102 Integer& id = Integer::Handle(); | 103 Integer& id = Integer::Handle(); |
| 103 id ^= id_obj.raw(); | 104 id ^= id_obj.raw(); |
| 104 Dart_Port port_id = static_cast<Dart_Port>(id.AsInt64Value()); | 105 Dart_Port port_id = static_cast<Dart_Port>(id.AsInt64Value()); |
| 105 return Bool::Get(PortMap::IsLocalPort(port_id)).raw(); | 106 return Bool::Get(PortMap::IsLocalPort(port_id)).raw(); |
| 106 } | 107 } |
| 107 | 108 |
| 109 static void EnsureConstructorsAreCompiled(const Function& func) { |
| 110 if (func.kind() != RawFunction::kConstructor) return; |
| 111 const Class& cls = Class::Handle(func.Owner()); |
| 112 const Error& error = Error::Handle(cls.EnsureIsFinalized(Isolate::Current())); |
| 113 if (!error.IsNull()) { |
| 114 ThrowInvokeError(error); |
| 115 UNREACHABLE(); |
| 116 } |
| 117 if (!func.HasCode()) { |
| 118 const Error& error = Error::Handle(Compiler::CompileFunction(func)); |
| 119 if (!error.IsNull()) { |
| 120 ThrowInvokeError(error); |
| 121 UNREACHABLE(); |
| 122 } |
| 123 } |
| 124 } |
| 108 | 125 |
| 109 static RawInstance* CreateParameterMirrorList(const Function& func, | 126 static RawInstance* CreateParameterMirrorList(const Function& func, |
| 110 const Instance& owner_mirror) { | 127 const Instance& owner_mirror) { |
| 111 HANDLESCOPE(Isolate::Current()); | 128 HANDLESCOPE(Isolate::Current()); |
| 112 const intptr_t implicit_param_count = func.NumImplicitParameters(); | 129 const intptr_t implicit_param_count = func.NumImplicitParameters(); |
| 113 const intptr_t non_implicit_param_count = func.NumParameters() - | 130 const intptr_t non_implicit_param_count = func.NumParameters() - |
| 114 implicit_param_count; | 131 implicit_param_count; |
| 115 const intptr_t index_of_first_optional_param = | 132 const intptr_t index_of_first_optional_param = |
| 116 non_implicit_param_count - func.NumOptionalParameters(); | 133 non_implicit_param_count - func.NumOptionalParameters(); |
| 117 const intptr_t index_of_first_named_param = | 134 const intptr_t index_of_first_named_param = |
| 118 non_implicit_param_count - func.NumOptionalNamedParameters(); | 135 non_implicit_param_count - func.NumOptionalNamedParameters(); |
| 119 const Array& results = Array::Handle(Array::New(non_implicit_param_count)); | 136 const Array& results = Array::Handle(Array::New(non_implicit_param_count)); |
| 120 const Array& args = Array::Handle(Array::New(9)); | 137 const Array& args = Array::Handle(Array::New(9)); |
| 121 | 138 |
| 122 // Return for synthetic functions and getters. | 139 // Return for synthetic functions and getters. |
| 123 if (func.IsGetterFunction() || | 140 if (func.IsGetterFunction() || |
| 124 func.IsImplicitConstructor() || | 141 func.IsImplicitConstructor() || |
| 125 func.IsImplicitGetterFunction() || | 142 func.IsImplicitGetterFunction() || |
| 126 func.IsImplicitSetterFunction()) { | 143 func.IsImplicitSetterFunction()) { |
| 127 return results.raw(); | 144 return results.raw(); |
| 128 } | 145 } |
| 129 | 146 |
| 130 Smi& pos = Smi::Handle(); | 147 Smi& pos = Smi::Handle(); |
| 131 String& name = String::Handle(); | 148 String& name = String::Handle(); |
| 132 Instance& param = Instance::Handle(); | 149 Instance& param = Instance::Handle(); |
| 133 Bool& is_final = Bool::Handle(); | 150 Bool& is_final = Bool::Handle(); |
| 134 Object& default_value = Object::Handle(); | 151 Object& default_value = Object::Handle(); |
| 135 Object& metadata = Object::Handle(); | 152 Object& metadata = Object::Handle(); |
| 136 | 153 |
| 154 // We force compilation of constructors to ensure the types of initializing |
| 155 // formals have been corrected. We do not force the compilation of all types |
| 156 // of functions because some have no body, e.g. signature functions. |
| 157 EnsureConstructorsAreCompiled(func); |
| 158 |
| 137 // Reparse the function for the following information: | 159 // Reparse the function for the following information: |
| 138 // * The default value of a parameter. | 160 // * The default value of a parameter. |
| 139 // * Whether a parameters has been deflared as final. | 161 // * Whether a parameters has been deflared as final. |
| 140 // * Any metadata associated with the parameter. | 162 // * Any metadata associated with the parameter. |
| 141 const Object& result = Object::Handle(Parser::ParseFunctionParameters(func)); | 163 const Object& result = Object::Handle(Parser::ParseFunctionParameters(func)); |
| 142 if (result.IsError()) { | 164 if (result.IsError()) { |
| 143 ThrowInvokeError(Error::Cast(result)); | 165 ThrowInvokeError(Error::Cast(result)); |
| 144 UNREACHABLE(); | 166 UNREACHABLE(); |
| 145 } | 167 } |
| 146 | 168 |
| (...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 } | 1714 } |
| 1693 | 1715 |
| 1694 | 1716 |
| 1695 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 1717 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |
| 1696 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 1718 GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |
| 1697 const Field& field = Field::Handle(ref.GetFieldReferent()); | 1719 const Field& field = Field::Handle(ref.GetFieldReferent()); |
| 1698 return field.type(); | 1720 return field.type(); |
| 1699 } | 1721 } |
| 1700 | 1722 |
| 1701 } // namespace dart | 1723 } // namespace dart |
| OLD | NEW |