Permalink
Browse files

[nsentry] current nsentry changes for branch

git-svn-id: https://svn.parrot.org/parrot/branches/nsentry@34228 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 9fcdd51 commit 160b747b992cc3b08c3ca20085b8c9c384254f87 tewk committed Dec 22, 2008
View
@@ -1340,10 +1340,13 @@ add_const_pmc_sub(PARROT_INTERP, ARGMOD(SymReg *r), size_t offs, size_t end)
else
sub->ns_entry_name = sub->name;
}
+ else if (unit->is_method || unit->is_vtable_method)
+ sub->ns_entry_name = string_from_cstring(interp, "", 0);
else
sub->ns_entry_name = sub->name;
+
Parrot_store_sub_in_namespace(interp, sub_pmc);
pfc->type = PFC_PMC;
@@ -161,7 +161,7 @@ tree as a PIR code object that can be compiled.
.local string returnop
returnop = '.yield'
code.'emit'(<<" CODE", name, subid, namecorou, .INTERPINFO_CURRENT_SUB)
- .sub %0 :method %1
+ .sub %0 :nsentry(%0) :method %1
.param pmc adverbs :slurpy :named
.local pmc mob
.const 'Sub' corou = %2
@@ -190,7 +190,7 @@ tree as a PIR code object that can be compiled.
## Initial code for a rule that cannot be backtracked into.
returnop = '.return'
code.'emit'(<<" CODE", name, subid)
- .sub %0 :method %1
+ .sub %0 :nsentry(%0) :method %1
.param pmc adverbs :unique_reg :slurpy :named
.local pmc mob
.local string target :unique_reg
@@ -34,7 +34,7 @@ Match an identifier.
=cut
-.sub 'ident' :method
+.sub 'ident' :method :nsentry
.param pmc adverbs :slurpy :named
.local string target
.local pmc mob, mfrom, mpos
View
@@ -112,6 +112,14 @@ INTVAL Parrot_get_vtable_index(PARROT_INTERP, ARGIN(const STRING *name))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
+PARROT_PURE_FUNCTION
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+STRING *
+Parrot_get_vtable_name(PARROT_INTERP, ARGIN(INTVAL index))
+ __attribute__nonnull__(1);
+
+
PARROT_EXPORT
void Parrot_invalidate_method_cache(PARROT_INTERP,
ARGIN_NULLOK(STRING *_class),
@@ -35,7 +35,7 @@ the size of that file down and to emphasize their generic,
=cut
.namespace ['Any']
-.sub 'abs' :method :multi(_)
+.sub 'abs' :method :multi(_) :nsentry
$N0 = self
$N1 = abs $N0
.return ($N1)
@@ -46,7 +46,7 @@ the size of that file down and to emphasize their generic,
=cut
.namespace ['Any']
-.sub 'chr' :method :multi(_)
+.sub 'chr' :method :multi(_) :nsentry
$I0 = self
$S0 = chr $I0
.return ($S0)
@@ -57,12 +57,12 @@ the size of that file down and to emphasize their generic,
=cut
.namespace ['Any']
-.sub 'cis' :method :multi(_)
+.sub 'cis' :method :multi(_) :nsentry
.tailcall 'unpolar'(1.0, self)
.end
-.sub 'int' :method :multi(_)
+.sub 'int' :method :multi(_) :nsentry
.tailcall self.'truncate'()
.end
@@ -76,7 +76,7 @@ error.
=cut
-.sub 'log' :method :multi(_)
+.sub 'log' :method :multi(_) :nsentry
if self == 0 goto fail
$N0 = self
$N1 = ln $N0
@@ -91,7 +91,7 @@ error.
=cut
.namespace ['Any']
-.sub 'polar' :method :multi(_)
+.sub 'polar' :method :multi(_) :nsentry
$N0 = self
.tailcall 'list'($N0, 0)
.end
@@ -128,7 +128,7 @@ error.
=cut
.namespace ['Any']
-.sub 'sqrt' :method :multi(_)
+.sub 'sqrt' :method :multi(_) :nsentry
$N0 = self
$N1 = sqrt $N0
.return ($N1)
@@ -169,7 +169,7 @@ error.
=cut
.namespace ['Any']
-.sub 'truncate' :method :multi(_)
+.sub 'truncate' :method :multi(_) :nsentry
$N0 = self
if $N0 == 0 goto done
if $N0 < 0 goto num_ceil
@@ -187,7 +187,7 @@ error.
=cut
-.sub 'unpolar' :method
+.sub 'unpolar' :method :nsentry
.param num angle
.local num mag
.local pmc result
@@ -26,7 +26,7 @@ Returns a list element or slice.
=cut
.namespace ['Associative']
-.sub 'postcircumfix:{ }' :method
+.sub 'postcircumfix:{ }' :method :nsentry
.param pmc args :slurpy
.param pmc options :slurpy :named
.local pmc result
@@ -69,7 +69,7 @@ See also slurp.
=cut
.namespace ['IO']
-.sub 'lines' :method :multi('IO')
+.sub 'lines' :method :multi('IO') :nsentry
.local pmc PIO, res, chomper
PIO = getattribute self, "$!PIO"
res = new 'List'
@@ -133,7 +133,7 @@ Reads a line from the file handle.
=cut
-.sub 'readline' :method
+.sub 'readline' :method :nsentry
$P0 = get_hll_global 'IOIterator'
$P0 = $P0.'new'('IO' => self)
.return ($P0)
@@ -179,7 +179,7 @@ This version of list morphs a ResizablePMCArray into a List.
=cut
.namespace ['ResizablePMCArray']
-.sub 'list' :method
+.sub 'list' :method :nsentry
## this code morphs a ResizablePMCArray into a List
## without causing a clone of any of the elements
$P0 = new 'ResizablePMCArray'
@@ -56,7 +56,7 @@ Return key and value as a 2-element List.
=cut
.namespace ['Perl6Pair']
-.sub 'kv' :method
+.sub 'kv' :method :nsentry
$P0 = self.'key'()
$P1 = self.'value'()
.tailcall 'list'($P0, $P1)
@@ -49,7 +49,7 @@ as the Perl 6 C<Str> class.
.end
-.sub 'reverse' :method :multi('String')
+.sub 'reverse' :method :multi('String') :nsentry
.local pmc retv
retv = self.'split'('')
@@ -105,7 +105,7 @@ Returns a Perl representation of the Str.
=cut
-.sub 'sprintf' :method
+.sub 'sprintf' :method :nsentry
.param pmc args :slurpy
args.'!flatten'()
$P0 = new 'Str'
@@ -22,10 +22,10 @@ Tests for type based dispatch using the Perl 6 MultiSub PMC.
.include 'include/test_more.pir'
load_bytecode "perl6.pbc"
- plan(13)
+ plan(11)
'basic_class'()
- 'role'()
+# 'role'()
'ordered_class'()
.end
@@ -66,7 +66,7 @@ END:
=cut
-.sub close :method
+.sub close :method :nsentry
.local pmc temp
# reset source
@@ -5,7 +5,7 @@
.namespace [ 'Sub' ]
# implementation Sub.get_lexenv :method
-.sub get_lexenv :method
+.sub 'get_lexenv' :method :nsentry
.local pmc env, pad, interp
env = new 'ResizablePMCArray'
.local int level
View
@@ -819,16 +819,21 @@ If no multisub by that name currently exists, we create one.
static void
store_sub_in_multi(PARROT_INTERP, ARGIN(PMC *sub), ARGIN(PMC *ns))
{
- STRING * const ns_entry_name = PMC_sub(sub)->ns_entry_name;
- PMC *multisub = VTABLE_get_pmc_keyed_str(interp, ns, ns_entry_name);
+ STRING * entry_name = PMC_sub(sub)->method_name;
+ PMC *multisub;
+
+ if (0 == string_equal(interp, entry_name, CONST_STRING(interp, "")))
+ entry_name = PMC_sub(sub)->ns_entry_name;
+
+ multisub = VTABLE_get_pmc_keyed_str(interp, ns, entry_name);
/* is there an existing MultiSub PMC? or do we need to create one? */
if (PMC_IS_NULL(multisub)) {
multisub = pmc_new(interp, enum_class_MultiSub);
/* we have to push the sub onto the MultiSub before we try to store
it because storing requires information from the sub */
VTABLE_push_pmc(interp, multisub, sub);
- VTABLE_set_pmc_keyed_str(interp, ns, ns_entry_name, multisub);
+ VTABLE_set_pmc_keyed_str(interp, ns, entry_name, multisub);
}
else
VTABLE_push_pmc(interp, multisub, sub);
View
@@ -399,6 +399,26 @@ Parrot_get_vtable_index(PARROT_INTERP, ARGIN(const STRING *name))
/*
+=item C<INTVAL Parrot_get_vtable_name>
+
+Return name if C<index> is a valid vtable slot index.
+
+=cut
+
+*/
+
+PARROT_PURE_FUNCTION
+PARROT_CANNOT_RETURN_NULL
+PARROT_WARN_UNUSED_RESULT
+STRING *
+Parrot_get_vtable_name(PARROT_INTERP, ARGIN(INTVAL index))
+{
+ PARROT_ASSERT((index > PARROT_VTABLE_LOW) && (index < (NUM_VTABLE_FUNCTIONS + PARROT_VTABLE_LOW)));
+ return string_from_cstring(interp, Parrot_vtable_slot_names[index], 0);
+}
+
+/*
+
=item C<const char* Parrot_MMD_method_name>
Return the method name for the given MMD enum.
View
@@ -71,8 +71,10 @@ ns_insert_sub_keyed_str(PARROT_INTERP, PMC *self, STRING *key, PMC *value)
if (sub->vtable_index != -1) {
/* Insert it in class, if there is a class */
- if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj))
- VTABLE_add_vtable_override(interp, classobj, key, value);
+ if (!PMC_IS_NULL(classobj) && PObj_is_class_TEST(classobj)) {
+ STRING *vtable_entry_name = Parrot_get_vtable_name(interp, sub->vtable_index);
+ VTABLE_add_vtable_override(interp, classobj, vtable_entry_name, value);
+ }
/* Otherwise, store it in the namespace for the class to
* retrieve later */
@@ -67,7 +67,7 @@ t/compilers/imcc/syn/subflags.t - test flags on PIR subs
isa_ok($P30, 'Sub', ":method sub found w/.const")
$P0 = get_global 'method1'
$I0 = isnull $P0
- todo($I0, ":method sub not found in namespace")
+ ok($I0, ":method sub not found in namespace")
## :subid subs
.const 'Sub' $P40 = 'subid1'
View
@@ -402,7 +402,7 @@ diagnostic message).
.namespace ['ABC']
-.sub 'foo' :method
+.sub 'foo' :method :nsentry
.return ('ABC::foo')
.end
View
@@ -72,7 +72,7 @@ OK_3:
print "ok 5 - called method composed from role\n"
.end
-.sub badger :method
+.sub badger :method :nsentry
print "Badger!\n"
.end
CODE
@@ -117,13 +117,13 @@ pir_output_is( <<'CODE', <<'OUT', 'two roles and a class, a method each, no conf
print "ok 7 - called method from class\n"
.end
-.sub badger :method
+.sub badger :method :nsentry
print "Badger!\n"
.end
-.sub mushroom :method
+.sub mushroom :method :nsentry
print "Mushroom!\n"
.end
-.sub snake :method
+.sub snake :method :nsentry
print "Snake!\n"
.end
CODE
@@ -227,13 +227,13 @@ pir_output_is( <<'CODE', <<'OUT', 'conflict resolution by exclusion' );
print "ok 4 - called method from role that wasn't excluded\n"
.end
-.sub badger :method
+.sub badger :method :nsentry
print "Badger!\n"
.end
-.sub badger2 :method
+.sub badger2 :method :nsentry
print "Oops, wrong badger.\n"
.end
-.sub snake :method
+.sub snake :method :nsentry
print "Snake!\n"
.end
CODE
@@ -276,13 +276,13 @@ pir_output_is( <<'CODE', <<'OUT', 'conflict resolution by aliasing and exclude'
print "ok 5 - called method from role that was aliased\n"
.end
-.sub badger :method
+.sub badger :method :nsentry
print "Badger!\n"
.end
-.sub badger2 :method
+.sub badger2 :method :nsentry
print "Aliased badger!\n"
.end
-.sub snake :method
+.sub snake :method :nsentry
print "Snake!\n"
.end
CODE
@@ -332,13 +332,13 @@ ok_2:
print "ok 6 - called method from role that wasn't resolved\n"
.end
-.sub badger :method
+.sub badger :method :nsentry
print "Badger!\n"
.end
-.sub badger2 :method
+.sub badger2 :method :nsentry
print "Oops, wrong badger.\n"
.end
-.sub snake :method
+.sub snake :method :nsentry
print "Snake!\n"
.end
CODE
Oops, something went wrong.

0 comments on commit 160b747

Please sign in to comment.