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

Unified Diff: runtime/vm/code_generator_test.cc

Issue 11468016: Rename GET_NATIVE_ARGUMENT macro to GET_NON_NULL_NATIVE_ARGUMENT. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/lib/weak_property.cc ('k') | runtime/vm/native_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator_test.cc
===================================================================
--- runtime/vm/code_generator_test.cc (revision 15918)
+++ runtime/vm/code_generator_test.cc (working copy)
@@ -396,7 +396,7 @@
function.set_parameter_types(Array::Handle(Array::New(num_params)));
function.set_parameter_names(Array::Handle(Array::New(num_params)));
const Type& param_type = Type::Handle(Type::DynamicType());
- for (int i = 0; i < num_params - 1; i++) {
+ for (int i = 0; i < num_params; i++) {
function.SetParameterTypeAt(i, param_type);
}
const String& native_name =
@@ -465,6 +465,55 @@
Smi::New(0 + 1 + 1 + 2 + 3))
+// Tested Dart code:
+// int sum(a, b, c) native: "TestNonNullSmiSum";
+// The native entry TestNonNullSmiSum implements sum natively.
+CODEGEN_TEST_GENERATE(NativeNonNullSumCodegen, test) {
+ SequenceNode* node_seq = test->node_sequence();
+ const int num_params = 3;
+ LocalScope* local_scope = node_seq->scope();
+ local_scope->AddVariable(NewTestLocalVariable("a"));
+ local_scope->AddVariable(NewTestLocalVariable("b"));
+ local_scope->AddVariable(NewTestLocalVariable("c"));
+ ASSERT(local_scope->num_variables() == num_params);
+ const Function& function = test->function();
+ function.set_is_native(true);
+ function.set_num_fixed_parameters(num_params);
+ ASSERT(!function.HasOptionalParameters());
+ function.set_parameter_types(Array::Handle(Array::New(num_params)));
+ function.set_parameter_names(Array::Handle(Array::New(num_params)));
+ const Type& param_type = Type::Handle(Type::DynamicType());
+ for (int i = 0; i < num_params; i++) {
+ function.SetParameterTypeAt(i, param_type);
+ }
+ const String& native_name =
+ String::ZoneHandle(Symbols::New("TestNonNullSmiSum"));
+ NativeFunction native_function =
+ reinterpret_cast<NativeFunction>(TestNonNullSmiSum);
+ node_seq->Add(new ReturnNode(kPos,
+ new NativeBodyNode(kPos,
+ function,
+ native_name,
+ native_function)));
+}
+
+
+// Tested Dart code, calling function sum declared above:
+// return sum(1, null, 3);
+CODEGEN_TEST2_GENERATE(StaticNonNullSumCallCodegen, function, test) {
+ SequenceNode* node_seq = test->node_sequence();
+ ArgumentListNode* arguments = new ArgumentListNode(kPos);
+ arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))));
+ arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle()));
+ arguments->Add(new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))));
+ node_seq->Add(new ReturnNode(kPos,
+ new StaticCallNode(kPos, function, arguments)));
+}
+CODEGEN_TEST2_RUN(StaticNonNullSumCallCodegen,
+ NativeNonNullSumCodegen,
+ Smi::New(1 + 3))
+
+
// Test allocation of dart objects.
CODEGEN_TEST_GENERATE(AllocateNewObjectCodegen, test) {
const char* kScriptChars =
« no previous file with comments | « runtime/lib/weak_property.cc ('k') | runtime/vm/native_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698