Skip to content
This repository
Browse code

Attempt to pass arguments in Rakudo

  • Loading branch information...
commit 44a985f123309783b43304bc4268cde93aba1ef3 1 parent 690db53
Duke Leto authored June 29, 2010

Showing 2 changed files with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. 16  plparrot.c
  2. 5  plperl6.pir
16  plparrot.c
@@ -91,7 +91,8 @@ Parrot_String create_string_const(const char *name);
91 91
 Parrot_PMC create_pmc(const char *name);
92 92
 Datum       plparrot_make_sausage(Parrot_Interp interp, Parrot_PMC pmc, FunctionCallInfo fcinfo);
93 93
 void plparrot_secure(Parrot_Interp interp);
94  
-Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code);
  94
+Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code,
  95
+FunctionCallInfo fcinfo, int numargs);
95 96
 
96 97
 void plparrot_push_pgdatatype_pmc(Parrot_PMC, FunctionCallInfo, int);
97 98
 
@@ -211,7 +212,7 @@ plperl6_func_handler(PG_FUNCTION_ARGS)
211 212
 
212 213
     proc_src = TextDatum2String(procsrc_datum);
213 214
     length   = strlen(proc_src);
214  
-    result   = plperl6_run(interp, create_string(proc_src) );
  215
+    result   = plperl6_run(interp, create_string(proc_src), fcinfo, numargs );
215 216
 
216 217
     if (Parrot_PMC_get_bool(interp,result)) {
217 218
         tmp_pmc = Parrot_PMC_pop_pmc(interp, result);
@@ -450,12 +451,15 @@ plparrot_call_handler(PG_FUNCTION_ARGS)
450 451
     return retval;
451 452
 }
452 453
 
453  
-Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code)
  454
+Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code,
  455
+FunctionCallInfo fcinfo, int numargs)
454 456
 {
455 457
     char *tmp, *errmsg;
456 458
     Parrot_String err;
457 459
     Parrot_PMC result   = create_pmc("ResizablePMCArray");
458 460
     Parrot_PMC func_pmc = Parrot_compile_string(interp, create_string_const("PIR"), PLPERL6, &err);
  461
+    Parrot_PMC func_args = create_pmc("ResizablePMCArray");
  462
+    int i;
459 463
 
460 464
     if (!Parrot_str_is_null(interp, err)) {
461 465
         tmp = Parrot_str_to_cstring(interp, err);
@@ -464,7 +468,11 @@ Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code)
464 468
         elog(ERROR, "Error compiling perl6 function: %s", errmsg);
465 469
     }
466 470
 
467  
-    Parrot_ext_call(interp, func_pmc, "S->Pf", code, &result);
  471
+    for (i = 0; i < numargs; i++) {
  472
+        plparrot_push_pgdatatype_pmc(func_args, fcinfo, i);
  473
+    }
  474
+
  475
+    Parrot_ext_call(interp, func_pmc, "SPf->Pf", code, func_args, &result);
468 476
 
469 477
     return result;
470 478
 
5  plperl6.pir
... ...
@@ -1,5 +1,6 @@
1 1
 .sub run
2 2
     .param string code
  3
+    .param pmc args :slurpy
3 4
     $S0 = "my $r = eval q<<<\nsub {"
4 5
     $S1 = "}\n>>>; $r.()"
5 6
     code = $S0 . code
@@ -9,7 +10,9 @@
9 10
     say code
10 11
     $P0 = compreg "perl6"
11 12
     $P1 = $P0.'compile'(code)
12  
-    $P2 = $P1()
  13
+    say "args="
  14
+    _dumper(args)
  15
+    $P2 = $P1(args)
13 16
     print "code returned: "
14 17
     _dumper($P2)
15 18
     .return($P2)

0 notes on commit 44a985f

Please sign in to comment.
Something went wrong with that request. Please try again.