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

Side by Side Diff: runtime/vm/code_generator.cc

Issue 18801007: Support type parameters and classes as expression in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "vm/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 location, Symbols::Empty(), Symbols::Empty(), 211 location, Symbols::Empty(), Symbols::Empty(),
212 Symbols::Empty(), malformed_error_message); 212 Symbols::Empty(), malformed_error_message);
213 UNREACHABLE(); 213 UNREACHABLE();
214 } 214 }
215 } 215 }
216 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated()); 216 ASSERT(type_arguments.IsNull() || type_arguments.IsInstantiated());
217 instance.SetTypeArguments(type_arguments); 217 instance.SetTypeArguments(type_arguments);
218 } 218 }
219 219
220 220
221 // Instantiate type.
222 // Arg0: uninstantiated type.
223 // Arg1: instantiator type arguments.
224 // Return value: instantiated type.
225 DEFINE_RUNTIME_ENTRY(InstantiateType, 2) {
226 ASSERT(arguments.ArgCount() == kInstantiateTypeRuntimeEntry.argument_count());
227 AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(0));
228 const AbstractTypeArguments& instantiator =
229 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(1));
230 ASSERT(!type.IsNull() && !type.IsInstantiated());
231 ASSERT(instantiator.IsNull() || instantiator.IsInstantiated());
232 Error& malformed_error = Error::Handle();
233 type = type.InstantiateFrom(instantiator, &malformed_error);
234 if (!malformed_error.IsNull()) {
235 // Throw a dynamic type error.
236 const intptr_t location = GetCallerLocation();
237 String& malformed_error_message = String::Handle(
238 String::New(malformed_error.ToErrorCString()));
239 Exceptions::CreateAndThrowTypeError(
240 location, Symbols::Empty(), Symbols::Empty(),
241 Symbols::Empty(), malformed_error_message);
242 UNREACHABLE();
243 }
244 ASSERT(!type.IsNull() && type.IsInstantiated());
245 arguments.SetReturn(type);
246 }
247
248
221 // Instantiate type arguments. 249 // Instantiate type arguments.
222 // Arg0: uninstantiated type arguments. 250 // Arg0: uninstantiated type arguments.
223 // Arg1: instantiator type arguments. 251 // Arg1: instantiator type arguments.
224 // Return value: instantiated type arguments. 252 // Return value: instantiated type arguments.
225 DEFINE_RUNTIME_ENTRY(InstantiateTypeArguments, 2) { 253 DEFINE_RUNTIME_ENTRY(InstantiateTypeArguments, 2) {
226 ASSERT(arguments.ArgCount() == 254 ASSERT(arguments.ArgCount() ==
227 kInstantiateTypeArgumentsRuntimeEntry.argument_count()); 255 kInstantiateTypeArgumentsRuntimeEntry.argument_count());
228 AbstractTypeArguments& type_arguments = 256 AbstractTypeArguments& type_arguments =
229 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(0)); 257 AbstractTypeArguments::CheckedHandle(arguments.ArgAt(0));
230 const AbstractTypeArguments& instantiator = 258 const AbstractTypeArguments& instantiator =
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 // Arg1: Value that is being stored. 1912 // Arg1: Value that is being stored.
1885 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1913 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1886 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1914 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1887 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1915 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1888 const Object& value = Object::Handle(arguments.ArgAt(1)); 1916 const Object& value = Object::Handle(arguments.ArgAt(1));
1889 1917
1890 field.UpdateCid(value.GetClassId()); 1918 field.UpdateCid(value.GetClassId());
1891 } 1919 }
1892 1920
1893 } // namespace dart 1921 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698