[svn:parrot] r47273 - in branches/gsoc_past_optimization: . config/gen/makefiles runtime/parrot/library/PAST t/library
tcurtis at svn.parrot.org
tcurtis at svn.parrot.org
Wed Jun 2 01:08:12 UTC 2010
Author: tcurtis
Date: Wed Jun 2 01:08:12 2010
New Revision: 47273
URL: https://trac.parrot.org/parrot/changeset/47273
Log:
Initial non-working commit of PAST::Pattern(well, it works when matching doesn't work!).
Added:
branches/gsoc_past_optimization/runtime/parrot/library/PAST/Pattern.pir (contents, props changed)
branches/gsoc_past_optimization/t/library/pastpattern.t (contents, props changed)
Modified:
branches/gsoc_past_optimization/MANIFEST
branches/gsoc_past_optimization/config/gen/makefiles/root.in
branches/gsoc_past_optimization/t/library/pastwalkerdynamic.t
Modified: branches/gsoc_past_optimization/MANIFEST
==============================================================================
--- branches/gsoc_past_optimization/MANIFEST Wed Jun 2 01:07:49 2010 (r47272)
+++ branches/gsoc_past_optimization/MANIFEST Wed Jun 2 01:08:12 2010 (r47273)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Fri May 28 00:54:19 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Tue Jun 1 23:57:29 2010 UT
#
# See below for documentation on the format of this file.
#
@@ -1157,6 +1157,7 @@
runtime/parrot/library/OpenGL.pir [library]
runtime/parrot/library/OpenGL/Math.pir [library]
runtime/parrot/library/P6object.pir [library]
+runtime/parrot/library/PAST/Pattern.pir [library]
runtime/parrot/library/PAST/Transformer.pir [library]
runtime/parrot/library/PAST/Transformer/Dynamic.pir [library]
runtime/parrot/library/PAST/Walker.pir [library]
@@ -1678,6 +1679,7 @@
t/library/osutils.t [test]
t/library/p6object.t [test]
t/library/parrotlib.t [test]
+t/library/pastpattern.t [test]
t/library/pasttransformer.t [test]
t/library/pasttransformerdynamic.t [test]
t/library/pastwalker.t [test]
Modified: branches/gsoc_past_optimization/config/gen/makefiles/root.in
==============================================================================
--- branches/gsoc_past_optimization/config/gen/makefiles/root.in Wed Jun 2 01:07:49 2010 (r47272)
+++ branches/gsoc_past_optimization/config/gen/makefiles/root.in Wed Jun 2 01:08:12 2010 (r47273)
@@ -285,6 +285,7 @@
#IF(has_opengl): $(LIBRARY_DIR)/OpenGL/Math.pbc \
$(LIBRARY_DIR)/osutils.pbc \
$(LIBRARY_DIR)/P6object.pbc \
+ $(LIBRARY_DIR)/PAST/Pattern.pbc \
$(LIBRARY_DIR)/PAST/Transformer.pbc \
$(LIBRARY_DIR)/PAST/Transformer/Dynamic.pbc \
$(LIBRARY_DIR)/PAST/Walker.pbc \
Added: branches/gsoc_past_optimization/runtime/parrot/library/PAST/Pattern.pir
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gsoc_past_optimization/runtime/parrot/library/PAST/Pattern.pir Wed Jun 2 01:08:12 2010 (r47273)
@@ -0,0 +1,106 @@
+#!./parrot
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+.macro accessor(attrname)
+.sub .attrname :method
+ .param pmc value
+ .param int has_value
+ if has_value goto setattr
+ value = self[.attrname]
+ unless null value goto value_done
+value_undef:
+ value = new 'Undef'
+value_done:
+ .return (value)
+setattr:
+ self[.attrname] = value
+ .return (value)
+.end
+.endm
+
+.sub 'onload' :anon :init :load
+ load_bytecode 'P6object.pbc'
+ .local pmc p6meta, base
+ p6meta = new 'P6metaclass'
+ $S0 = 'name source pos returns arity named flat lvalue'
+ $P0 = get_class 'Capture'
+ base = p6meta.'new_class'('PAST::Pattern', 'parent'=>$P0, 'attrs'=>$S0)
+ $S1 = 'blocktype closure control loadinit namespace multi hll'
+ $S2 = 'nsentry symtable lexical compiler compiler_args subid pirflags'
+ $S0 = concat $S1, $S2
+ p6meta.'new_class'('PAST::Pattern::Block', 'parent'=>base, 'attrs'=>$S0)
+ $S0 = 'pasttype pirop inline'
+ p6meta.'new_class'('PAST::Pattern::Op', 'parent'=>base, 'attrs'=>$S0)
+ p6meta.'new_class'('PAST::Pattern::Stmts', 'parent'=>base)
+ $S0 = 'value'
+ p6meta.'new_class'('PAST::Pattern::Val', 'parent'=>base, 'attrs'=>$S0)
+ $S0 = 'scope isdecl namespace slurpy call_sig viviself vivibase multitype'
+ p6meta.'new_class'('PAST::Pattern::Var', 'parent'=>base, 'attrs'=>$S0)
+ p6meta.'new_class'('PAST::Pattern::VarList', 'parent'=>base)
+.end
+
+.namespace ['PAST'; 'Pattern']
+
+.accessor('name')
+.accessor('source')
+.accessor('pos')
+
+.accessor('returns')
+.accessor('arity')
+.accessor('named')
+.accessor('flat')
+.accessor('lvalue')
+
+.sub 'ACCEPTS' :method
+ .param pmc node
+ .return (0) # .ACCEPTS should return false by default.
+.end
+
+.namespace ['PAST'; 'Pattern'; 'Block']
+
+.accessor('blocktype')
+.accessor('closure')
+.accessor('control')
+.accessor('loadinit')
+.accessor('namespace')
+.accessor('multi')
+.accessor('hll')
+.accessor('nsentry')
+.accessor('symbtable')
+.accessor('lexical')
+.accessor('compiler')
+.accessor('compiler_args')
+.accessor('subid')
+.accessor('pirflags')
+
+.namespace ['PAST'; 'Pattern'; 'Op']
+
+.accessor('pasttype')
+.accessor('pirop')
+.accessor('inline')
+
+.namespace ['PAST'; 'Pattern'; 'Stmts']
+
+.namespace ['PAST'; 'Pattern'; 'Val']
+
+.accessor('value')
+
+.namespace ['PAST'; 'Pattern'; 'Var']
+
+.accessor('scope')
+.accessor('isdecl')
+.accessor('namespace')
+.accessor('slurpy')
+.accessor('call_sig')
+.accessor('viviself')
+.accessor('vivibase')
+.accessor('multitype')
+
+.namespace ['PAST'; 'Pattern'; 'VarList']
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Added: branches/gsoc_past_optimization/t/library/pastpattern.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gsoc_past_optimization/t/library/pastpattern.t Wed Jun 2 01:08:12 2010 (r47273)
@@ -0,0 +1,86 @@
+#!./parrot-nqp
+# Copyright (C) 2010, Parrot Foundation.
+# $Id$
+
+pir::load_bytecode('PCT.pbc');
+pir::load_bytecode('PAST/Pattern.pbc');
+
+plan(36);
+
+test_type_matching();
+
+sub test_type_matching() {
+ my $blockPat := PAST::Pattern::Block.new();
+ my $opPat := PAST::Pattern::Op.new();
+ my $stmtsPat := PAST::Pattern::Stmts.new();
+ my $valPat := PAST::Pattern::Val.new();
+ my $varPat := PAST::Pattern::Var.new();
+ my $varListPat := PAST::Pattern::VarList.new();
+
+ my $block := PAST::Block.new();
+ my $op := PAST::Op.new();
+ my $stmts := PAST::Stmts.new();
+ my $val := PAST::Val.new();
+ my $var := PAST::Var.new();
+ my $varList := PAST::VarList.new();
+
+ my @objs := [ $block, $op, $stmts, $val, $var, $varList ];
+
+ for @objs {
+ if $_ ~~ PAST::Block {
+ ok($_ ~~ $blockPat, "PAST::Block ~~ PAST::Pattern::Block.");
+ }
+ else {
+ ok(!($_ ~~ $blockPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::Block.");
+ }
+
+ if $_ ~~ PAST::Op {
+ ok($_ ~~ $opPat, "PAST::Op ~~ PAST::Pattern::Op.");
+ }
+ else {
+ ok(!($_ ~~ $opPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::Op.");
+ }
+
+ if $_ ~~ PAST::Stmts {
+ ok($_ ~~ $stmtsPat, "PAST::Stmts ~~ PAST::Pattern::Stmts.");
+ }
+ else {
+ ok(!($_ ~~ $stmtsPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::Stmts.");
+ }
+
+ if $_ ~~ PAST::Val {
+ ok($_ ~~ $valPat, "PAST::Val ~~ PAST::Pattern::Val.");
+ }
+ else {
+ ok(!($_ ~~ $valPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::Val.");
+ }
+
+ if $_ ~~ PAST::Var {
+ ok($_ ~~ $varPat, "PAST::Var ~~ PAST::Pattern::Var.");
+ }
+ else {
+ ok(!($_ ~~ $varPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::Var.");
+ }
+
+ if $_ ~~ PAST::VarList {
+ ok($_ ~~ $varListPat,
+ "PAST::VarList ~~ PAST::Pattern::VarList.");
+ }
+ else {
+ ok(!($_ ~~ $varListPat),
+ ~pir::class__p_p($_) ~ " !~~ PAST::Pattern::VarList.");
+ }
+ }
+}
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Modified: branches/gsoc_past_optimization/t/library/pastwalkerdynamic.t
==============================================================================
--- branches/gsoc_past_optimization/t/library/pastwalkerdynamic.t Wed Jun 2 01:07:49 2010 (r47272)
+++ branches/gsoc_past_optimization/t/library/pastwalkerdynamic.t Wed Jun 2 01:08:12 2010 (r47273)
@@ -85,7 +85,7 @@
}
# Local Variables:
-# mode: cperl-mode
+# mode: cperl
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
More information about the parrot-commits
mailing list