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

Side by Side Diff: runtime/lib/mirrors.cc

Issue 1311613005: Add ParameterMirror.isInitializingFormal to dart:mirrors Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
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 "lib/mirrors.h" 5 #include "lib/mirrors.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bootstrap_natives.h" 8 #include "vm/bootstrap_natives.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const Instance& owner_mirror) { 111 const Instance& owner_mirror) {
112 HANDLESCOPE(Isolate::Current()); 112 HANDLESCOPE(Isolate::Current());
113 const intptr_t implicit_param_count = func.NumImplicitParameters(); 113 const intptr_t implicit_param_count = func.NumImplicitParameters();
114 const intptr_t non_implicit_param_count = func.NumParameters() - 114 const intptr_t non_implicit_param_count = func.NumParameters() -
115 implicit_param_count; 115 implicit_param_count;
116 const intptr_t index_of_first_optional_param = 116 const intptr_t index_of_first_optional_param =
117 non_implicit_param_count - func.NumOptionalParameters(); 117 non_implicit_param_count - func.NumOptionalParameters();
118 const intptr_t index_of_first_named_param = 118 const intptr_t index_of_first_named_param =
119 non_implicit_param_count - func.NumOptionalNamedParameters(); 119 non_implicit_param_count - func.NumOptionalNamedParameters();
120 const Array& results = Array::Handle(Array::New(non_implicit_param_count)); 120 const Array& results = Array::Handle(Array::New(non_implicit_param_count));
121 const Array& args = Array::Handle(Array::New(9)); 121 const Array& args = Array::Handle(Array::New(10));
122 122
123 Smi& pos = Smi::Handle(); 123 Smi& pos = Smi::Handle();
124 String& name = String::Handle(); 124 String& name = String::Handle();
125 Instance& param = Instance::Handle(); 125 Instance& param = Instance::Handle();
126 Bool& is_final = Bool::Handle(); 126 Bool& is_final = Bool::Handle();
127 Object& default_value = Object::Handle(); 127 Object& default_value = Object::Handle();
128 Object& metadata = Object::Handle(); 128 Object& metadata = Object::Handle();
129 Object& is_field_initializer = Object::Handle();
129 130
130 // We force compilation of constructors to ensure the types of initializing 131 // We force compilation of constructors to ensure the types of initializing
131 // formals have been corrected. We do not force the compilation of all types 132 // formals have been corrected. We do not force the compilation of all types
132 // of functions because some have no body, e.g. signature functions. 133 // of functions because some have no body, e.g. signature functions.
133 EnsureConstructorsAreCompiled(func); 134 EnsureConstructorsAreCompiled(func);
134 135
135 bool has_extra_parameter_info = true; 136 bool has_extra_parameter_info = true;
136 if (non_implicit_param_count == 0) { 137 if (non_implicit_param_count == 0) {
137 has_extra_parameter_info = false; 138 has_extra_parameter_info = false;
138 } 139 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 for (intptr_t i = 0; i < non_implicit_param_count; i++) { 171 for (intptr_t i = 0; i < non_implicit_param_count; i++) {
171 pos ^= Smi::New(i); 172 pos ^= Smi::New(i);
172 name ^= func.ParameterNameAt(implicit_param_count + i); 173 name ^= func.ParameterNameAt(implicit_param_count + i);
173 if (has_extra_parameter_info) { 174 if (has_extra_parameter_info) {
174 is_final ^= param_descriptor.At(i * Parser::kParameterEntrySize + 175 is_final ^= param_descriptor.At(i * Parser::kParameterEntrySize +
175 Parser::kParameterIsFinalOffset); 176 Parser::kParameterIsFinalOffset);
176 default_value = param_descriptor.At(i * Parser::kParameterEntrySize + 177 default_value = param_descriptor.At(i * Parser::kParameterEntrySize +
177 Parser::kParameterDefaultValueOffset); 178 Parser::kParameterDefaultValueOffset);
178 metadata = param_descriptor.At(i * Parser::kParameterEntrySize + 179 metadata = param_descriptor.At(i * Parser::kParameterEntrySize +
179 Parser::kParameterMetadataOffset); 180 Parser::kParameterMetadataOffset);
181 is_field_initializer = param_descriptor.At(
182 i * Parser::kParameterEntrySize +
183 Parser::kParameterIsFieldInitializorOffset);
180 } 184 }
181 ASSERT(default_value.IsNull() || default_value.IsInstance()); 185 ASSERT(default_value.IsNull() || default_value.IsInstance());
182 186
183 // Arguments 0 (referent) and 2 (owner) are the same for all parameters. See 187 // Arguments 0 (referent) and 2 (owner) are the same for all parameters. See
184 // above. 188 // above.
185 args.SetAt(1, name); 189 args.SetAt(1, name);
186 args.SetAt(3, pos); 190 args.SetAt(3, pos);
187 args.SetAt(4, Bool::Get(i >= index_of_first_optional_param)); 191 args.SetAt(4, Bool::Get(i >= index_of_first_optional_param));
188 args.SetAt(5, Bool::Get(i >= index_of_first_named_param)); 192 args.SetAt(5, Bool::Get(i >= index_of_first_named_param));
189 args.SetAt(6, is_final); 193 args.SetAt(6, is_final);
190 args.SetAt(7, default_value); 194 args.SetAt(7, default_value);
191 args.SetAt(8, metadata); 195 args.SetAt(8, metadata);
196 args.SetAt(9, is_field_initializer);
192 param ^= CreateMirror(Symbols::_LocalParameterMirror(), args); 197 param ^= CreateMirror(Symbols::_LocalParameterMirror(), args);
193 results.SetAt(i, param); 198 results.SetAt(i, param);
194 } 199 }
195 results.MakeImmutable(); 200 results.MakeImmutable();
196 return results.raw(); 201 return results.raw();
197 } 202 }
198 203
199 204
200 static RawInstance* CreateTypeVariableMirror(const TypeParameter& param, 205 static RawInstance* CreateTypeVariableMirror(const TypeParameter& param,
201 const Instance& owner_mirror) { 206 const Instance& owner_mirror) {
(...skipping 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 } 2102 }
2098 2103
2099 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) { 2104 DEFINE_NATIVE_ENTRY(TypeMirror_subtypeTest, 2) {
2100 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0)); 2105 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, a, arguments->NativeArgAt(0));
2101 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1)); 2106 GET_NON_NULL_NATIVE_ARGUMENT(AbstractType, b, arguments->NativeArgAt(1));
2102 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw(); 2107 return Bool::Get(a.IsSubtypeOf(b, NULL)).raw();
2103 } 2108 }
2104 2109
2105 2110
2106 } // namespace dart 2111 } // namespace dart
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart ('k') | runtime/lib/mirrors_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698