Skip to content

Commit

Permalink
Merge branch 'master' into perl6_args
Browse files Browse the repository at this point in the history
Conflicts:
	plparrot.c
  • Loading branch information
leto committed Jul 28, 2010
2 parents 44a985f + ecebc43 commit 29a86df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 2 additions & 0 deletions html/docs.html
Expand Up @@ -31,6 +31,8 @@
<li><a href="PLParrot_PGCon_2010.pdf">PL/Parrot at PGCon 2010</a></li>
<li><a href="PLParrot_SFPM_20100525.pdf">PL/Parrot at San Francisco Perl Mongers, May 2010</a></li>
<li><a href="http://leto.net/perl/2010/04/plparrot-flies.html">PL/Parrot Flies!</a></li>
<li><a href="http://www.chesnok.com/daily/2010/05/26/pgcon-2010-plparrot-simulated-annealing-exclusion-constraints-postgres-xc/">
PgCon 2010 - PL/Parrot, Simulated Annealing, Exclusion Constraints, Postgres-XC</a></li>
</ul>
</div>
</div>
Expand Down
37 changes: 27 additions & 10 deletions plparrot.c
Expand Up @@ -44,6 +44,8 @@ PG_MODULE_MAGIC;
#define TextDatum2String(X) (pstrdup(DatumGetCString(DirectFunctionCall1(textout, (X)))))
#endif

#define DEBUG_MODE 1

/**********************************************************************
* The information we cache about loaded procedures
**********************************************************************/
Expand Down Expand Up @@ -95,6 +97,7 @@ Parrot_PMC plperl6_run(Parrot_Interp interp, Parrot_String code,
FunctionCallInfo fcinfo, int numargs);

void plparrot_push_pgdatatype_pmc(Parrot_PMC, FunctionCallInfo, int);
void debug(char *msg);

/* this is saved and restored by plparrot_call_handler */
static plparrot_call_data *current_call_data = NULL;
Expand All @@ -108,16 +111,31 @@ void _PG_fini(void);
void
_PG_init(void)
{
debug("_PG_init");
if (inited)
return;

Parrot_set_config_hash();

debug("set_config_hash");

untrusted_interp = Parrot_new(NULL);

debug("untrusted");

/* Must use the first created interp as the parent of subsequently created interps */
trusted_interp = Parrot_new(untrusted_interp);
debug("trusted");

if (!trusted_interp) {
elog(ERROR,"Could not create a trusted Parrot interpreter!\n");
return;
}
if (!untrusted_interp) {
elog(ERROR,"Could not create an untrusted Parrot interpreter!\n");
return;
}

//Parrot_set_trace(interp, PARROT_ALL_TRACE_FLAGS);
#ifdef HAS_PERL6
p6_interp = Parrot_new(trusted_interp);
p6u_interp = Parrot_new(untrusted_interp);
Expand All @@ -130,17 +148,12 @@ _PG_init(void)
return;
}
interp = p6_interp;
debug("loading bytecode");
debug(PERL6PBC);
Parrot_load_bytecode(interp,create_string_const(PERL6PBC));
debug("loaded bytecode");
#endif

if (!trusted_interp) {
elog(ERROR,"Could not create a trusted Parrot interpreter!\n");
return;
}
if (!untrusted_interp) {
elog(ERROR,"Could not create an untrusted Parrot interpreter!\n");
return;
}
interp = trusted_interp;
plparrot_secure(interp);

Expand Down Expand Up @@ -400,7 +413,7 @@ plperl6_call_handler(PG_FUNCTION_ARGS)
{
Datum retval = 0;
TriggerData *tdata;

elog(NOTICE, "plperl6_call_handler");
interp = p6_interp;
if(!interp) {
elog(ERROR,"Invalid Parrot interpreter!");
Expand Down Expand Up @@ -567,3 +580,7 @@ plparrot_make_sausage(Parrot_Interp interp, Parrot_PMC pmc, FunctionCallInfo fci
}
}

void debug(char *msg) {
if (DEBUG_MODE)
elog(NOTICE, msg);
}

0 comments on commit 29a86df

Please sign in to comment.