Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r35497 - in branches/removing_stm: . docs/book docs/dev docs/pdds include/parrot languages/befunge languages/ecmascript languages/ecmascript/src/classes languages/ecmascript/src/parser languages/ecmascript/t/js_pt languages/ecmascript/t/sanit
From:
Whiteknight
Date:
January 13, 2009 11:13
Subject:
[svn:parrot] r35497 - in branches/removing_stm: . docs/book docs/dev docs/pdds include/parrot languages/befunge languages/ecmascript languages/ecmascript/src/classes languages/ecmascript/src/parser languages/ecmascript/t/js_pt languages/ecmascript/t/sanit
Message ID:
20090113191323.57718CB9F9@x12.develooper.com
Author: Whiteknight
Date: Tue Jan 13 11:13:19 2009
New Revision: 35497
Modified:
branches/removing_stm/ (props changed)
branches/removing_stm/DEPRECATED.pod
branches/removing_stm/docs/book/ch07_testing_and_debugging.pod (props changed)
branches/removing_stm/docs/book/ch08_architecture.pod (props changed)
branches/removing_stm/docs/book/ch09_pct.pod (props changed)
branches/removing_stm/docs/book/ch10_hlls.pod (props changed)
branches/removing_stm/docs/book/ch11_pmcs.pod (props changed)
branches/removing_stm/docs/book/ch12_opcodes.pod (props changed)
branches/removing_stm/docs/book/ch13_reference.pod (props changed)
branches/removing_stm/docs/dev/c_functions.pod (props changed)
branches/removing_stm/docs/pdds/pdd19_pir.pod
branches/removing_stm/include/parrot/gc_api.h (props changed)
branches/removing_stm/include/parrot/gc_mark_sweep.h (props changed)
branches/removing_stm/include/parrot/gc_pools.h (props changed)
branches/removing_stm/languages/befunge/Configure.pl (props changed)
branches/removing_stm/languages/befunge/befunge.pir
branches/removing_stm/languages/befunge/load.pir
branches/removing_stm/languages/ecmascript/js.pir
branches/removing_stm/languages/ecmascript/src/classes/Array.pir
branches/removing_stm/languages/ecmascript/src/classes/Boolean.pir
branches/removing_stm/languages/ecmascript/src/classes/Null.pir
branches/removing_stm/languages/ecmascript/src/classes/Object.pir
branches/removing_stm/languages/ecmascript/src/parser/actions.pm
branches/removing_stm/languages/ecmascript/t/js_pt/09-array.t
branches/removing_stm/languages/ecmascript/t/sanity_pt/03-boolean.t (props changed)
branches/removing_stm/languages/lua/src/lib/luaaux.pir
branches/removing_stm/languages/lua/src/lib/luadebug.pir
branches/removing_stm/languages/lua/src/lib/markdown.pir
branches/removing_stm/languages/lua/t/table.t
branches/removing_stm/languages/lua/t/test/bisect-output-win32.txt (props changed)
branches/removing_stm/languages/perl6/docs/spectest-progress.csv
branches/removing_stm/languages/perl6/src/parser/grammar.pg
branches/removing_stm/languages/perl6/src/parser/methods.pir
branches/removing_stm/languages/pipp/docs/internals.pod (contents, props changed)
branches/removing_stm/languages/pipp/docs/pipp.pod
branches/removing_stm/languages/pipp/pipp.pir (props changed)
branches/removing_stm/languages/pipp/src/classes/Object.pir (props changed)
branches/removing_stm/languages/pipp/src/pct/actions.pm
branches/removing_stm/languages/pipp/src/pct/grammar.pg
branches/removing_stm/languages/pipp/src/pmc/pipp_hash.c (props changed)
branches/removing_stm/languages/pipp/src/pmc/pipp_hash.h (props changed)
branches/removing_stm/languages/pipp/t/embed/eval.t (props changed)
branches/removing_stm/languages/pipp/t/php/namespace.t
branches/removing_stm/src/gc/api.c (props changed)
branches/removing_stm/src/gc/generational_ms.c (props changed)
branches/removing_stm/src/gc/incremental_ms.c (props changed)
branches/removing_stm/src/gc/mark_sweep.c (props changed)
branches/removing_stm/src/gc/pools.c (props changed)
branches/removing_stm/t/compilers/tge/NoneGrammar.tg (props changed)
branches/removing_stm/tools/util/perlcritic-cage.conf (props changed)
Log:
[removing_stm] updating branch to trunk from r35463
Modified: branches/removing_stm/DEPRECATED.pod
==============================================================================
--- branches/removing_stm/DEPRECATED.pod (original)
+++ branches/removing_stm/DEPRECATED.pod Tue Jan 13 11:13:19 2009
@@ -3,7 +3,7 @@
=head1 Deprecation in Parrot
This is a list of currently deprecated features of Parrot. Every deprecation
-has an associated RT ticket. Each item indicates the last release it's
+has an associated RT or TT ticket. Each item indicates the last release it's
guaranteed to appear in.
When deprecated items are removed, all usage of the feature in the
@@ -128,7 +128,7 @@
=item P6protoobject stringification [post 0.9.0]
Stringification of protoobjects will return the full name of the type
-and parentheses, per Synopsis 12.
+and parentheses, per Synopsis 12. See TT #168
=back
Modified: branches/removing_stm/docs/pdds/pdd19_pir.pod
==============================================================================
--- branches/removing_stm/docs/pdds/pdd19_pir.pod (original)
+++ branches/removing_stm/docs/pdds/pdd19_pir.pod Tue Jan 13 11:13:19 2009
@@ -398,7 +398,8 @@
Define "main" entry point to start execution. If multiple subroutines are
marked as B<:main>, the B<last> marked subroutine is used. Only the first
file loaded or compiled counts; subs marked as B<:main> are ignored by the
-B<load_bytecode> op.
+B<load_bytecode> op. If no B<:main> flag is specified at all, execution
+starts at the first subroutine in the file.
=item :load
Modified: branches/removing_stm/languages/befunge/befunge.pir
==============================================================================
--- branches/removing_stm/languages/befunge/befunge.pir (original)
+++ branches/removing_stm/languages/befunge/befunge.pir Tue Jan 13 11:13:19 2009
@@ -10,6 +10,8 @@
.sub "befunge" :main
.param pmc argv
+ push_eh catch
+
# disable buffering on stdout
.local pmc stdout
getstdout stdout
@@ -240,6 +242,11 @@
set_global "status", status
goto TICK
+ catch:
+ .local pmc ex
+ .get_results (ex)
+ printerr ex
+
.end
Modified: branches/removing_stm/languages/befunge/load.pir
==============================================================================
--- branches/removing_stm/languages/befunge/load.pir (original)
+++ branches/removing_stm/languages/befunge/load.pir Tue Jan 13 11:13:19 2009
@@ -64,8 +64,8 @@
$S0 .= "' ("
$S1 = err
$S0 .= $S1
- $S0 .= ")\n"
- printerr $S0
+ $S0 .= ")"
+ ex = $S0
rethrow ex
.end
Modified: branches/removing_stm/languages/ecmascript/js.pir
==============================================================================
--- branches/removing_stm/languages/ecmascript/js.pir (original)
+++ branches/removing_stm/languages/ecmascript/js.pir Tue Jan 13 11:13:19 2009
@@ -16,7 +16,16 @@
## Create a 'List' class; stolen from Rakudo.
## At some point, this should be refactored/reused.
##
+.HLL 'js'
.namespace []
+.sub 'onload' :anon :load :init
+ load_bytecode 'PCT.pbc'
+ .local pmc parrotns, jsns, exports
+ parrotns = get_root_namespace ['parrot']
+ jsns = get_hll_namespace
+ exports = split ' ', 'PAST PCT PGE P6metaclass'
+ parrotns.'export_to'(jsns, exports)
+.end
.sub '__onload' :load :init
$P0 = subclass 'ResizablePMCArray', 'List'
@@ -51,18 +60,25 @@
.sub 'onload' :load :init :anon
load_bytecode 'PCT.pbc'
+
+ #.local pmc jsmeta
+ #jsmeta = get_hll_global ['JSObject'], '!JSMETA'
+ #jsmeta.'new_class'('JS::Compiler', 'parent'=>'PCT::HLLCompiler')
$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
$P1.'language'('JS')
- $P1.'parsegrammar'('JS::Grammar')
- $P1.'parseactions'('JS::Grammar::Actions')
+ $P0 = get_hll_namespace ['JS';'Grammar']
+ $P1.'parsegrammar'($P0)
+ $P0 = get_hll_namespace ['JS';'Grammar';'Actions']
+ $P1.'parseactions'($P0)
## Create a list called '@?BLOCK' and store it, so it can
## be used in the parse actions.
##
$P0 = new 'List'
set_hll_global ['JS';'Grammar';'Actions'], '@?BLOCK', $P0
+
.end
Modified: branches/removing_stm/languages/ecmascript/src/classes/Array.pir
==============================================================================
--- branches/removing_stm/languages/ecmascript/src/classes/Array.pir (original)
+++ branches/removing_stm/languages/ecmascript/src/classes/Array.pir Tue Jan 13 11:13:19 2009
@@ -19,9 +19,11 @@
.local pmc jsmeta
load_bytecode 'PCT.pbc'
$P0 = get_root_global ['parrot'], 'P6metaclass'
- $P0.'new_class'('JSArray', 'parent'=>'JSObject')
+ $P0.'new_class'('Array', 'parent'=>'JSObject')
jsmeta = $P0.'HOW'()
- set_hll_global ['JSArray'], '$!JSMETA', jsmeta
+ set_hll_global ['Array'], '$!JSMETA', jsmeta
+ get_class $P0, 'Array'
+ addattribute $P0, '__array'
.end
=head2 Methods
@@ -39,23 +41,7 @@
=cut
-.namespace ['JSArray']
-.sub 'Set' :method
- .param pmc key
- .param pmc val
- self[key] = val
- .return(self)
-.end
-
-.namespace ['JSArray']
-.sub 'Get' :method
- .param pmc key
- .local pmc val
- val = self[key]
- .return(val)
-.end
-
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'clone' :method
.param pmc new_attrs :slurpy :named
@@ -90,7 +76,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'defined' :method
$P0 = get_hll_global ['Bool'], 'True'
.return ($P0)
@@ -103,7 +89,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'hash' :method
.tailcall self.'Hash'()
.end
@@ -120,7 +106,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'item' :method
.return (self)
.end
@@ -146,7 +132,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'list' :method
$P0 = new 'List'
push $P0, self
@@ -159,7 +145,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'print' :method
$P0 = get_hll_global 'print'
.tailcall $P0(self)
@@ -171,7 +157,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'say' :method
$P0 = get_hll_global 'say'
.tailcall $P0(self)
@@ -183,7 +169,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'true' :method
.tailcall self.'defined'()
.end
@@ -198,9 +184,9 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'Array' :method
- $P0 = new 'JSArray'
+ $P0 = new 'Array'
$P0.'!STORE'(self)
.return ($P0)
.end
@@ -209,7 +195,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'Hash' :method
$P0 = new 'JSHash'
$P0.'!STORE'(self)
@@ -232,7 +218,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub '' :method('Scalar') :anon
$I0 = isa self, 'ObjectRef'
unless $I0 goto not_ref
@@ -264,7 +250,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'Str' :method
$P0 = new 'ResizableStringArray'
$P1 = self.'WHAT'()
@@ -288,14 +274,14 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub 'new' :method
.param pmc init_parents :slurpy
.param pmc init_this :named :slurpy
# Instantiate.
.local pmc jsmeta
- jsmeta = get_hll_global ['JSArray'], '$!JSMETA'
+ jsmeta = get_hll_global ['Array'], '$!JSMETA'
$P0 = jsmeta.'get_parrotclass'(self)
$P1 = new $P0
.return ($P1)
@@ -307,7 +293,7 @@
=cut
-.namespace ['JSArray']
+.namespace ['Array']
.sub '' :vtable('decrement') :method
$P0 = self.'pred'()
'infix:='(self, $P0)
@@ -328,11 +314,30 @@
.tailcall self.'Iterator'()
.end
+#.sub '' :vtable('get_string') :method
+# $S0 = self.'Str'()
+# .return ($S0)
+#.end
+
.sub '' :vtable('get_string') :method
- $S0 = self.'Str'()
- .return ($S0)
+ $S0 = ''
+ .local pmc iter
+ iter = new 'Iterator', self
+ goto loop_start
+ loop:
+ unless iter goto end
+ $S0 = concat $S0, ','
+ loop_start:
+ $S1 = shift iter
+ $S2 = iter[$S1]
+ concat $S0, $S2
+ goto loop
+ end:
+.return ($S0)
.end
+
+
.sub '' :vtable('increment') :method
$P0 = self.'succ'()
'infix:='(self, $P0)
Modified: branches/removing_stm/languages/ecmascript/src/classes/Boolean.pir
==============================================================================
--- branches/removing_stm/languages/ecmascript/src/classes/Boolean.pir (original)
+++ branches/removing_stm/languages/ecmascript/src/classes/Boolean.pir Tue Jan 13 11:13:19 2009
@@ -18,9 +18,10 @@
.namespace ['JSBoolean']
.sub 'onload' :anon :init :load
- .local pmc jsmeta, boolproto
+ .local pmc jsmeta, boolproto, booleanclass
+ booleanclass = get_root_global ['parrot'], 'Boolean'
jsmeta = get_hll_global ['JSObject'], '$!JSMETA'
- boolproto = jsmeta.'new_class'('JSBoolean', 'parent'=>'Boolean')
+ boolproto = jsmeta.'new_class'('JSBoolean', 'parent'=>booleanclass)
#boolproto = jsmeta.'new_class'('Boolean')
#boolproto.'!IMMUTABLE'()
jsmeta.'register'('Boolean', 'parent'=>boolproto, 'protoobject'=>boolproto)
Modified: branches/removing_stm/languages/ecmascript/src/classes/Null.pir
==============================================================================
--- branches/removing_stm/languages/ecmascript/src/classes/Null.pir (original)
+++ branches/removing_stm/languages/ecmascript/src/classes/Null.pir Tue Jan 13 11:13:19 2009
@@ -11,9 +11,10 @@
.namespace []
.sub '' :anon :load :init
- .local pmc jsmeta, nilproto
+ .local pmc jsmeta, nilproto, nullclass
+ nullclass = get_hll_global ['parrot'], 'Null'
jsmeta = get_hll_global ['JSObject'], '$!JSMETA'
- nilproto = jsmeta.'new_class'('JSNull', 'parent'=>'Null')
+ nilproto = jsmeta.'new_class'('JSNull', 'parent'=>nullclass)
jsmeta.'register'('Null', 'parent'=>nilproto, 'protoobject'=>nilproto)
$P0 = nilproto.'new'()
Modified: branches/removing_stm/languages/ecmascript/src/classes/Object.pir
==============================================================================
--- branches/removing_stm/languages/ecmascript/src/classes/Object.pir (original)
+++ branches/removing_stm/languages/ecmascript/src/classes/Object.pir Tue Jan 13 11:13:19 2009
@@ -18,8 +18,9 @@
.sub '' :anon :init :load
.local pmc jsmeta
load_bytecode 'PCT.pbc'
+ $P1 = get_root_global ['parrot'], 'Hash'
$P0 = get_root_global ['parrot'], 'P6metaclass'
- $P0.'new_class'('JSObject', 'parent'=>'Hash')
+ $P0.'new_class'('JSObject', 'parent'=>$P1)
jsmeta = $P0.'HOW'()
set_hll_global ['JSObject'], '$!JSMETA', jsmeta
.end
Modified: branches/removing_stm/languages/ecmascript/src/parser/actions.pm
==============================================================================
--- branches/removing_stm/languages/ecmascript/src/parser/actions.pm (original)
+++ branches/removing_stm/languages/ecmascript/src/parser/actions.pm Tue Jan 13 11:13:19 2009
@@ -10,6 +10,8 @@
if $key eq 'open' {
## create a 'global' current block and stuff it into the scope stack.
$?BLOCK := PAST::Block.new( :blocktype('declaration'), :node($/) );
+ $?BLOCK.hll('js');
+
@?BLOCK.unshift($?BLOCK);
}
elsif $key eq 'close' {
@@ -631,7 +633,7 @@
## past as argument. This is done 'inside out', so the last 'new' is invoked
## first, so to say.
for $<sym> {
- $past := PAST::Op.new( $past, :name('new'), :pasttype('call'), :node($/) );
+ $past := PAST::Op.new( $past, :name('new'), :pasttype('callmethod'), :node($/) );
}
make $past;
}
@@ -700,7 +702,7 @@
method property($/) {
my $key := $( $<property_name> );
my $val := $( $<assignment_expression> );
- my $past := PAST::Op.new( :pasttype('callmethod'), :name('Set'), $key, $val, :node($/) );
+ my $past := PAST::Op.new( :inline(' %0[%1] = %2'), $key, $val, :node($/) );
make $past;
}
@@ -717,7 +719,7 @@
method array_literal($/) {
my $past := PAST::Stmts.new( :node($/) );
- my $type := PAST::Var.new( :name('JSArray'), :scope('package'), :node($/) );
+ my $type := PAST::Var.new( :name('Array'), :scope('package'), :node($/) );
my $objvar := PAST::Var.new(:scope('register'), :name('obj'));
$past.push(
PAST::Op.new(:pasttype('bind'),
@@ -727,7 +729,7 @@
my $i := 0;
for $<assignment_expression> {
$past.push(
- PAST::Op.new( :pasttype('callmethod'), :name('Set'), $objvar, $i, $($_), :node($/) ));
+ PAST::Op.new( :inline(' %0[%1] = %2'), $objvar, $i, $($_), :node($/) ));
$i := $i + 1;
}
$past.push($objvar);
Modified: branches/removing_stm/languages/ecmascript/t/js_pt/09-array.t
==============================================================================
--- branches/removing_stm/languages/ecmascript/t/js_pt/09-array.t (original)
+++ branches/removing_stm/languages/ecmascript/t/js_pt/09-array.t Tue Jan 13 11:13:19 2009
@@ -11,7 +11,7 @@
language_output_is( 'JS', <<'CODE', <<'OUT', 'new array into var', todo => 'NOTIMPLEMENTED');
var a = new Array();
-print a.length
+print(a.length);
CODE
0
OUT
Modified: branches/removing_stm/languages/lua/src/lib/luaaux.pir
==============================================================================
--- branches/removing_stm/languages/lua/src/lib/luaaux.pir (original)
+++ branches/removing_stm/languages/lua/src/lib/luaaux.pir Tue Jan 13 11:13:19 2009
@@ -35,7 +35,7 @@
.param int narg
.param pmc extramsg :slurpy
$S0 = lua_x_argerror(narg, extramsg :flat)
- lua_error($S0)
+ die $S0
.end
.sub 'lua_x_argerror'
@@ -1010,11 +1010,10 @@
.local pmc bt
bt = ex.'backtrace'()
$S0 = where()
- $S0 .= ' '
$S1 = ex
$S0 .= $S1
$S0 .= "\n"
- $S1 = traceback(bt)
+ $S1 = str_traceback(bt)
$S0 .= $S1
.return (1, $S0)
L2:
@@ -1023,10 +1022,10 @@
.sub 'where' :anon
# dummy implementation
- .return ("_._:0:")
+ .return ("_._:0: ")
.end
-.sub 'traceback' :anon
+.sub 'str_traceback'
.param pmc bt
.local pmc iter, sub, outer, annos
new iter, 'Iterator', bt
Modified: branches/removing_stm/languages/lua/src/lib/luadebug.pir
==============================================================================
--- branches/removing_stm/languages/lua/src/lib/luadebug.pir (original)
+++ branches/removing_stm/languages/lua/src/lib/luadebug.pir Tue Jan 13 11:13:19 2009
@@ -377,7 +377,8 @@
unless $S1 goto L1
$S1 .= "\n"
L1:
- $S0 = _traceback($I2)
+ $P0 = _traceback($I2)
+ $S0 = str_traceback($P0)
$S1 .= $S0
new res, 'LuaString'
set res, $S1
@@ -387,29 +388,22 @@
.sub '_traceback' :anon
.param int level
$P0 = getinterp
+ .local pmc res, hash, sub, annos
+ new res, 'ResizablePMCArray'
$I0 = 0
- $S0 = "stack traceback:"
- .local pmc sub, outer
L1:
inc $I0
push_eh _handler
sub = $P0['sub'; $I0]
+ annos = $P0['annotations'; $I0]
pop_eh
- outer = sub.'get_outer'()
- $S0 .= "\n\t"
- unless null outer goto L3
- $S0 .= "[PIR]:"
- goto L4
- L3:
- $S0 .= "_._:0:"
- L4:
- $S0 .= " in function '"
- $S1 = sub.'get_name'()
- $S0 .= $S1
- $S0 .= "'"
+ new hash, 'Hash'
+ hash['sub'] = sub
+ hash['annotations'] = annos
+ push res, hash
goto L1
_handler:
- .return ($S0)
+ .return (res)
.end
Modified: branches/removing_stm/languages/lua/src/lib/markdown.pir
==============================================================================
--- branches/removing_stm/languages/lua/src/lib/markdown.pir (original)
+++ branches/removing_stm/languages/lua/src/lib/markdown.pir Tue Jan 13 11:13:19 2009
@@ -60,8 +60,9 @@
.param pmc extra :slurpy
.local pmc res
$S1 = lua_checkstring(1, str)
- $P0 = compreg 'Markdown'
- $S0 = $P0.'compile'($S1)
+ $P0 = compreg 'markdown'
+ $P1 = $P0.'compile'($S1)
+ $S0 = $P1()
new res, 'LuaString'
set res, $S0
.return (res)
Modified: branches/removing_stm/languages/lua/t/table.t
==============================================================================
--- branches/removing_stm/languages/lua/t/table.t (original)
+++ branches/removing_stm/languages/lua/t/table.t Tue Jan 13 11:13:19 2009
@@ -78,12 +78,11 @@
3 c
OUTPUT
-language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function foreach (hash)' );
+language_output_like( 'lua', << 'CODE', << 'OUTPUT', 'function foreach (hash)' );
t = {a=10, b=100}
table.foreach(t, print)
CODE
-a 10
-b 100
+/^(a\t10\nb\t100|b\t100\na\t10)$/
OUTPUT
language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'function foreachi' );
Modified: branches/removing_stm/languages/perl6/docs/spectest-progress.csv
==============================================================================
--- branches/removing_stm/languages/perl6/docs/spectest-progress.csv (original)
+++ branches/removing_stm/languages/perl6/docs/spectest-progress.csv Tue Jan 13 11:13:19 2009
@@ -234,3 +234,5 @@
"2009-01-09 00:00",35243,6172,0,337,1424,7933,11263,279
"2009-01-10 00:00",35329,6141,0,331,1479,7951,11287,279
"2009-01-11 00:00",35386,6143,0,331,1478,7952,11288,279
+"2009-01-12 00:00",35432,6218,0,331,1425,7974,11470,281
+"2009-01-13 00:00",35477,6233,0,333,1425,7991,11487,282
Modified: branches/removing_stm/languages/perl6/src/parser/grammar.pg
==============================================================================
--- branches/removing_stm/languages/perl6/src/parser/grammar.pg (original)
+++ branches/removing_stm/languages/perl6/src/parser/grammar.pg Tue Jan 13 11:13:19 2009
@@ -625,10 +625,11 @@
rule package_def {
[
- <module_name=name>
+ <module_name>
{{
$P0 = match['module_name']
$P0 = $P0[0]
+ $P0 = $P0['name']
$S0 = $P0.'text'()
match.'add_type'($S0)
}}
@@ -728,6 +729,21 @@
| <sigil> '(' <semilist> ')' {*} #= $( )
}
+token module_name {
+ <name>
+ [
+ :dba('generic role')
+ <?{{
+ ## ($+PKGDECL//'') eq 'role' (more like (@?PKGDECL[0]//'') eq 'role')
+ $P0 = get_hll_global ['Perl6'; 'Grammar'; 'Actions'], '@?PKGDECL'
+ $S0 = $P0[0]
+ $I0 = $S0 == 'role'
+ .return ($I0)
+ }}>
+ '[' ~ ']' <signature>
+ ]?
+}
+
token name {
| <identifier> <morename>*
| <morename>+
@@ -747,15 +763,11 @@
}
token typename {
- <?before <.upper> | '::' > <name>
+ <name>
<?{{
$P0 = match['name']
$S0 = $P0.'text'()
- # XXX Uncomment next line to test type registration. Disabled in
- # commited version for now, while I track down the bugs/regressions
- # that it causes.
- #.tailcall match.'is_type'($S0)
- .return (1)
+ .tailcall match.'is_type'($S0)
}}>
{*}
}
Modified: branches/removing_stm/languages/perl6/src/parser/methods.pir
==============================================================================
--- branches/removing_stm/languages/perl6/src/parser/methods.pir (original)
+++ branches/removing_stm/languages/perl6/src/parser/methods.pir Tue Jan 13 11:13:19 2009
@@ -31,10 +31,20 @@
$P0 = get_hll_global ns, short_name
unless null $P0 goto done
- # Add name to the current block's symbols.
- .local pmc cur_block
- cur_block = get_hll_global ['Perl6';'Grammar';'Actions'], '@?BLOCK'
- cur_block = cur_block[0]
+ # Work outwards to find a block defining a package and put the type
+ # there. XXX This makes it too visible for lexical types, but if we
+ # assume lexical rather than package scope then we will fail various
+ # tests/code.
+ .local pmc blocks, it, cur_block
+ blocks = get_hll_global ['Perl6';'Grammar';'Actions'], '@?BLOCK'
+ it = iter blocks
+ it_loop:
+ unless it goto it_loop_end
+ cur_block = shift it
+ $P0 = cur_block['sym']
+ if null $P0 goto it_loop
+ if $P0 == '' goto it_loop
+ it_loop_end:
cur_block.'symbol'(name, 'does_abstraction'=>1)
done:
Modified: branches/removing_stm/languages/pipp/docs/internals.pod
==============================================================================
--- branches/removing_stm/languages/pipp/docs/internals.pod (original)
+++ branches/removing_stm/languages/pipp/docs/internals.pod Tue Jan 13 11:13:19 2009
@@ -18,7 +18,11 @@
=head1 Parsing
-Parsing is done with PCT.
+Parsing is done with Parrot Compiler Toolkit, PCT.
+
+=head1 Bytecode generation
+
+The parse tree is transformed to a Parrot Abstrace Syntax Tree, from which PIR und then Bytecode is generated.
=head1 Variables
@@ -48,8 +52,10 @@
=head1 Namespaces
-A namespace is introduced with the keyword B<namespace>.
-There can be multiple namespaces per file. They are not nested.
+A namespace is introduced with the keyword B<namespace>.
+The namespaced code can be enclosed in brackets.
+The namespace declaration needs to be the first statement in the file.
+With brackets, there can be multiple namespaces per file. Nesting is not possible.
Namespaces don't carry over to included files.
B<define()> doesn't define in the current namespace.
The backslash character serves as the namespace separator.
@@ -62,14 +68,10 @@
=head2 Implementation in Pipp
-Currently the namespace directive is only parsed.
-
In order to ease implementation and testing, there will be
some divergences in Pipp.
-Code before the first namespace directive is allowed.
-Free code within namespace is allowed.
-There will be namespaced variables as well.
-'namespace \;' indicates the return to the root namespace.
+Only the bracketed syntax is supported.
+Code outside the scope of namespaces directives is allowed.
=head2 SEE ALSO
Modified: branches/removing_stm/languages/pipp/docs/pipp.pod
==============================================================================
--- branches/removing_stm/languages/pipp/docs/pipp.pod (original)
+++ branches/removing_stm/languages/pipp/docs/pipp.pod Tue Jan 13 11:13:19 2009
@@ -29,6 +29,8 @@
=item No old style constructors, where the constructor is named after the class.
+=item Only bracketed version of namespaces. No check for unnamespaced code.
+
=back
=head1 Implementation
Modified: branches/removing_stm/languages/pipp/src/pct/actions.pm
==============================================================================
--- branches/removing_stm/languages/pipp/src/pct/actions.pm (original)
+++ branches/removing_stm/languages/pipp/src/pct/actions.pm Tue Jan 13 11:13:19 2009
@@ -114,17 +114,18 @@
}
method namespace_statement($/) {
- our $?NS := ~$<NAMESPACE_NAME>;
- my $past := PAST::Op.new(
- :pasttype('call'),
- :name('echo'),
- :node($/),
- PAST::Val.new(
- :value('Encountered namespace: ' ~ $?NS ~ "\n"),
- :returns('PhpString'),
- ),
- );
- make $past;
+ my $ns_name := +$<NAMESPACE_NAME> ?? ~$<NAMESPACE_NAME>[0] !! '';
+ my $block :=
+ PAST::Block.new(
+ :namespace($ns_name),
+ $( $<statement_list> )
+ );
+
+ # set up scope 'package' for the superglobals
+ our @?SUPER_GLOBALS;
+ for ( @?SUPER_GLOBALS ) { $block.symbol( :scope('package'), $_ ); }
+
+ make $block;
}
method return_statement($/) {
@@ -814,11 +815,9 @@
method quote_expression($/, $key) {
my $past;
if $key eq 'quote_regex' {
- our $?NS;
$past := PAST::Block.new(
$<quote_regex>,
:compiler('PGE::Perl6Regex'),
- :namespace($?NS),
:blocktype('declaration'),
:node( $/ )
);
Modified: branches/removing_stm/languages/pipp/src/pct/grammar.pg
==============================================================================
--- branches/removing_stm/languages/pipp/src/pct/grammar.pg (original)
+++ branches/removing_stm/languages/pipp/src/pct/grammar.pg Tue Jan 13 11:13:19 2009
@@ -146,7 +146,7 @@
}
rule namespace_statement {
- 'namespace' <NAMESPACE_NAME> ';'
+ 'namespace' <NAMESPACE_NAME>? '{' <statement_list> '}'
{*}
}
Modified: branches/removing_stm/languages/pipp/t/php/namespace.t
==============================================================================
--- branches/removing_stm/languages/pipp/t/php/namespace.t (original)
+++ branches/removing_stm/languages/pipp/t/php/namespace.t Tue Jan 13 11:13:19 2009
@@ -24,27 +24,27 @@
use FindBin;
use lib "$FindBin::Bin/../../../../lib", "$FindBin::Bin/../../lib";
-use Parrot::Test tests => 5;
+use Parrot::Test tests => 4;
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'parsing of namespace directive' );
<?php
-namespace A\B;
+namespace A\B {}
-namespace \A\B\C;
+namespace \A\B\C {}
?>
CODE
-Encountered namespace: A\B
-Encountered namespace: \A\B\C
OUT
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with constant', todo => 'not implemented yet' );
<?php
+namespace {
const FOO = "FOO in root.\n";
+}
-namespace A\B;
+namespace A\B {
const FOO = "FOO in A::B\n";
@@ -52,12 +52,16 @@
echo A\B\FOO;
echo \FOO;
-namespace \;
+}
+
+namespace {
echo FOO;
echo A\B\FOO;
echo \FOO;
+}
+
?>
CODE
FOO in A::B
@@ -68,47 +72,30 @@
FOO in root
OUT
-language_output_is( 'Pipp', <<'CODE', <<'OUT', 'case insensitive namespace', todo => 'not implemented yet' );
-<?php
-
-namespace A\B;
-
-const FOO = "FOO in a::b\n";
-
-namespace \;
-
-echo A\B\FOO;
-echo A\b\FOO;
-echo a\B\FOO;
-echo a\b\FOO;
-
-?>
-CODE
-FOO in a::b
-FOO in a::b
-FOO in a::b
-FOO in a::b
-OUT
-
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with variable', todo => 'not implemented yet' );
<?php
+namespace {
$FOO = "FOO in root.\n";
+}
-namespace A\B;
+namespace A\B {
$FOO = "FOO in A::B\n";
echo $FOO;
echo $A\B\FOO;
echo $\FOO;
+}
-namespace \;
+namespace {
echo $FOO;
echo $A\B\FOO;
echo $\FOO;
+}
+
?>
CODE
FOO in A::B
@@ -122,7 +109,7 @@
language_output_is( 'Pipp', <<'CODE', <<'OUT', 'namespace with class', todo => 'not implemented yet' );
<?php
-namespace A\B;
+namespace A\B {
class Dings {
@@ -134,6 +121,8 @@
$dings = new A\Dings;
$dings->bums();
+}
+
?>
CODE
The function bums() in class A\Dings has been called.
-
[svn:parrot] r35497 - in branches/removing_stm: . docs/book docs/dev docs/pdds include/parrot languages/befunge languages/ecmascript languages/ecmascript/src/classes languages/ecmascript/src/parser languages/ecmascript/t/js_pt languages/ecmascript/t/sanit
by Whiteknight