Author: leo
Date: Fri Mar 10 03:49:20 2006
New Revision: 11852
Added:
trunk/t/dynpmc/sub.t (contents, props changed)
Modified:
trunk/MANIFEST
trunk/compilers/imcc/imc.c
trunk/compilers/imcc/imc.h
trunk/compilers/imcc/imcc.y
trunk/compilers/imcc/imcparser.c
trunk/compilers/imcc/pbc.c
trunk/compilers/imcc/unit.h
Log:
PBC, context handling - 3
* store HLL_id in context, when seen during compile
* remove HLL_id from unit and imcc_info
* test creation of HLL-mapped .Sub PMCs with .SubProxy, which happens
to be a .Sub and already available
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST (original)
+++ trunk/MANIFEST Fri Mar 10 03:49:20 2006
@@ -1954,6 +1954,7 @@
t/dynpmc/foo.t []
t/dynpmc/gdbmhash.t []
t/dynpmc/quantumreg.t []
+t/dynpmc/sub.t []
t/examples/japh.t []
t/examples/library.t []
t/examples/pasm.t []
Modified: trunk/compilers/imcc/imc.c
==============================================================================
--- trunk/compilers/imcc/imc.c (original)
+++ trunk/compilers/imcc/imc.c Fri Mar 10 03:49:20 2006
@@ -123,7 +123,6 @@
imc_info->n_comp_units++;
unit->file = imc_info->state->file;
unit->pasm_file = imc_info->state->pasm_file;
- unit->HLL_id = imc_info->HLL_id;
return unit;
}
Modified: trunk/compilers/imcc/imc.h
==============================================================================
--- trunk/compilers/imcc/imc.h (original)
+++ trunk/compilers/imcc/imc.h Fri Mar 10 03:49:20 2006
@@ -182,7 +182,6 @@
struct nodeType_t *top_node;
struct parser_state_t *state;
- INTVAL HLL_id;
} imc_info_t;
Modified: trunk/compilers/imcc/imcc.y
==============================================================================
--- trunk/compilers/imcc/imcc.y (original)
+++ trunk/compilers/imcc/imcc.y Fri Mar 10 03:49:20 2006
@@ -491,14 +491,14 @@
STRING *hll_name, *hll_lib;
hll_name = string_unescape_cstring(interp, $2 + 1, '"', NULL);
hll_lib = string_unescape_cstring(interp, $4 + 1, '"', NULL);
- IMCC_INFO(interp)->HLL_id =
+ CONTEXT(((Interp*)interp)->ctx)->current_HLL =
Parrot_register_HLL(interp, hll_name, hll_lib);
$$ = 0;
}
| HLL_MAP INTC COMMA INTC
{
Parrot_register_HLL_type(interp,
- IMCC_INFO(interp)->HLL_id, atoi($2), atoi($4));
+ CONTEXT(((Interp*)interp)->ctx)->current_HLL, atoi($2),
atoi($4));
$$ = 0;
}
;
Modified: trunk/compilers/imcc/imcparser.c
==============================================================================
--- trunk/compilers/imcc/imcparser.c (original)
+++ trunk/compilers/imcc/imcparser.c Fri Mar 10 03:49:20 2006
@@ -2258,7 +2258,7 @@
STRING *hll_name, *hll_lib;
hll_name = string_unescape_cstring(interp, yyvsp[-2].s + 1, '"',
NULL);
hll_lib = string_unescape_cstring(interp, yyvsp[0].s + 1, '"',
NULL);
- IMCC_INFO(interp)->HLL_id =
+ CONTEXT(((Interp*)interp)->ctx)->current_HLL =
Parrot_register_HLL(interp, hll_name, hll_lib);
yyval.t = 0;
}
@@ -2268,7 +2268,7 @@
#line 499 "compilers/imcc/imcc.y"
{
Parrot_register_HLL_type(interp,
- IMCC_INFO(interp)->HLL_id, atoi(yyvsp[-2].s),
atoi(yyvsp[0].s));
+ CONTEXT(((Interp*)interp)->ctx)->current_HLL,
atoi(yyvsp[-2].s), atoi(yyvsp[0].s));
yyval.t = 0;
}
break;
Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c (original)
+++ trunk/compilers/imcc/pbc.c Fri Mar 10 03:49:20 2006
@@ -673,8 +673,6 @@
unit->outer ? enum_class_Closure : enum_class_Sub;
/*
* use a possible type mapping for the Sub PMCs
- * XXX need to place HLL_id into context during compile to
- * make this actually working
*/
type = Parrot_get_ctx_HLL_type(interpreter, type);
/* TODO create constant - see also src/packfile.c
@@ -701,7 +699,7 @@
sub->namespace = ns_pmc;
sub->start_offs = offs;
sub->end_offs = end;
- sub->HLL_id = unit->HLL_id;
+ sub->HLL_id = CONTEXT(interpreter->ctx)->current_HLL;
for (i = 0; i < 4; ++i)
sub->n_regs_used[i] = unit->n_regs_used[i];
sub->lex_info = create_lexinfo(interpreter, unit, sub_pmc,
Modified: trunk/compilers/imcc/unit.h
==============================================================================
--- trunk/compilers/imcc/unit.h (original)
+++ trunk/compilers/imcc/unit.h Fri Mar 10 03:49:20 2006
@@ -43,7 +43,6 @@
SymReg *namespace;
int pasm_file;
const char *file;
- INTVAL HLL_id;
int n_vars_used[4]; /* INSP in PIR */
int n_regs_used[4]; /* INSP in PBC */
int first_avail[4]; /* INSP */
Added: trunk/t/dynpmc/sub.t
==============================================================================
--- (empty file)
+++ trunk/t/dynpmc/sub.t Fri Mar 10 03:49:20 2006
@@ -0,0 +1,68 @@
+#! perl
+# Copyright: 2005 The Perl Foundation. All Rights Reserved.
+# $Id$
+
+use strict;
+use warnings;
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use Parrot::Test tests => 2;
+use Parrot::Config;
+
+
+=head1 NAME
+
+t/dynpmc/sub.t - test if Sub is overridable by .HLL_map
+
+=head1 SYNOPSIS
+
+ % prove t/dynpmc/sub.t
+
+=head1 DESCRIPTION
+
+Tests the .HLL_map of Sub PMCs. The test is using .SubProxy, which
+happens to be a .Sub.
+
+=cut
+
+
+pir_output_is(<< 'CODE', << 'OUTPUT', "loadlib");
+.sub main :main
+ .local pmc lib
+ lib = loadlib "subproxy"
+ unless lib goto not_loaded
+ print "ok\n"
+ end
+not_loaded:
+ print "not loaded\n"
+.end
+CODE
+ok
+OUTPUT
+
+pir_output_is(<< 'CODE', << 'OUTPUT', "test type of HLL_mapped .Sub");
+.sub main :main
+ .const .Sub b = 'bar'
+ $S0 = typeof b
+ print $S0
+ print "\n"
+ .const .Sub f = 'foo'
+ $S0 = typeof f
+ print $S0
+ print "\n"
+.end
+
+.sub bar
+ noop
+.end
+
+.HLL "Some", "subproxy"
+.HLL_map .Sub, .SubProxy
+
+.sub foo
+ noop
+.end
+CODE
+Sub
+SubProxy
+OUTPUT