| 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/dart_entry.h" |     8 #include "vm/dart_entry.h" | 
|     9 #include "vm/exceptions.h" |     9 #include "vm/exceptions.h" | 
|    10 #include "vm/object_store.h" |    10 #include "vm/object_store.h" | 
 |    11 #include "vm/parser.h" | 
|    11 #include "vm/port.h" |    12 #include "vm/port.h" | 
|    12 #include "vm/symbols.h" |    13 #include "vm/symbols.h" | 
|    13  |    14  | 
|    14 namespace dart { |    15 namespace dart { | 
|    15  |    16  | 
|    16 static RawInstance* CreateMirror(const String& mirror_class_name, |    17 static RawInstance* CreateMirror(const String& mirror_class_name, | 
|    17                                  const Array& constructor_arguments) { |    18                                  const Array& constructor_arguments) { | 
|    18   const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); |    19   const Library& mirrors_lib = Library::Handle(Library::MirrorsLibrary()); | 
|    19   const String& constructor_name = Symbols::Dot(); |    20   const String& constructor_name = Symbols::Dot(); | 
|    20  |    21  | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|    38     UNREACHABLE(); |    39     UNREACHABLE(); | 
|    39   } |    40   } | 
|    40   ASSERT(id_obj.IsSmi() || id_obj.IsMint()); |    41   ASSERT(id_obj.IsSmi() || id_obj.IsMint()); | 
|    41   Integer& id = Integer::Handle(); |    42   Integer& id = Integer::Handle(); | 
|    42   id ^= id_obj.raw(); |    43   id ^= id_obj.raw(); | 
|    43   Dart_Port port_id = static_cast<Dart_Port>(id.AsInt64Value()); |    44   Dart_Port port_id = static_cast<Dart_Port>(id.AsInt64Value()); | 
|    44   return Bool::Get(PortMap::IsLocalPort(port_id)); |    45   return Bool::Get(PortMap::IsLocalPort(port_id)); | 
|    45 } |    46 } | 
|    46  |    47  | 
|    47  |    48  | 
 |    49 static void ThrowInvokeError(const Error& error); | 
 |    50  | 
 |    51  | 
|    48 static RawInstance* CreateParameterMirrorList(const Function& func, |    52 static RawInstance* CreateParameterMirrorList(const Function& func, | 
|    49                                               const Instance& owner_mirror) { |    53                                               const Instance& owner_mirror) { | 
|    50   HANDLESCOPE(Isolate::Current()); |    54   HANDLESCOPE(Isolate::Current()); | 
|    51   const intptr_t implicit_param_count = func.NumImplicitParameters(); |    55   const intptr_t implicit_param_count = func.NumImplicitParameters(); | 
|    52   const intptr_t non_implicit_param_count = func.NumParameters() - |    56   const intptr_t non_implicit_param_count = func.NumParameters() - | 
|    53                                             implicit_param_count; |    57                                             implicit_param_count; | 
|    54   const intptr_t index_of_first_optional_param = |    58   const intptr_t index_of_first_optional_param = | 
|    55       non_implicit_param_count - func.NumOptionalParameters(); |    59       non_implicit_param_count - func.NumOptionalParameters(); | 
|    56   const intptr_t index_of_first_named_param = |    60   const intptr_t index_of_first_named_param = | 
|    57       non_implicit_param_count - func.NumOptionalNamedParameters(); |    61       non_implicit_param_count - func.NumOptionalNamedParameters(); | 
|    58   const Array& results = Array::Handle(Array::New(non_implicit_param_count)); |    62   const Array& results = Array::Handle(Array::New(non_implicit_param_count)); | 
|    59   const Array& args = Array::Handle(Array::New(6)); |    63   const Array& args = Array::Handle(Array::New(8)); | 
 |    64  | 
|    60   args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func))); |    65   args.SetAt(0, MirrorReference::Handle(MirrorReference::New(func))); | 
|    61   args.SetAt(2, owner_mirror); |    66   args.SetAt(2, owner_mirror); | 
 |    67  | 
