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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/flow_graph_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 24832)
+++ runtime/vm/code_generator.cc (working copy)
@@ -218,6 +218,34 @@
}
+// Instantiate type.
+// Arg0: uninstantiated type.
+// Arg1: instantiator type arguments.
+// Return value: instantiated type.
+DEFINE_RUNTIME_ENTRY(InstantiateType, 2) {
+ ASSERT(arguments.ArgCount() == kInstantiateTypeRuntimeEntry.argument_count());
+ AbstractType& type = AbstractType::CheckedHandle(arguments.ArgAt(0));
+ const AbstractTypeArguments& instantiator =
+ AbstractTypeArguments::CheckedHandle(arguments.ArgAt(1));
+ ASSERT(!type.IsNull() && !type.IsInstantiated());
+ ASSERT(instantiator.IsNull() || instantiator.IsInstantiated());
+ Error& malformed_error = Error::Handle();
+ type = type.InstantiateFrom(instantiator, &malformed_error);
+ if (!malformed_error.IsNull()) {
+ // Throw a dynamic type error.
+ const intptr_t location = GetCallerLocation();
+ String& malformed_error_message = String::Handle(
+ String::New(malformed_error.ToErrorCString()));
+ Exceptions::CreateAndThrowTypeError(
+ location, Symbols::Empty(), Symbols::Empty(),
+ Symbols::Empty(), malformed_error_message);
+ UNREACHABLE();
+ }
+ ASSERT(!type.IsNull() && type.IsInstantiated());
+ arguments.SetReturn(type);
+}
+
+
// Instantiate type arguments.
// Arg0: uninstantiated type arguments.
// Arg1: instantiator type arguments.
« 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