Skip to content
Browse files

Attemp to use Parrot_load_bytecode to load P6object.pbc

Loading PIR which does load_bytecode did not seem to work, so we attempt to
call Parrot_load_bytecode(interp, "P6object.pbc") before we load our PIR
that intercepts file I/O.

This currently coredumps in parrot_split_path_ext, which is called by Parrot_load_bytecode.
  • Loading branch information...
1 parent ae65615 commit 1ae4402fbad6a724b3db31fac0287b1e1f76de43 @leto committed Apr 23, 2010
Showing with 45 additions and 4 deletions.
  1. +3 −1 bin/text2macro.pl
  2. +1 −0 plparrot.c
  3. +1 −3 plparrot.h
  4. +40 −0 plparrot_secure.pir
View
4 bin/text2macro.pl 100644 → 100755
@@ -1,4 +1,6 @@
-# This is borrowed from PostgreSQL, it is just a copy for the
+#!/usr/bin/env perl
+
+# This is borrowed from PostgreSQL, it is just a copy for the
# convenience of PL/Parrot developers
# $PostgreSQL:$
View
1 plparrot.c
@@ -306,6 +306,7 @@ void plparrot_secure(Parrot_Interp interp)
Parrot_PMC func_pmc;
Parrot_String err;
+ Parrot_load_bytecode(interp,"P6object.pbc");
func_pmc = Parrot_compile_string(interp, create_string("PIR"), PLPARROT_SECURE, &err);
Parrot_ext_call(interp, func_pmc, "P->", interp);
}
View
4 plparrot.h
@@ -1,7 +1,7 @@
/*
* DO NOT EDIT - THIS FILE IS AUTOGENERATED - CHANGES WILL BE LOST
- * Written by text2macro.pl from /Users/leto/git/plparrot/plparrot_secure.pir
+ * Written by ./bin/text2macro.pl from plparrot_secure.pir
*/
#define PLPARROT_SECURE \
".namespace [\"PLParrot\"]\n" \
@@ -34,8 +34,6 @@
".namespace []\n" \
"\n" \
".sub _ :load :init :anon\n" \
-" load_bytecode 'P6object.pbc'\n" \
-"\n" \
" .local pmc p6meta, interp, classes, classid\n" \
" p6meta = get_root_global [\"parrot\"], \"P6metaclass\"\n" \
" p6meta.'new_class'('PLParrot')\n" \
View
40 plparrot_secure.pir
@@ -0,0 +1,40 @@
+.namespace ["PLParrot"]
+
+.sub open :method
+ .param pmc args :slurpy
+ print "Attempt to open "
+ $S1 = args[0]
+ say $S1
+.end
+
+.sub copy :method
+ .param pmc from
+ .param pmc to
+ print "Attempt to copy file "
+ print from
+ print "="
+ say to
+.end
+
+.sub rename :method
+ .param pmc from
+ .param pmc to
+ print "Attempt to rename file "
+ print from
+ print " to "
+ say to
+.end
+
+.namespace []
+
+.sub _ :load :init :anon
+ .local pmc p6meta, interp, classes, classid
+ p6meta = get_root_global ["parrot"], "P6metaclass"
+ p6meta.'new_class'('PLParrot')
+
+ interp = getinterp
+ classes = interp[0]
+ classid = classes['PLParrot']
+ set classes['FileHandle'], classid
+ set classes['File'], classid
+.end

0 comments on commit 1ae4402

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