|    62   Smi& pos = Smi::Handle(); |    68   Smi& pos = Smi::Handle(); | 
|    63   String& name = String::Handle(); |    69   String& name = String::Handle(); | 
|    64   Instance& param = Instance::Handle(); |    70   Instance& param = Instance::Handle(); | 
 |    71   Bool& is_final = Bool::Handle(); | 
 |    72   Object& default_value = Object::Handle(); | 
 |    73  | 
 |    74   // Reparse the function for the following information: | 
 |    75   // * The default value of a parameter. | 
 |    76   // * Whether a parameters has been deflared as final. | 
 |    77   const Object& result = Object::Handle(Parser::ParseFunctionParameters(func)); | 
 |    78   if (result.IsError()) { | 
 |    79     ThrowInvokeError(Error::Cast(result)); | 
 |    80     UNREACHABLE(); | 
 |    81   } | 
 |    82  | 
 |    83   const Array& param_descriptor = Array::Cast(result); | 
|    65   for (intptr_t i = 0; i < non_implicit_param_count; i++) { |    84   for (intptr_t i = 0; i < non_implicit_param_count; i++) { | 
|    66     pos ^= Smi::New(i); |    85     pos ^= Smi::New(i); | 
|    67     name ^= func.ParameterNameAt(implicit_param_count + i); |    86     name ^= func.ParameterNameAt(implicit_param_count + i); | 
 |    87     is_final ^= param_descriptor.At(i * 2); | 
 |    88     default_value = param_descriptor.At(i * 2 + 1); | 
 |    89     ASSERT(default_value.IsInstance()); | 
 |    90  | 
|    68     args.SetAt(1, name); |    91     args.SetAt(1, name); | 
|    69     args.SetAt(3, pos); |    92     args.SetAt(3, pos); | 
|    70     args.SetAt(4, (i >= index_of_first_optional_param) ? |    93     args.SetAt(4, (i >= index_of_first_optional_param) ? | 
|    71         Bool::True() : Bool::False()); |    94         Bool::True() : Bool::False()); | 
|    72     args.SetAt(5, (i >= index_of_first_named_param) ? |    95     args.SetAt(5, (i >= index_of_first_named_param) ? | 
|    73         Bool::True() : Bool::False()); |    96         Bool::True() : Bool::False()); | 
 |    97     args.SetAt(6, is_final.value() ? Bool::True() : Bool::False()); | 
 |    98     args.SetAt(7, default_value); | 
|    74     param ^= CreateMirror(Symbols::_LocalParameterMirrorImpl(), args); |    99     param ^= CreateMirror(Symbols::_LocalParameterMirrorImpl(), args); | 
|    75     results.SetAt(i, param); |   100     results.SetAt(i, param); | 
|    76   } |   101   } | 
|    77   results.MakeImmutable(); |   102   results.MakeImmutable(); | 
|    78   return results.raw(); |   103   return results.raw(); | 
|    79 } |   104 } | 
|    80  |   105  | 
|    81  |   106  | 
|    82 static RawInstance* CreateTypeVariableMirror(const TypeParameter& param, |   107 static RawInstance* CreateTypeVariableMirror(const TypeParameter& param, | 
|    83                                              const Instance& owner_mirror) { |   108                                              const Instance& owner_mirror) { | 
| (...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1294 } |  1319 } | 
|  1295  |  1320  | 
|  1296  |  1321  | 
|  1297 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { |  1322 DEFINE_NATIVE_ENTRY(VariableMirror_type, 1) { | 
|  1298   GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); |  1323   GET_NON_NULL_NATIVE_ARGUMENT(MirrorReference, ref, arguments->NativeArgAt(0)); | 
|  1299   const Field& field = Field::Handle(ref.GetFieldReferent()); |  1324   const Field& field = Field::Handle(ref.GetFieldReferent()); | 
|  1300   return field.type(); |  1325   return field.type(); | 
|  1301 } |  1326 } | 
|  1302  |  1327  | 
|  1303 }  // namespace dart |  1328 }  // namespace dart | 
| OLD | NEW |