[svn:parrot] r39744 - in branches/pmc_pct/compilers/pmcc/src: . emitter parser
cotto at svn.parrot.org
cotto at svn.parrot.org
Tue Jun 23 15:32:25 UTC 2009
Author: cotto
Date: Tue Jun 23 15:32:25 2009
New Revision: 39744
URL: https://trac.parrot.org/parrot/changeset/39744
Log:
[pmcc] generate some more code in class_init, add actions to support hll and maps traits
Modified:
branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
branches/pmc_pct/compilers/pmcc/src/nodes.pir
branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
Modified: branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Tue Jun 23 15:17:25 2009 (r39743)
+++ branches/pmc_pct/compilers/pmcc/src/emitter/pmc.pm Tue Jun 23 15:32:25 2009 (r39744)
@@ -520,18 +520,34 @@
@res.push(' } /* pass 2 */');
@res.push(' else {');
+
+ my $hll := self.past.hll();
- #XXX: take care of HLL stuff here
+ if $hll ne '' && elements(self.past.maps()) {
+
+ @res.push(' {');
+ @res.push(' /* Register this PMC as a HLL mapping */');
+ @res.push(' const INTVAL pmc_id = Parrot_get_HLL_id( interp, CONST_STRING_GEN(interp, "'~$hll~'"));');
+ @res.push(' if (pmc_id > 0) {');
- @res.push(' {');
- @res.push(' VTABLE * const vt = interp->vtables[entry];');
- @res.push(' vt->mro = Parrot_'~self.name~'_get_mro(interp, PMCNULL);');
- @res.push(' if (vt->ro_variant_vtable)');
- @res.push(' vt->ro_variant_vtable->mro = vt->mro;');
- @res.push(' }');
+ for self.past.maps() {
+ @res.push(' Parrot_register_HLL_type( interp, pmc_id, enum_class_'~$_~', entry);');
+ }
+
+ @res.push(' }');
+ @res.push(' }');
+ @res.push('');
+ }
+
+ @res.push(' /* set up MRO and _namespace */');
+ @res.push(' {');
+ @res.push(' VTABLE * const vt = interp->vtables[entry];');
+ @res.push(' vt->mro = Parrot_'~self.name~'_get_mro(interp, PMCNULL);');
+ @res.push(' if (vt->ro_variant_vtable)');
+ @res.push(' vt->ro_variant_vtable->mro = vt->mro;');
+ @res.push(' }');
@res.push('');
- @res.push(' /* set up MRO and _namespace */');
- @res.push(' Parrot_create_mro(interp, entry);');
+ @res.push(' Parrot_create_mro(interp, entry);');
@res.push('}');
Modified: branches/pmc_pct/compilers/pmcc/src/nodes.pir
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/nodes.pir Tue Jun 23 15:17:25 2009 (r39743)
+++ branches/pmc_pct/compilers/pmcc/src/nodes.pir Tue Jun 23 15:32:25 2009 (r39744)
@@ -41,30 +41,36 @@
res.'init'(children :flat, adverbs :flat :named)
# Initialize various attributes
- $P1 = new 'ResizableStringArray'
+ $P1 = new ['ResizableStringArray']
res.'attr'('parents', $P1, 1)
- $P1 = new 'Hash'
+ $P1 = new ['Hash']
res.'attr'('vtables', $P1, 1)
- $P1 = new 'Hash'
+ $P1 = new ['Hash']
res.'attr'('vtdump', $P1, 1)
- $P1 = new 'Hash'
+ $P1 = new ['Hash']
res.'attr'('methods', $P1, 1)
# Multis are Hash of Arrays. name -> implementation*
- $P1 = new 'Hash'
+ $P1 = new ['Hash']
res.'attr'('multis', $P1, 1)
- $P1 = new 'ResizablePMCArray'
+ $P1 = new ['ResizablePMCArray']
res.'attr'('attrs', $P1, 1)
- $P1 = new 'ResizableStringArray'
+ $P1 = new ['ResizableStringArray']
res.'attr'('provides', $P1, 1)
- $P1 = new 'Hash'
+ $P1 = new ['Hash']
res.'attr'('traits', $P1, 1)
+
+ $P1 = new ['String']
+ res.'attr'('hll', $P1, 1)
+
+ $P1 = new ['ResizableStringArray']
+ res.'attr'('maps', $P1, 1)
.return (res)
.end
@@ -159,6 +165,24 @@
.tailcall self.'attr'('traits',0,0)
.end
+=item hll
+
+Get PMC hll name.
+
+=cut
+
+.sub 'hll' :method
+ .tailcall self.'attr'('hll',0,0)
+.end
+
+.sub 'set_hll' :method
+ .param pmc name
+ .tailcall self.'attr'('hll',name,1)
+.end
+
+.sub 'maps' :method
+ .tailcall self.'attr'('maps',0,0)
+.end
=item C<thaw_pmc_attrs>
@@ -364,7 +388,7 @@
die $S0
add_method:
- attr = new 'Hash'
+ attr = new ['Hash']
attr['type'] = type
attr['name'] = name
attr['is_fp'] = is_fp
Modified: branches/pmc_pct/compilers/pmcc/src/parser/actions.pm
==============================================================================
--- branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Tue Jun 23 15:17:25 2009 (r39743)
+++ branches/pmc_pct/compilers/pmcc/src/parser/actions.pm Tue Jun 23 15:32:25 2009 (r39744)
@@ -43,12 +43,12 @@
method traits($/, $key) {
our $?PMC;
- #say("traits " ~$/);
if $key eq 'does' {
}
elsif $key eq 'group' {
}
elsif $key eq 'hll' {
+ $?PMC.set_hll(~$<identifier>);
}
elsif $key eq 'provides' {
$?PMC.provides().push(~$<identifier>);
@@ -58,6 +58,7 @@
$?PMC.thaw_pmc_attrs(~$<identifier>);
}
elsif $key eq 'maps' {
+ $?PMC.maps().push(~$<identifier>);
}
elsif $key eq 'lib' {
}
More information about the parrot-commits
mailing list