cvsuser 04/03/11 05:17:21
Modified: imcc imc.h imcc.l imcc.y pbc.c pcc.c symreg.c symreg.h
imcc/t/syn objects.t
src packfile.c
t/pmc object-meths.t
Log:
PIR meth call syntax - 4
* add more syntax
obj.var(args)
obj.string(args)
namespace [ string ]
* namespace are plain strings currently not nested yet
* s. t/pmc/object-emths.t, imcc/t/syn/objects.t
Revision Changes Path
1.62 +9 -8 parrot/imcc/imc.h
Index: imc.h
===================================================================
RCS file: /cvs/public/parrot/imcc/imc.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -w -r1.61 -r1.62
--- imc.h 9 Jan 2004 02:57:31 -0000 1.61
+++ imc.h 11 Mar 2004 13:17:00 -0000 1.62
@@ -185,10 +185,11 @@
int verbose;
int debug;
int n_comp_units;
+ SymReg * cur_namespace;
} imc_info_t;
-#define IMCC_INFO(i) ((i)->imc_info)
+#define IMCC_INFO(i) (((Parrot_Interp)(i))->imc_info)
#define IMC_TRACE 0
#define IMC_TRACE_HIGH 0
1.88 +1 -1 parrot/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.l,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -w -r1.87 -r1.88
--- imcc.l 10 Mar 2004 15:02:50 -0000 1.87
+++ imcc.l 11 Mar 2004 13:17:00 -0000 1.88
@@ -203,7 +203,7 @@
".return" return(RETURN);
".class" return(CLASS);
".endclass" return(ENDCLASS);
-".namespace" return(NAMESPACE);
+<emit,INITIAL>".namespace" return(NAMESPACE);
".endnamespace" return(ENDNAMESPACE);
".field" return(FIELD);
".method" return(METHOD);
1.123 +20 -7 parrot/imcc/imcc.y
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/imcc/imcc.y,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -w -r1.122 -r1.123
--- imcc.y 10 Mar 2004 15:48:46 -0000 1.122
+++ imcc.y 11 Mar 2004 13:17:00 -0000 1.123
@@ -53,6 +53,7 @@
static Instruction * current_call;
static SymReg *cur_obj;
IMC_Unit * cur_unit;
+SymReg *cur_namespace; /* ugly hack for mk_address */
/*
* these are used for constructing one INS
@@ -257,7 +258,7 @@
%token <s> PARROT_OP
%type <t> type newsub ptr
%type <i> program class class_body member_decls member_decl field_decl
-%type <i> method_decl
+%type <i> method_decl class_namespace
%type <i> global constdef sub emit pcc_sub sub_body pcc_ret pcc_yield
%type <i> compilation_units compilation_unit
%type <s> classname relop
@@ -303,6 +304,7 @@
compilation_unit:
class { $$ = $1; cur_unit = 0; }
+ | class_namespace { $$ = $1; }
| constdef { $$ = $1; }
| global { $$ = $1; }
| sub { $$ = $1; imc_close_unit(interp, cur_unit); cur_unit = 0; }
@@ -340,6 +342,7 @@
| MACRO '\n' { $$ = 0; }
| FILECOMMENT { $$ = 0; }
| LINECOMMENT { $$ = 0; }
+ | class_namespace { $$ = $1; }
;
pasm_inst: { clear_state(); }
@@ -347,9 +350,10 @@
{ $$ = INS(interp, cur_unit, $2,0,regs,nargs,keyvec,1);
free($2); }
| PCC_SUB pcc_sub_proto LABEL
- { char *name = str_dup($3);
+ {
$$ = iSUBROUTINE(cur_unit, mk_sub_label($3));
- $$->r[1] = mk_pcc_sub(name, 0);
+ $$->r[1] = mk_pcc_sub(str_dup($$->r[0]->name), 0);
+ add_namespace(interp, $$->r[1]);
$$->r[1]->pcc_sub->pragma = $2;
}
| /* none */ { $$ = 0;}
@@ -371,6 +375,13 @@
$$=0; }
;
+class_namespace:
+ NAMESPACE '[' keylist ']' { $$=0;
+ IMCC_INFO(interp)->cur_namespace = $3;
+ cur_namespace = $3;
+ }
+ ;
+
class:
CLASS IDENTIFIER
{
@@ -441,9 +452,9 @@
}
IDENTIFIER pcc_sub_proto '\n'
{
- char *name = str_dup($3);
Instruction *i = iSUBROUTINE(cur_unit, mk_sub_label($3));
- i->r[1] = $<sr>$ = mk_pcc_sub(name, 0);
+ i->r[1] = $<sr>$ = mk_pcc_sub(str_dup(i->r[0]->name), 0);
+ add_namespace(interp, i->r[1]);
i->r[1]->pcc_sub->pragma = $4;
}
sub_params
@@ -469,9 +480,9 @@
PCC_SUB { cur_unit = imc_open_unit(interp, IMC_PCCSUB); }
IDENTIFIER pcc_sub_proto '\n'
{
- char *name = str_dup($3);
Instruction *i = iSUBROUTINE(cur_unit, mk_sub_label($3));
- i->r[1] = $<sr>$ = mk_pcc_sub(name, 0);
+ i->r[1] = $<sr>$ = mk_pcc_sub(str_dup(i->r[0]->name), 0);
+ add_namespace(interp, i->r[1]);
i->r[1]->pcc_sub->pragma = $4;
}
pcc_params
@@ -839,6 +850,8 @@
fataly(1, sourcefile, line, "Sub isn't a PMC");
}
| VAR ptr IDENTIFIER { cur_obj = $1; $$ = mk_sub_address($3); }
+ | VAR ptr STRINGC { cur_obj = $1; $$ = mk_const($3, 'S'); }
+ | VAR ptr target { cur_obj = $1; $$ = $3; }
;
ptr: POINTY { $$=0; }
1.66 +32 -5 parrot/imcc/pbc.c
Index: pbc.c
===================================================================
RCS file: /cvs/public/parrot/imcc/pbc.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -w -r1.65 -r1.66
--- pbc.c 23 Feb 2004 14:28:27 -0000 1.65
+++ pbc.c 11 Mar 2004 13:17:00 -0000 1.66
@@ -71,6 +71,7 @@
static int add_const_str(struct Parrot_Interp *, char *str);
static void imcc_globals_destroy(int ex, void *param);
+static opcode_t build_key(struct Parrot_Interp *interpreter, SymReg *reg);
static void
imcc_globals_destroy(int ex, void *param)
@@ -608,15 +609,38 @@
char buf[256];
opcode_t *rc;
struct PackFile_Constant *pfc;
+ SymReg *ns;
+ int ns_const = -1;
+ char *real_name;
+
+
+ if (r->pcc_sub->namespace) {
+ ns = r->pcc_sub->namespace->reg;
+ if (ns->set == 'K')
+ ns->color = build_key(interpreter, ns);
+ debug(interpreter, DEBUG_PBC_CONST, "name space const = %d\n",
+ ns->color);
+ ns_const = ns->color;
+ /* strip namespace off from front */
+ real_name = strrchr(r->name, ':');
+ if (!real_name)
+ real_name = r->name;
+ else
+ ++real_name;
+ }
+ else
+ real_name = r->name;
+ debug(interpreter, DEBUG_PBC_CONST,
+ "add_const_pmc_sub '%s' -> '%s' flags %d\n",
+ r->name, real_name, r->pcc_sub->pragma);
- debug(interpreter, DEBUG_PBC_CONST, "add_const_pmc_sub '%s' flags %d\n",
- r->name, r->pcc_sub->pragma);
/*
* TODO use serialize api if that is done
* for now:
- * "Class name offs end flags"
+ * "Class name offs end flags namespace#"
*/
- sprintf(buf, "Sub %s %d %d %d", r->name, offs, len, r->pcc_sub->pragma);
+ sprintf(buf, "Sub %s %d %d %d %d", real_name, offs, len,
+ r->pcc_sub->pragma, ns_const);
pfc = malloc(sizeof(struct PackFile_Constant));
rc = PackFile_Constant_unpack_pmc(interpreter,
@@ -631,7 +655,7 @@
* create entry in our fixup (=symbol) table
* the offset is the index in the constant table of this Sub
*/
- PackFile_FixupTable_new_entry(interpreter, r->name, enum_fixup_sub, k);
+ PackFile_FixupTable_new_entry(interpreter, real_name, enum_fixup_sub, k);
return k;
}
@@ -796,6 +820,9 @@
for (r = ghash[i]; r; r = r->next) {
if (r->type & VTCONST) {
add_1_const(interpreter, r);
+ }
+ else if (r->type & VT_CONSTP) {
+ add_1_const(interpreter, r->reg);
}
}
/* ... but keychains 'K' are in local hash, they may contain
1.49 +7 -1 parrot/imcc/pcc.c
Index: pcc.c
===================================================================
RCS file: /cvs/public/parrot/imcc/pcc.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -w -r1.48 -r1.49
--- pcc.c 10 Mar 2004 17:43:12 -0000 1.48
+++ pcc.c 11 Mar 2004 13:17:00 -0000 1.49
@@ -844,6 +844,12 @@
if (meth_call) {
/* set S0, meth */
regs[0] = get_pasm_reg("S0");;
+ if ((arg->type & VT_REGP) &&
+ (arg->reg->type == VTIDENTIFIER ||
+ arg->reg->type == VTPASM ||
+ arg->reg->type == VTREG))
+ regs[1] = arg->reg;
+ else
regs[1] = mk_const(str_dup(arg->name), 'S');
ins = insINS(interp, unit, ins, "set", regs, 2);
/* set P2, obj */
1.46 +51 -5 parrot/imcc/symreg.c
Index: symreg.c
===================================================================
RCS file: /cvs/public/parrot/imcc/symreg.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -w -r1.45 -r1.46
--- symreg.c 23 Feb 2004 14:28:27 -0000 1.45
+++ symreg.c 11 Mar 2004 13:17:00 -0000 1.46
@@ -14,8 +14,6 @@
/* Globals: */
/* Code: */
-static SymReg * dup_sym(SymReg *r);
-
void
push_namespace(char * name)
@@ -135,6 +133,25 @@
}
/*
+ * add current namespace to sub decl
+ */
+void
+add_namespace(Parrot_Interp interpreter, SymReg *sub)
+{
+ SymReg *ns = IMCC_INFO(interpreter)->cur_namespace;
+ SymReg *r, *g;
+
+ if (!ns)
+ return;
+ g = dup_sym(ns);
+ sub->pcc_sub->namespace = g;
+ g->reg = ns;
+ g->type = VT_CONSTP;
+ if (! (r = _get_sym(ghash, g->name)) || r->type != VT_CONSTP )
+ _store_symreg(ghash, g);
+}
+
+/*
* Add make a pointer to a register or constant
* and add to the subroutine structure arg list.
* If arg is a pointer, deref the symbol first.
@@ -305,6 +322,31 @@
return _mk_const(ghash, name, t);
}
+extern SymReg *cur_namespace; /* ugly hack for mk_address */
+
+/*
+ * add namespace to sub if any
+ * */
+static char *
+add_ns(SymReg *r, char *name)
+{
+ int len, l;
+ char *ns_name;
+
+ if (!cur_namespace || (l = strlen(cur_namespace->name)) <= 2)
+ return name;
+ /* TODO keyed syntax */
+ len = strlen(name) + l + 3;
+ ns_name = mem_sys_allocate(len);
+ strcpy(ns_name, cur_namespace->name);
+ *ns_name = '_';
+ ns_name[l - 1] = '\0';
+ strcat(ns_name, "::");
+ strcat(ns_name, name);
+ mem_sys_free(name);
+ return ns_name;
+}
+
/* Makes a new address */
SymReg *
_mk_address(SymReg *hsh[], char * name, int uniq)
@@ -318,6 +360,8 @@
_store_symreg(hsh,r);
return r;
}
+ if (uniq == U_add_uniq_sub)
+ name = add_ns(r, name);
if (uniq && (r = _get_sym(hsh, name)) &&
r->type == VTADDRESS &&
@@ -429,7 +473,7 @@
*
*/
-static SymReg *
+SymReg *
dup_sym(SymReg *r)
{
SymReg * new = malloc(sizeof(SymReg));
@@ -446,6 +490,8 @@
SymReg * first, *key, *keychain;
int i;
char key_str[256];
+ /* namespace keys are global consts - no cur_unit */
+ SymReg **h = cur_unit ? cur_unit->hash : ghash;
if (nargs == 0)
fatal(1, "link_keys", "hu? no keys\n");
@@ -459,7 +505,7 @@
if (i < nargs - 1)
strcat(key_str, ";");
}
- if ( (keychain = get_sym(key_str)) != 0)
+ if ( (keychain = _get_sym(h, key_str)) != 0)
return keychain;
/* no, need a new one */
keychain = calloc(1, sizeof(SymReg));
@@ -485,7 +531,7 @@
keychain->name = str_dup(key_str);
keychain->set = 'K';
keychain->color = -1;
- store_symreg(keychain);
+ _store_symreg(h, keychain);
return keychain;
}
1.42 +3 -0 parrot/imcc/symreg.h
Index: symreg.h
===================================================================
RCS file: /cvs/public/parrot/imcc/symreg.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -w -r1.41 -r1.42
--- symreg.h 10 Mar 2004 15:02:50 -0000 1.41
+++ symreg.h 11 Mar 2004 13:17:00 -0000 1.42
@@ -119,6 +119,7 @@
void add_pcc_result(SymReg *r, SymReg * arg);
void add_pcc_param(SymReg *r, SymReg * arg);
void add_pcc_return(SymReg *r, SymReg * arg);
+void add_namespace(Parrot_Interp interpreter, SymReg *sub);
typedef enum {
P_NON_PROTOTYPED = 0x00, /* must be 0 */
@@ -144,6 +145,7 @@
int nci;
int label;
SymReg * object;
+ SymReg * namespace;
};
@@ -170,6 +172,7 @@
void clear_globals(void);
unsigned int hash_str(const char * str);
void _delete_sym(struct _IMC_Unit *, const char * name);
+SymReg * dup_sym(SymReg *r);
SymReg * _find_sym(Namespace * ns, SymReg * hash[], const char * name);
char * _mk_fullname(Namespace * ns, const char * name);
1.3 +76 -7 parrot/imcc/t/syn/objects.t
Index: objects.t
===================================================================
RCS file: /cvs/public/parrot/imcc/t/syn/objects.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- objects.t 10 Mar 2004 15:48:50 -0000 1.2
+++ objects.t 11 Mar 2004 13:17:08 -0000 1.3
@@ -1,17 +1,17 @@
#!perl
use strict;
-use TestCompiler tests => 3;
+use TestCompiler tests => 5;
##############################
# Parrot Calling Conventions
output_is(<<'CODE', <<'OUT', "meth call syntax");
+.namespace [ "Foo" ]
+
.sub _main
.local pmc class
.local pmc obj
- find_global $P0, "_meth"
- store_global "Foo", "_meth", $P0
newclass class, "Foo"
find_type $I0, "Foo"
new obj, $I0
@@ -30,11 +30,10 @@
OUT
output_is(<<'CODE', <<'OUT', "meth call syntax m.o(arg)");
+.namespace [ "Foo" ]
.sub _main
.local pmc class
.local pmc obj
- find_global $P0, "_meth"
- store_global "Foo", "_meth", $P0
newclass class, "Foo"
find_type $I0, "Foo"
new obj, $I0
@@ -56,11 +55,10 @@
OUT
output_is(<<'CODE', <<'OUT', "meth call ret = o.m(arg)");
+.namespace [ "Foo" ]
.sub _main
.local pmc class
.local pmc obj
- find_global $P0, "_meth"
- store_global "Foo", "_meth", $P0
newclass class, "Foo"
find_type $I0, "Foo"
new obj, $I0
@@ -83,3 +81,74 @@
ok
done
OUT
+
+output_is(<<'CODE', <<'OUT', "meth call syntax");
+.namespace [ "Foo" ]
+.sub _main
+ .local pmc class
+ .local pmc obj
+ .local string meth
+ meth = "_meth"
+ newclass class, "Foo"
+ find_type $I0, "Foo"
+ new obj, $I0
+ obj."_meth"()
+ obj->meth()
+ set S10, "_meth"
+ obj->S10()
+ set $S10, "_meth"
+ obj->$S10()
+ print "done\n"
+ end
+.end
+.sub _meth
+ print "in meth\n"
+.end
+CODE
+in meth
+in meth
+in meth
+in meth
+done
+OUT
+
+output_is(<<'CODE', <<'OUT', "initializer");
+.sub _main
+ newclass P1, "Foo"
+ subclass P2, P1, "Bar"
+ subclass P3, P2, "Baz"
+ find_type I1, "Baz"
+ new P3, I1
+ find_global P0, "_sub"
+ invokecc
+ print "done\n"
+ end
+.end
+
+.namespace ["Foo"]
+.sub __init
+ print "foo_init\n"
+.end
+
+.namespace ["Bar"]
+.sub __init
+ print "bar_init\n"
+.end
+
+.namespace ["Baz"]
+.sub __init
+ print "baz_init\n"
+.end
+
+.namespace [""] # main again
+.sub _sub
+ print "in sub\n"
+.end
+CODE
+foo_init
+bar_init
+baz_init
+in sub
+done
+OUT
+
1.152 +61 -12 parrot/src/packfile.c
Index: packfile.c
===================================================================
RCS file: /cvs/public/parrot/src/packfile.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -w -r1.151 -r1.152
--- packfile.c 7 Mar 2004 19:07:31 -0000 1.151
+++ packfile.c 11 Mar 2004 13:17:14 -0000 1.152
@@ -2,7 +2,7 @@
Copyright (C) 2001-2002 Gregor N. Purdy. All rights reserved.
This program is free software. It is subject to the same license as
Parrot itself.
-$Id: packfile.c,v 1.151 2004/03/07 19:07:31 leo Exp $
+$Id: packfile.c,v 1.152 2004/03/11 13:17:14 leo Exp $
=head1 NAME
@@ -27,6 +27,7 @@
#include "parrot/parrot.h"
#include "parrot/embed.h"
#include "parrot/packfile.h"
+#include <assert.h>
#define TRACE_PACKFILE 0
#define TRACE_PACKFILE_PMC 0
@@ -2736,6 +2737,57 @@
*/
+static void
+store_sub_in_namespace(Parrot_Interp interpreter, struct PackFile *pf,
+ PMC* sub_pmc,
+ char *name, int ns)
+{
+ STRING *key = string_from_cstring(interpreter, name, 0);
+ PMC * globals = interpreter->globals->stash_hash;
+
+#if TRACE_PACKFILE_PMC
+ fprintf(stderr, "PMC_CONST: store_global: name '%s' ns %d\n", name, ns);
+#endif
+ /*
+ * namespace is a const table entry indey
+ * -1 ... no namespace or
+ * type PFC_STRING .. a simple string
+ * PFC_KEY ... a Key chain
+ */
+ if (ns == -1) {
+global_ns:
+ VTABLE_set_pmc_keyed_str(interpreter, globals, key, sub_pmc);
+ }
+ else {
+ STRING *names;
+ PMC * stash;
+ struct PackFile_Constant *pfc_const;
+
+ assert(ns < pf->const_table->const_count);
+ pfc_const = pf->const_table->constants[ns];
+ switch (pfc_const->type) {
+ case PFC_STRING:
+ names = pfc_const->u.string;
+ if (!string_length(names))
+ goto global_ns;
+ if (!VTABLE_exists_keyed_str(interpreter, globals, names)) {
+ stash = pmc_new(interpreter, enum_class_OrderedHash);
+ VTABLE_set_pmc_keyed_str(interpreter, globals, names,
+ stash);
+ }
+ else {
+ stash = VTABLE_get_pmc_keyed_str(interpreter, globals,
+ names);
+ }
+ VTABLE_set_pmc_keyed_str(interpreter, stash, key, sub_pmc);
+ break;
+ default:
+ internal_exception(1, "Unhandled namespace constant");
+ }
+
+ }
+}
+
opcode_t *
PackFile_Constant_unpack_pmc(struct Parrot_Interp *interpreter,
struct PackFile_ConstTable *constt,
@@ -2747,9 +2799,10 @@
char class[32], name[128];
int start, end, flag;
int rc, pmc_num;
- PMC *sub_pmc, *key;
+ PMC *sub_pmc;
struct Parrot_Sub *sub;
struct PackFile *pf_save;
+ int ns_const;
#if TRACE_PACKFILE_PMC
fprintf(stderr, "PMC_CONST '%s'\n", (char*)cursor);
@@ -2760,15 +2813,16 @@
*
* TODO first get classname, then get rest according to PMC type
*/
- rc = sscanf(pmcs, "%31s %127s %d %d %d)", class, name, &start, &end, &flag);
- if (rc != 5) {
+ rc = sscanf(pmcs, "%31s %127s %d %d %d %d",
+ class, name, &start, &end, &flag, &ns_const);
+ if (rc != 6) {
fprintf(stderr, "PMC_CONST ERR RC '%d'\n", rc);
}
#if TRACE_PACKFILE_PMC
fprintf(stderr,
- "PMC_CONST: class '%s', name '%s', start %d end %d flag %d\n",
- class, name, start, end, flag);
+ "PMC_CONST: class '%s', name '%s', start %d end %d flag %d ns %d\n",
+ class, name, start, end, flag, ns_const);
#endif
/*
* make a constant subroutine object of the desired class
@@ -2813,12 +2867,7 @@
/*
* finally place the sub in the global stash
*/
- key = key_new_cstring(interpreter, name);
-#if TRACE_PACKFILE_PMC
- fprintf(stderr, "PMC_CONST: store_global: name '%s'\n", name);
-#endif
- VTABLE_set_pmc_keyed(interpreter, interpreter->globals->stash_hash,
- key, sub_pmc);
+ store_sub_in_namespace(interpreter, pf, sub_pmc, name, ns_const);
/*
* restore interpreters packfile
1.9 +25 -28 parrot/t/pmc/object-meths.t
Index: object-meths.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/object-meths.t,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -r1.8 -r1.9
--- object-meths.t 10 Mar 2004 11:47:29 -0000 1.8
+++ object-meths.t 11 Mar 2004 13:17:21 -0000 1.9
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: object-meths.t,v 1.8 2004/03/10 11:47:29 leo Exp $
+# $Id: object-meths.t,v 1.9 2004/03/11 13:17:21 leo Exp $
=head1 NAME
@@ -33,20 +33,12 @@
newclass P2, "Foo"
set S0, "meth"
- # cant mangle method names yet
- find_global P3, "meth"
- # so store ref to the sub with the real name
- store_global "Foo", "meth", P3
-
print "main\n"
callmethodcc
print "back\n"
end
-# .mangle "::" "\x00"
-# .pcc_sub Foo::meth:
-# or some such
-
+.namespace ["Foo"]
.pcc_sub meth:
print "in meth\n"
invoke P1
@@ -101,13 +93,12 @@
output_is(<<'CODE', <<'OUTPUT', "constructor");
newclass P1, "Foo"
- find_global P2, "init"
- store_global "Foo", "__init", P2
find_type I1, "Foo"
new P3, I1
print "ok 2\n"
end
-.pcc_sub init:
+.namespace ["Foo"]
+.pcc_sub __init:
print "ok 1\n"
invoke P1
CODE
@@ -118,24 +109,21 @@
output_is(<<'CODE', <<'OUTPUT', "constructor - init attr");
newclass P1, "Foo"
addattribute P1, ".i"
- find_global P2, "Foo::init"
- store_global "Foo", "__init", P2
- find_global P2, "Foo::get_s"
- store_global "Foo", "__get_string", P2
find_type I1, "Foo"
new P3, I1
print "ok 2\n"
print P3
print "\n"
end
-.pcc_sub Foo::init:
+.namespace ["Foo"]
+.pcc_sub __init:
print "ok 1\n"
new P10, .PerlInt
set P10, 42
classoffset I0, P2, "Foo"
setattribute P2, I0, P10
invoke P1
-.pcc_sub Foo::get_s:
+.pcc_sub __get_string:
classoffset I0, P2, "Foo"
getattribute P10, P2, I0
set S5, P10
@@ -148,32 +136,40 @@
output_is(<<'CODE', <<'OUTPUT', "constructor - parents");
newclass P1, "Foo"
- find_global P12, "_foo::init"
- store_global "Foo", "__init", P12
subclass P2, P1, "Bar"
- find_global P12, "_bar::init"
- store_global "Bar", "__init", P12
subclass P3, P2, "Baz"
- find_global P12, "_baz::init"
- store_global "Baz", "__init", P12
find_type I1, "Baz"
new P3, I1
find_type I1, "Bar"
new P3, I1
+ find_global P0, "_sub"
+ invokecc
print "done\n"
end
-.pcc_sub _foo::init:
+
+ .namespace ["Foo"]
+.pcc_sub __init:
print "foo_init\n"
classname S0, P2
print S0
print "\n"
invoke P1
-.pcc_sub _bar::init:
+
+ .namespace ["Bar"]
+.pcc_sub __init:
print "bar_init\n"
invoke P1
-.pcc_sub _baz::init:
+
+ .namespace ["Baz"]
+.pcc_sub __init:
print "baz_init\n"
invoke P1
+
+ .namespace [""] # main again
+.pcc_sub _sub:
+ print "in sub\n"
+ invoke P1
+
CODE
foo_init
Baz
@@ -182,5 +178,6 @@
foo_init
Bar
bar_init
+in sub
done
OUTPUT