[svn:parrot] r38254 - in branches/headercleanup: . compilers/nqp/src compilers/nqp/src/Grammar compilers/nqp/t compilers/pct/src/PCT compilers/pge/PGE config/auto config/auto/format config/gen config/gen/makefiles config/gen/platform/openbsd config/init/hints config/inter docs docs/book docs/book/draft docs/dev docs/pdds docs/project examples/languages/abc examples/languages/squaak examples/streams include/parrot lib/Parrot lib/Parrot/Docs/Section ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/library runtime/parrot/library/Math src src/call src/gc src/interp src/jit/ppc src/packfile src/pmc src/runcore src/string/charset src/string/encoding t/benchmark t/codingstd t/compilers/imcc/syn t/compilers/pge/perl6regex t/compilers/tge t/dynpmc t/library t/native_pbc t/native_pbc/testdata t/pmc t/pmc/testlib t/src tools/build tools/dev tools/install tools/util
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Tue Apr 21 21:28:37 UTC 2009
Author: chromatic
Date: Tue Apr 21 21:28:29 2009
New Revision: 38254
URL: https://trac.parrot.org/parrot/changeset/38254
Log:
[headercleanup] Brought the headercleanup branch up to date with r38253.
Added:
branches/headercleanup/compilers/pct/src/PCT/Dumper.pir
- copied unchanged from r38253, trunk/compilers/pct/src/PCT/Dumper.pir
branches/headercleanup/ports/fedora/
- copied from r38253, trunk/ports/fedora/
branches/headercleanup/ports/mandriva/
- copied from r38253, trunk/ports/mandriva/
branches/headercleanup/ports/suse/
- copied from r38253, trunk/ports/suse/
branches/headercleanup/t/native_pbc/annotations.pbc
- copied unchanged from r38253, trunk/t/native_pbc/annotations.pbc
branches/headercleanup/t/native_pbc/testdata/
- copied from r38253, trunk/t/native_pbc/testdata/
branches/headercleanup/t/pmc/testlib/
- copied from r38253, trunk/t/pmc/testlib/
branches/headercleanup/tools/dev/create_language.pl
- copied unchanged from r38253, trunk/tools/dev/create_language.pl
Replaced:
branches/headercleanup/ports/fedora/parrot.spec.fedora
- copied unchanged from r38253, trunk/ports/fedora/parrot.spec.fedora
branches/headercleanup/ports/mandriva/parrot.spec.mandriva
- copied unchanged from r38253, trunk/ports/mandriva/parrot.spec.mandriva
branches/headercleanup/ports/suse/parrot.spec.suse
- copied unchanged from r38253, trunk/ports/suse/parrot.spec.suse
branches/headercleanup/t/native_pbc/testdata/README
- copied unchanged from r38253, trunk/t/native_pbc/testdata/README
branches/headercleanup/t/native_pbc/testdata/annotations.pir
- copied unchanged from r38253, trunk/t/native_pbc/testdata/annotations.pir
branches/headercleanup/t/pmc/testlib/packfile_common.pir
- copied unchanged from r38253, trunk/t/pmc/testlib/packfile_common.pir
Deleted:
branches/headercleanup/parrot.spec
Modified:
branches/headercleanup/ (props changed)
branches/headercleanup/CREDITS
branches/headercleanup/ChangeLog
branches/headercleanup/MANIFEST
branches/headercleanup/MANIFEST.generated
branches/headercleanup/META.yml
branches/headercleanup/NEWS
branches/headercleanup/PLATFORMS
branches/headercleanup/README
branches/headercleanup/RESPONSIBLE_PARTIES
branches/headercleanup/VERSION
branches/headercleanup/compilers/nqp/src/Grammar.pg
branches/headercleanup/compilers/nqp/src/Grammar/Actions.pir
branches/headercleanup/compilers/nqp/t/26-method_ops.t
branches/headercleanup/compilers/pct/src/PCT/HLLCompiler.pir
branches/headercleanup/compilers/pge/PGE/Exp.pir
branches/headercleanup/compilers/pge/PGE/Perl6Regex.pir
branches/headercleanup/config/auto/cgoto.pm
branches/headercleanup/config/auto/format/intval_maxmin_c.in (props changed)
branches/headercleanup/config/gen/makefiles/docs.in
branches/headercleanup/config/gen/makefiles/dynoplibs_pl.in
branches/headercleanup/config/gen/makefiles/dynpmc_pl.in
branches/headercleanup/config/gen/makefiles/pct.in
branches/headercleanup/config/gen/makefiles/root.in
branches/headercleanup/config/gen/parrot_include.pm
branches/headercleanup/config/gen/platform/openbsd/math.c
branches/headercleanup/config/init/hints/cygwin.pm
branches/headercleanup/config/init/hints/mswin32.pm
branches/headercleanup/config/inter/libparrot.pm
branches/headercleanup/docs/book/appa_glossary.pod (props changed)
branches/headercleanup/docs/book/appb_patch_submission.pod (contents, props changed)
branches/headercleanup/docs/book/appc_command_line_options.pod (props changed)
branches/headercleanup/docs/book/appd_build_options.pod (contents, props changed)
branches/headercleanup/docs/book/appe_source_code.pod (contents, props changed)
branches/headercleanup/docs/book/ch01_introduction.pod (contents, props changed)
branches/headercleanup/docs/book/ch02_getting_started.pod
branches/headercleanup/docs/book/ch03_pir.pod (contents, props changed)
branches/headercleanup/docs/book/ch04_compiler_tools.pod (props changed)
branches/headercleanup/docs/book/ch05_pge.pod (contents, props changed)
branches/headercleanup/docs/book/ch06_nqp.pod (contents, props changed)
branches/headercleanup/docs/book/ch07_dynpmcs.pod (props changed)
branches/headercleanup/docs/book/ch08_dynops.pod (contents, props changed)
branches/headercleanup/docs/book/ch09_pasm.pod (contents, props changed)
branches/headercleanup/docs/book/ch10_opcode_reference.pod (contents, props changed)
branches/headercleanup/docs/book/ch11_directive_reference.pod (props changed)
branches/headercleanup/docs/book/ch12_operator_reference.pod (props changed)
branches/headercleanup/docs/book/draft/chXX_hlls.pod (props changed)
branches/headercleanup/docs/book/draft/chXX_library.pod (props changed)
branches/headercleanup/docs/book/draft/chXX_testing_and_debugging.pod (props changed)
branches/headercleanup/docs/compiler_faq.pod
branches/headercleanup/docs/dev/c_functions.pod (props changed)
branches/headercleanup/docs/parrothist.pod
branches/headercleanup/docs/pdds/pdd07_codingstd.pod
branches/headercleanup/docs/pdds/pdd13_bytecode.pod
branches/headercleanup/docs/project/release_manager_guide.pod
branches/headercleanup/examples/languages/abc/ (props changed)
branches/headercleanup/examples/languages/squaak/ (props changed)
branches/headercleanup/examples/streams/FileLines.pir
branches/headercleanup/examples/streams/ParrotIO.pir
branches/headercleanup/include/parrot/call.h (props changed)
branches/headercleanup/include/parrot/gc_api.h (props changed)
branches/headercleanup/include/parrot/gc_mark_sweep.h (props changed)
branches/headercleanup/include/parrot/gc_pools.h (props changed)
branches/headercleanup/include/parrot/misc.h
branches/headercleanup/include/parrot/packfile.h
branches/headercleanup/include/parrot/runcore_trace.h (props changed)
branches/headercleanup/include/parrot/scheduler.h
branches/headercleanup/include/parrot/string_funcs.h
branches/headercleanup/include/parrot/thread.h
branches/headercleanup/lib/Parrot/Docs/Section/Parrot.pm
branches/headercleanup/lib/Parrot/Op.pm
branches/headercleanup/ports/cpan/cpan_release.pod
branches/headercleanup/ports/cpan/pause_guide.pod (contents, props changed)
branches/headercleanup/ports/cygwin/parrot-1.0.0-1.cygport (props changed)
branches/headercleanup/ports/debian/libparrot-dev.install.in (props changed)
branches/headercleanup/ports/debian/libparrot.install.in (props changed)
branches/headercleanup/ports/debian/parrot-doc.install.in (props changed)
branches/headercleanup/ports/debian/parrot.install.in (props changed)
branches/headercleanup/runtime/parrot/library/Math/Rand.pir (props changed)
branches/headercleanup/runtime/parrot/library/P6object.pir
branches/headercleanup/src/call/ops.c (props changed)
branches/headercleanup/src/call/pcc.c (props changed)
branches/headercleanup/src/exec_save.c
branches/headercleanup/src/gc/api.c (props changed)
branches/headercleanup/src/gc/generational_ms.c (props changed)
branches/headercleanup/src/gc/incremental_ms.c (props changed)
branches/headercleanup/src/gc/mark_sweep.c (props changed)
branches/headercleanup/src/gc/pools.c (props changed)
branches/headercleanup/src/gc/system.c (props changed)
branches/headercleanup/src/hll.c
branches/headercleanup/src/interp/inter_create.c (props changed)
branches/headercleanup/src/jit/ppc/asm.s
branches/headercleanup/src/multidispatch.c
branches/headercleanup/src/packfile.c
branches/headercleanup/src/packfile/pf_items.c
branches/headercleanup/src/pmc/fixedpmcarray.pmc
branches/headercleanup/src/pmc/hash.pmc
branches/headercleanup/src/pmc/namespace.pmc
branches/headercleanup/src/pmc/packfile.pmc
branches/headercleanup/src/pmc/packfileannotation.pmc
branches/headercleanup/src/pmc/packfileannotationkeys.pmc
branches/headercleanup/src/pmc/packfileannotations.pmc
branches/headercleanup/src/pmc/packfileconstanttable.pmc
branches/headercleanup/src/pmc/packfiledirectory.pmc
branches/headercleanup/src/pmc/packfilefixupentry.pmc
branches/headercleanup/src/pmc/packfilefixuptable.pmc
branches/headercleanup/src/pmc/packfilerawsegment.pmc
branches/headercleanup/src/pmc/packfilesegment.pmc
branches/headercleanup/src/runcore/cores.c (props changed)
branches/headercleanup/src/runcore/trace.c (props changed)
branches/headercleanup/src/string/charset/unicode.c
branches/headercleanup/src/string/encoding/ucs2.c
branches/headercleanup/src/string/encoding/utf8.c
branches/headercleanup/t/benchmark/benchmarks.t
branches/headercleanup/t/codingstd/c_function_docs.t
branches/headercleanup/t/codingstd/copyright.t
branches/headercleanup/t/codingstd/svn_id.t
branches/headercleanup/t/compilers/imcc/syn/pcc.t
branches/headercleanup/t/compilers/pge/perl6regex/rx_quantifiers
branches/headercleanup/t/compilers/tge/NoneGrammar.tg (props changed)
branches/headercleanup/t/dynpmc/pair.t (props changed)
branches/headercleanup/t/library/streams.t
branches/headercleanup/t/native_pbc/integer_1.pbc
branches/headercleanup/t/native_pbc/integer_2.pbc
branches/headercleanup/t/native_pbc/number_1.pbc
branches/headercleanup/t/native_pbc/number_2.pbc
branches/headercleanup/t/native_pbc/string_1.pbc
branches/headercleanup/t/native_pbc/string_2.pbc
branches/headercleanup/t/pmc/class.t
branches/headercleanup/t/pmc/nci.t
branches/headercleanup/t/pmc/packfile.t
branches/headercleanup/t/pmc/packfileannotation.t
branches/headercleanup/t/pmc/packfileannotationkeys.t
branches/headercleanup/t/pmc/packfileannotations.t
branches/headercleanup/t/pmc/packfileconstanttable.t
branches/headercleanup/t/pmc/packfiledirectory.t
branches/headercleanup/t/pmc/packfilefixupentry.t
branches/headercleanup/t/pmc/packfilefixuptable.t
branches/headercleanup/t/pmc/packfilerawsegment.t
branches/headercleanup/t/pmc/packfilesegment.t
branches/headercleanup/t/pmc/resizablepmcarray.t
branches/headercleanup/t/src/embed.t (props changed)
branches/headercleanup/tools/build/nativecall.pl
branches/headercleanup/tools/dev/fetch_languages.pl (contents, props changed)
branches/headercleanup/tools/dev/mk_gitignore.pl (props changed)
branches/headercleanup/tools/dev/mk_language_shell.pl
branches/headercleanup/tools/dev/pbc_to_exe.pir
branches/headercleanup/tools/install/smoke_languages.pl
branches/headercleanup/tools/util/perlcritic-cage.conf (props changed)
branches/headercleanup/tools/util/release.json
Modified: branches/headercleanup/CREDITS
==============================================================================
--- branches/headercleanup/CREDITS Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/CREDITS Tue Apr 21 21:28:29 2009 (r38254)
@@ -289,6 +289,11 @@
N: Danny Werner
D: Test for literals
+N: Daniel Arbelo Arrocha
+U: darbelo
+D: OpenBSD fixes and testing
+E: dany.arbelo at gmail.com
+
N: Dave Woldrich
D: Win32 build fixes
E: dave at woldrich.com
@@ -348,6 +353,7 @@
D: language Lua
D: language WMLScript (PIR translator)
D: Pipp
+D: Release manager for 1.1.0
N: Garrett Rooney
D: Fix typo in PARROT_BIGENDIAN case
@@ -383,6 +389,11 @@
E: gregor at focusresearch.com
S: Sunnyvale, CA
+N: Havard Eidnes
+U: he
+D: NetBSD and OpenBSD fixes
+E: he at NetBSD.org
+
N: H.Merijn Brand
D: HP-UX fixes and smoke tests
@@ -582,6 +593,10 @@
U: luqui
D: Many fixes
+U: LylePerl
+D: Win32 and CGI testing
+W: http://perl.bristolbath.org/blog/lyle/
+
N: Marcelo Serra Castilhos
E: mhelix at terra.com.br
D: Bug fix
@@ -749,9 +764,6 @@
E: pdcawley at bofh.org.uk
W: http://www.bofh.org.uk:8080/
-U: rg
-D: fixes to pod2html generator
-
N: Reini Urban
U: rurban
E: rurban at cpan.org
@@ -783,6 +795,11 @@
N: Roland Illing
D: Building Parrot with pkgsrc
+N: Rolf Grossmann
+U: rg
+D: pod2html fixes, floating point fixes, platform testing, cage cleaning
+E: rg at progtech.net
+
N: Ron Blaschke
U: rblasch
E: ron at rblasch.org
@@ -914,6 +931,7 @@
D: Lot of general Parrot design hints
N: Vasily Chekalkin
+U: bacek
E: bacek at bacek.com
D: Core and Rakudo patches
Modified: branches/headercleanup/ChangeLog
==============================================================================
--- branches/headercleanup/ChangeLog Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/ChangeLog Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,5 +1,9 @@
#1 $Id$
+2009.04.21 fperrad
+ * Released 1.1.0
+ See NEWS for more.
+
2009.03.17 allison
* Released 1.0.0
See NEWS for more.
Modified: branches/headercleanup/MANIFEST
==============================================================================
--- branches/headercleanup/MANIFEST Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/MANIFEST Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Apr 15 17:57:34 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Apr 19 13:39:13 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -122,6 +122,7 @@
compilers/pct/src/PAST.pir [pct]
compilers/pct/src/PAST/Compiler.pir [pct]
compilers/pct/src/PAST/Node.pir [pct]
+compilers/pct/src/PCT/Dumper.pir [pct]
compilers/pct/src/PCT/Grammar.pir [pct]
compilers/pct/src/PCT/HLLCompiler.pir [pct]
compilers/pct/src/PCT/Node.pir [pct]
@@ -1137,7 +1138,6 @@
lib/Pod/Simple/TranscodeSmart.pm []
lib/Pod/Simple/XHTML.pm []
lib/Pod/Simple/XMLOutStream.pm []
-parrot.spec []
parrotbug []
runtime/parrot/dynext/README []doc
runtime/parrot/include/README []doc
@@ -1718,6 +1718,7 @@
t/manifest/04-alt_file.t [test]
t/manifest/05-alt_skip.t [test]
t/manifest/README []doc
+t/native_pbc/annotations.pbc [test]
t/native_pbc/header.t [test]
t/native_pbc/integer.t [test]
t/native_pbc/integer_1.pbc [test]
@@ -1742,6 +1743,8 @@
t/native_pbc/string_4.pbc [test]
t/native_pbc/string_6.pbc [test]
t/native_pbc/string_7.pbc [test]
+t/native_pbc/testdata/README []doc
+t/native_pbc/testdata/annotations.pir [test]
t/oo/attributes.t [test]
t/oo/composition.t [test]
t/oo/inheritance.t [test]
@@ -1905,6 +1908,7 @@
t/pmc/sub.t [test]
t/pmc/sys.t [test]
t/pmc/task.t [test]
+t/pmc/testlib/packfile_common.pir [test]
t/pmc/threads.t [test]
t/pmc/timer.t [test]
t/pmc/undef.t [test]
@@ -2059,6 +2063,7 @@
tools/dev/as2c.pl []
tools/dev/bench_op.pir []
tools/dev/cc_flags.pl []
+tools/dev/create_language.pl []
tools/dev/debian_docs.sh []
tools/dev/fetch_languages.pl []
tools/dev/gen_charset_tables.pl []
Modified: branches/headercleanup/MANIFEST.generated
==============================================================================
--- branches/headercleanup/MANIFEST.generated Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/MANIFEST.generated Tue Apr 21 21:28:29 2009 (r38254)
@@ -2,10 +2,10 @@
# See tools/dev/install_files.pl for documentation on the
# format of this file.
# Please re-sort this file after *EVERY* modification
-blib/lib/libparrot.1.0.0.dylib [main]lib
+blib/lib/libparrot.1.1.0.dylib [main]lib
blib/lib/libparrot.a [main]lib
blib/lib/libparrot.dylib [main]lib
-blib/lib/libparrot.so.1.0.0 [main]lib
+blib/lib/libparrot.so.1.1.0 [main]lib
blib/lib/libparrot.so [main]lib
compilers/json/JSON/grammar.pbc [json]
compilers/json/JSON.pbc [json]
Modified: branches/headercleanup/META.yml
==============================================================================
--- branches/headercleanup/META.yml Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/META.yml Tue Apr 21 21:28:29 2009 (r38254)
@@ -4,7 +4,7 @@
# See http://module-build.sourceforge.net/META-spec-current.html for details.
---
name: parrot
-version: 1.0.0
+version: 1.1.0
author: parrot-dev at lists.parrot.org
abstract: a virtual machine designed for dynamic languages
license: artistic2
Modified: branches/headercleanup/NEWS
==============================================================================
--- branches/headercleanup/NEWS Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/NEWS Tue Apr 21 21:28:29 2009 (r38254)
@@ -2,14 +2,33 @@
New in 1.1.0
- Core
- + Added op: load_language
+ + Added op: load_language, find_caller_lex
+ + socket IO are back as PMC
+ + refactor some PMC: Hash, ManagedStruct
+- Compiler
+ + PGE
+ - Allow \x, \c, and \o in enumerated character classes (incl ranges)
+ - Add initial greedy-only version of ** <exp> quantifier
+ + PCT
+ - Add HLL source line bytecode annotations
+ - Add another dumper format to assist syntax highlighters
+ - Revise mk_language_shell.pl to updated create_language.pl
- Deprecations
+ Removed ops: gcd, exec, classname, need_finalize, runinterp, substr_r
- + Removed dynamic op: mul
+ + Removed dynamic op: mul
+ Removed .HLL_map directive; use interp's .hll_map() instead
+ Removed PMCs: slice, bound_nci, ref
+ Removed Configure.pl option: --pmc
+ Removed PMC union struct
+- Documentation
+ + Book
+ - Reorganization and many improvements & additions
+- Tools
+ + Add a parrot-fuzzer
+- Miscellaneous
+ + Improve Debian/Ubuntu package
+ + various bugfixes, code cleanups, and coding standard fixes
+
New in 1.0.0
- Documentation
Modified: branches/headercleanup/PLATFORMS
==============================================================================
--- branches/headercleanup/PLATFORMS Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/PLATFORMS Tue Apr 21 21:28:29 2009 (r38254)
@@ -14,19 +14,18 @@
CGoto JIT EXEC Thr Sig
--------------------------------------------------------------------------------
cygwin1.5.25-x86-gcc3.4.4 4 Y Y - - - Y Y Y 20090315
-darwin8.11.1-x86-gcc4.0.1 ?? ? ? ? ? ? Y Y/1*2 ? 20081216
-freebsd-x86-gcc-3.4.6 Y ? ? ? ? Y Y ? 20080519
-linux-x86-gcc4.1.2 Y Y ? Y Y Y Y ? 20080617
+darwin8.11.1-x86-gcc4.0.1 ?? ? N ? ? ? Y Y*3 Y 20090420
+linux-x86-gcc4.1.2 Y Y ? Y Y Y Y ? 20090419
linux-x86-gcc4.1.3 Y Y ? Y Y Y Y ? 20080414
linux-x86-gcc4.2.3 Y Y ? Y Y Y Y ? 20080715
linux-x86-gcc4.2.4 Y Y ? Y Y Y Y ? 20081023
linux-x86-gcc4.3.2 Y Y ? Y Y Y Y ? 20081030
linux-x86-llvm-gcc-4.2 Y Y ? ? ? Y Y ? 20080801
-sol10-sparc-cc_5.9 B4*2 Y - - Y Y Y Y ? 20080510
-sol10-sparc-cc_5.9 B8 Y - - Y Y Y Y/3*1 ? 20090217
-sol10-sparc-gcc_4.0.2 B4*2 Y - - Y Y Y Y/1 ? 20080510
+sol10-sparc-cc_5.9 B4 Y - - Y Y Y Y ? 20090419
+sol10-sparc-cc_5.9 B8 Y - - Y Y Y Y ? 20090419
+sol10-sparc-gcc_4.0.2 B4 Y - - Y Y Y Y/1 ? 20080510
sol10-sparc-gcc_4.0.2 B8 Y - - Y Y Y Y/2 ? 20080518
-win32-x86-mingw_gcc3.4.5 Y Y - - - Y Y Y 20090217
+win32-x86-mingw_gcc3.4.5 Y Y - - - Y Y Y 20090421
win32-x86-msvc_9.0 - Y - Y - Y Y ? 20090317
@@ -37,11 +36,21 @@
--------------------------------------------------------------------------------
aix5.3-power-gcc4.2 B8 - - - Y ? ? 20080510
cygwin1.7.0-x86-gcc4.3.2 4 Y Y - - - Y Y Y 20090315
-freebsd-x86-gcc-3.4.6 Y ? ? ? ? Y Y ? 20080519
+freebsd-x86-gcc-4.2.1 4 Y Y Y ? ? Y Y Y 20090415
+freebsd-amd64-gcc-4.2.1 8 Y - - ? ? Y Y Y 20090419
linux-ppc-gcc3.4.5 Y Y Y ? ? Y Y ? 20080519
linux-s390x-gcc4.1.2 B4 ? - - Y Y Y Y/2 ? 20080908
linux-x86_64-gcc4.1.2 8 Y - - Y Y Y Y ? 20080220
linux-x86_64-gcc4.3.2 8 Y - - Y Y Y Y ? 20081118
+linux-x86_64-gcc4.3.3 8 Y - - Y Y Y Y ? 20090419
+netbsd3.1-ppc-gcc-3.3.3 B Y Y ? Y Y Y Y ? 20090419
+netbsd4.0-arm-gcc-4.1.2 Y - ? Y Y Y Y ? 20090421
+netbsd4.0-i386-gcc-4.1.2 Y Y ? Y Y Y Y ? 20090419
+netbsd4.0-ppc-gcc-4.1.2 B Y Y ? Y Y Y Y ? 20090419
+netbsd4.0-x86_64-gcc-4.1.2 8 Y - ? Y Y Y Y ? 20090419
+netbsd5.0-i386-gcc-4.1.3 Y Y ? Y Y Y Y ? 20090419
+netbsd5.0-sparc64-gcc-4.1.3 B8 Y - - Y Y Y Y ? 20090421
+netbsd5.0-x86_64-gcc-4.1.3 8 Y - - Y Y Y Y ? 20090419
opensolaris-x86-gcc_4.0.3 4 Y Y ? ? ? Y Y/2 ? 20080325
sol8-sparc-cc B - - - - - - Y ? 20090317
sol8-sparc-gcc_4.1.0 B - - - - - - Y/42 ? 20090317
@@ -77,9 +86,9 @@
Remarks:
*1 gcc and cc defaults to 32bits on solaris, for 64bit use
- --ccflags='-m64 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO'
- --ldflags='-m64'
+ --ccflags='-m64' --ldflags='-m64' --linkflags='-m64'
*2 http://rt.perl.org/rt3/Ticket/Display.html?id=60926
+*3 failures in 'make examples_tests' (part of 'make fulltest')
The following configurations are also working on x86/linux (and possibly
other platforms):
Modified: branches/headercleanup/README
==============================================================================
--- branches/headercleanup/README Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/README Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,4 +1,4 @@
-This is Parrot, version 1.0.0
+This is Parrot, version 1.1.0
------------------------------
Parrot is Copyright (C) 2001-2009, Parrot Foundation.
Modified: branches/headercleanup/RESPONSIBLE_PARTIES
==============================================================================
--- branches/headercleanup/RESPONSIBLE_PARTIES Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/RESPONSIBLE_PARTIES Tue Apr 21 21:28:29 2009 (r38254)
@@ -24,6 +24,7 @@
Will Coleda
Andrew Whitworth
Klaas-Jan Stol
+ Francois Perrad
Metacommitter Allison Randal
Jerry Gay
Modified: branches/headercleanup/VERSION
==============================================================================
--- branches/headercleanup/VERSION Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/VERSION Tue Apr 21 21:28:29 2009 (r38254)
@@ -1 +1 @@
-1.0.0
+1.1.0
Modified: branches/headercleanup/compilers/nqp/src/Grammar.pg
==============================================================================
--- branches/headercleanup/compilers/nqp/src/Grammar.pg Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/nqp/src/Grammar.pg Tue Apr 21 21:28:29 2009 (r38254)
@@ -261,16 +261,17 @@
token methodop {
'.' <ident>
- '(' <arglist>
- [ <.ws> ')' || <panic: "Missing ')'"> ]
- {*} #= methodop
+ [
+ | '(' ~ ')' <arglist> {*} #= arglist
+ | {*} #= null
+ ]
}
token postcircumfix {
| '(' <arglist> ')' {*} #= ( )
| '[' <EXPR> <.ws> ']' {*} #= [ ]
| '{' <EXPR> <.ws> '}' {*} #= { }
- | '<' <string_literal: '>' > '>' {*} #= < >
+ | '<' <string_literal: '>' > '>' {*} #= < >
}
rule arglist {
Modified: branches/headercleanup/compilers/nqp/src/Grammar/Actions.pir
==============================================================================
--- branches/headercleanup/compilers/nqp/src/Grammar/Actions.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/nqp/src/Grammar/Actions.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -538,7 +538,9 @@
## method methodop($/, $key) {
-## my $past := $($<arglist>);
+## my $past := $key eq 'null'
+## ?? PAST::Op.new
+## !! $<arglist>.ast;
## $past.name(~$<ident>);
## $past.pasttype('callmethod');
## $past.node($/);
@@ -548,8 +550,14 @@
.param pmc match
.param string key
.local pmc past
+ unless key == 'null' goto arglist
+ $P0 = get_hll_global ['PAST'], 'Op'
+ past = $P0.'new'()
+ goto have_past
+ arglist:
$P0 = match['arglist']
past = $P0.'ast'()
+ have_past:
$S0 = match['ident']
past.'name'($S0)
past.'pasttype'('callmethod')
Modified: branches/headercleanup/compilers/nqp/t/26-method_ops.t
==============================================================================
--- branches/headercleanup/compilers/nqp/t/26-method_ops.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/nqp/t/26-method_ops.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -2,12 +2,15 @@
# method ops (just method calls for now)
-plan(2);
+plan(3);
class Foo {
method blarg() {
'ok 1 # method calls work';
}
+ method blargless() {
+ 'ok 3 # argument-less method calls work'
+ }
}
class Bar {
@@ -24,3 +27,4 @@
say($foo.blarg());
say(blarg());
+say($foo.blargless);
Copied: branches/headercleanup/compilers/pct/src/PCT/Dumper.pir (from r38253, trunk/compilers/pct/src/PCT/Dumper.pir)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/compilers/pct/src/PCT/Dumper.pir Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/compilers/pct/src/PCT/Dumper.pir)
@@ -0,0 +1,106 @@
+# $Id$
+
+=head1 NAME
+
+PCT::Dumper - various dumper formats for PCT
+
+=head1 DESCRIPTION
+
+This file implements a dumper that attempts to output PAST,
+Match, and Capture objects in a YAML-compatible format.
+Yes, the code is probably much uglier and convoluted than
+it should be. No, I'm not proud of it, but it works for now.
+
+=cut
+
+.namespace ['PCT';'Dumper']
+
+.sub 'padre'
+ .param pmc obj
+ .param string name
+ .param pmc options :slurpy :named
+
+ 'padre_item'(obj, name)
+.end
+
+
+.sub 'padre_item' :multi(_)
+ .param pmc obj
+ .param pmc name
+.end
+
+
+.sub 'padre_item' :multi(['PGE';'Match'])
+ .param pmc obj
+ .param pmc name
+
+ .local string str
+ str = obj.'Str'()
+ $I0 = length str
+ if $I0 < 48 goto have_str
+ str = substr str, 0, 48
+ str .= '...'
+ have_str:
+ str = escape str
+
+ $S0 = obj['type']
+ unless $S0 goto have_name
+ name = $S0
+ have_name:
+
+ $P0 = new 'ResizablePMCArray'
+ $I1 = obj.'from'()
+ push $P0, $I1
+ $I2 = obj.'to'()
+ $I2 -= $I1
+ push $P0, $I2
+ push $P0, name
+ push $P0, str
+
+ $S0 = sprintf ' %4d %4d %-20s "%s"', $P0
+ say $S0
+
+ .local pmc hash, hash_it
+ hash = obj.'hash'()
+ hash_it = iter hash
+ hash_it_loop:
+ unless hash_it goto hash_it_done
+ .local string key
+ key = shift hash_it
+ $P0 = hash[key]
+ 'padre_item'($P0, key)
+ goto hash_it_loop
+ hash_it_done:
+
+ $P0 = obj.'list'()
+ 'padre_item'($P0, name)
+
+.end
+
+
+.sub 'padre_item' :multi(['ResizablePMCArray'])
+ .param pmc obj
+ .param pmc name
+
+ .local pmc list_it
+ list_it = iter obj
+ list_it_loop:
+ unless list_it goto list_it_done
+ $P0 = shift list_it
+ 'padre_item'($P0, name)
+ goto list_it_loop
+ list_it_done:
+.end
+
+=head1 AUTHOR
+
+Patrick R. Michaud <pmichaud at pobox.com>
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
Modified: branches/headercleanup/compilers/pct/src/PCT/HLLCompiler.pir
==============================================================================
--- branches/headercleanup/compilers/pct/src/PCT/HLLCompiler.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/pct/src/PCT/HLLCompiler.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -31,7 +31,7 @@
$P0 = split ' ', 'parse past post pir evalpmc'
setattribute self, '@stages', $P0
- $P0 = split ' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s combine version|v'
+ $P0 = split ' ', 'e=s help|h target=s dumper=s trace|t=s encoding=s output|o=s combine version|v'
setattribute self, '@cmdoptions', $P0
$P1 = box <<' USAGE'
@@ -582,7 +582,7 @@
if null $P0 goto interactive_loop
unless target goto interactive_loop
if target == 'pir' goto target_pir
- '_dumper'($P0, target)
+ self.'dumper'($P0, target, adverbs :flat :named)
goto interactive_loop
target_pir:
say $P0
@@ -690,7 +690,7 @@
$P0 = self.'eval'(code, args :flat, adverbs :flat :named)
if target == '' goto end
if target == 'pir' goto end
- '_dumper'($P0, target)
+ self.'dumper'($P0, target, adverbs :flat :named)
end:
.return ($P0)
@@ -845,6 +845,28 @@
.return ($P0)
.end
+=item dumper(obj, name, options)
+
+Dump C<obj> with C<name> according to C<options>.
+
+=cut
+
+.sub 'dumper' :method
+ .param pmc obj
+ .param string name
+ .param pmc options :slurpy :named
+
+ $S0 = options['dumper']
+ if $S0 goto load_dumper
+ .tailcall '_dumper'(obj, name)
+
+ load_dumper:
+ load_bytecode 'PCT/Dumper.pbc'
+ downcase $S0
+ $P0 = get_hll_global ['PCT';'Dumper'], $S0
+ .tailcall $P0(obj, name)
+.end
+
=item usage()
Modified: branches/headercleanup/compilers/pge/PGE/Exp.pir
==============================================================================
--- branches/headercleanup/compilers/pge/PGE/Exp.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/pge/PGE/Exp.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -466,8 +466,9 @@
.sub 'reduce' :method
.param pmc next
- .local pmc exp0
+ .local pmc exp0, sep
exp0 = self[0]
+ sep = self['sep']
.local int backtrack, min, max
backtrack = self['backtrack']
@@ -489,6 +490,10 @@
reduce_exp0:
exp0 = exp0.'reduce'(next)
self[0] = exp0
+ if null sep goto reduce_exp0_1
+ sep = sep.'reduce'(next)
+ self['sep'] = sep
+ reduce_exp0_1:
.return (self)
.end
@@ -497,10 +502,12 @@
.param string label
.param string next
- .local pmc exp
- .local string explabel, replabel
+ .local pmc exp, sep
+ .local string explabel, seplabel, replabel, nextlabel
exp = self[0]
+ sep = self['sep']
+ unless null sep goto outer_quant
$I0 = can exp, 'pir_quant'
if $I0 == 0 goto outer_quant
$I0 = exp.'pir_quant'(code, label, next, self)
@@ -515,7 +522,12 @@
backtrack = self['backtrack']
explabel = code.'unique'('R')
+ nextlabel = explabel
replabel = concat label, '_repeat'
+ if null sep goto outer_quant_1
+ seplabel = code.'unique'('R')
+ nextlabel = concat label, '_sep'
+ outer_quant_1:
if backtrack == PGE_BACKTRACK_EAGER goto bt_eager
if backtrack == PGE_BACKTRACK_NONE goto bt_none
@@ -528,7 +540,7 @@
if $I0 != 0 goto bt_greedy_none
$I0 = self['max']
if $I0 != PGE_INF goto bt_greedy_none
- code.'emit'(<<" CODE", replabel, explabel, args :flat :named)
+ code.'emit'(<<" CODE", replabel, nextlabel, args :flat :named)
%L: # quant 0..Inf greedy
%0:
push ustack, pos
@@ -548,7 +560,7 @@
if $I0 != 0 goto bt_greedy_none
$I0 = self['max']
if $I0 != PGE_INF goto bt_greedy_none
- code.'emit'(<<" CODE", replabel, explabel, args :flat :named)
+ code.'emit'(<<" CODE", replabel, nextlabel, args :flat :named)
%L: # quant 0..Inf none
local_branch cstack, %0
if cutmark != %c goto fail
@@ -568,7 +580,7 @@
bt_greedy_none:
## handle greedy or none
- code.'emit'(<<" CODE", replabel, explabel, args :flat :named)
+ code.'emit'(<<" CODE", replabel, nextlabel, args :flat :named)
%L: # quant %Q greedy/none
push gpad, 0
local_branch cstack, %0
@@ -603,7 +615,7 @@
bt_eager:
## handle eager backtracking
- code.'emit'(<<" CODE", replabel, explabel, args :flat :named)
+ code.'emit'(<<" CODE", replabel, nextlabel, args :flat :named)
%L: # quant %Q eager
push gpad, 0
local_branch cstack, %0
@@ -627,6 +639,14 @@
CODE
end:
+ if null sep goto sep_done
+ code.'emit'(<<" CODE", nextlabel, explabel, seplabel)
+ %0:
+ if rep == 1 goto %1
+ goto %2
+ CODE
+ sep.'pir'(code, seplabel, explabel)
+ sep_done:
exp.'pir'(code, explabel, replabel)
.return ()
.end
Modified: branches/headercleanup/compilers/pge/PGE/Perl6Regex.pir
==============================================================================
--- branches/headercleanup/compilers/pge/PGE/Perl6Regex.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/compilers/pge/PGE/Perl6Regex.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -607,10 +607,11 @@
(mob, pos, target) = mob.'new'(mob, 'grammar'=>'PGE::Exp::Quant')
lastpos = length target
- .local int min, max, suffixpos
+ .local int min, max, suffixpos, sepws
.local string suffix
min = 1
max = 1
+ sepws = is_cclass .CCLASS_WHITESPACE, target, pos
suffixpos = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
if key == '**' goto quant_suffix
@@ -657,12 +658,14 @@
quant:
if key != '**' goto quant_set
quant_closure:
+ $I0 = is_cclass .CCLASS_WHITESPACE, target, pos
+ sepws |= $I0
pos = find_not_cclass .CCLASS_WHITESPACE, target, pos, lastpos
.local int isconst
isconst = is_cclass .CCLASS_NUMERIC, target, pos
if isconst goto brace_skip
$S0 = substr target, pos, 1
- if $S0 != "{" goto err_closure
+ if $S0 != "{" goto parse_repetition_controller
inc pos
brace_skip:
$I1 = find_not_cclass .CCLASS_NUMERIC, target, pos, lastpos
@@ -700,6 +703,45 @@
end:
.return (mob)
+ parse_repetition_controller:
+ .local pmc regex, repetition_controller
+ mob.'to'(pos)
+ regex = get_global 'regex'
+ #parse everything down to concatenation precedence
+ repetition_controller = regex(mob, 'tighter'=>'infix:')
+ unless repetition_controller goto err_repetition_controller
+
+ #update pos to after the matched
+ pos = repetition_controller.'to'()
+ repetition_controller = repetition_controller['expr']
+
+ # if there's surrounding ws, then add WS nodes
+ unless sepws goto sepws_done
+ $P0 = mob.'new'(mob, 'grammar'=>'PGE::Exp::Concat')
+ $P0.'to'(pos)
+ $P1 = mob.'new'(mob, 'grammar'=>'PGE::Exp::WS')
+ $P1.'to'(pos)
+ push $P0, $P1
+ push $P0, repetition_controller
+ $P1 = mob.'new'(mob, 'grammar'=>'PGE::Exp::WS')
+ $P1.'to'(pos)
+ push $P0, $P1
+ repetition_controller = $P0
+ sepws_done:
+
+ #save the matched in the mob as sep
+ mob['sep'] = repetition_controller
+
+ #force the match to be 1..Inf
+ mob['min'] = 1
+ mob['max'] = PGE_INF
+
+ #move position to after the matched
+ mob.'to'(pos)
+ .return (mob)
+
+ err_repetition_controller:
+ 'parse_error'(mob, pos, "Error in repetition controller")
err_closure:
'parse_error'(mob, pos, "Error in closure quantifier")
.end
@@ -1390,7 +1432,7 @@
self['backtrack'] = PGE_BACKTRACK_NONE
backtrack_done:
- .local pmc exp0
+ .local pmc exp0, sep
.local int isarray
isarray = pad['isarray']
pad['isarray'] = 1
@@ -1400,6 +1442,11 @@
exp0['isquant'] = 1
exp0 = exp0.'perl6exp'(pad)
self[0] = exp0
+ sep = self['sep']
+ if null sep goto sep_done
+ sep = sep.'perl6exp'(pad)
+ self['sep'] = sep
+ sep_done:
pad['isarray'] = isarray
.return (self)
err_parse_quant:
Modified: branches/headercleanup/config/auto/cgoto.pm
==============================================================================
--- branches/headercleanup/config/auto/cgoto.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/auto/cgoto.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -62,8 +62,10 @@
TEMP_cg_c => <<'EOF',
# generated by config/auto/cgoto.pm
-$(OPS_DIR)/core_ops_cg$(O): $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_cg.c
-$(OPS_DIR)/core_ops_cgp$(O): $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_cgp.c
+$(OPS_DIR)/core_ops_cg$(O): $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_cg.c \
+ $(SRC_DIR)/pmc/pmc_parrotlibrary.h
+$(OPS_DIR)/core_ops_cgp$(O): $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_cgp.c \
+ $(SRC_DIR)/pmc/pmc_parrotlibrary.h
$(SRC_DIR)/runcore/cores.c: $(INC_DIR)/oplib/core_ops_cgp.h
$(INC_DIR)/oplib/core_ops_cg.h: $(OPS_DIR)/core_ops_cg.c
Modified: branches/headercleanup/config/gen/makefiles/docs.in
==============================================================================
--- branches/headercleanup/config/gen/makefiles/docs.in Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/makefiles/docs.in Tue Apr 21 21:28:29 2009 (r38254)
@@ -43,7 +43,7 @@
clean:
$(RM_F) packfile-c.pod $(POD)
-html:
+html: all
$(PERL) -I../lib ../tools/docs/write_docs.pl --silent --version=$(VERSION)
html-clean:
Modified: branches/headercleanup/config/gen/makefiles/dynoplibs_pl.in
==============================================================================
--- branches/headercleanup/config/gen/makefiles/dynoplibs_pl.in Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/makefiles/dynoplibs_pl.in Tue Apr 21 21:28:29 2009 (r38254)
@@ -83,7 +83,7 @@
"$LD ".
"@ld_out@" . $target . " " .
join(" ", map {"$PATHQUOTE$_$PATHQUOTE"} @$sources) .
- " $liblist $LDFLAGS $LD_LOAD_FLAGS $PATHQUOTE$LIBPARROT$PATHQUOTE";
+ " $liblist $LDFLAGS $LD_LOAD_FLAGS $LIBPARROT";
}
our $NOW = time();
Modified: branches/headercleanup/config/gen/makefiles/dynpmc_pl.in
==============================================================================
--- branches/headercleanup/config/gen/makefiles/dynpmc_pl.in Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/makefiles/dynpmc_pl.in Tue Apr 21 21:28:29 2009 (r38254)
@@ -108,7 +108,7 @@
"$LD ".
'@ld_out@' . $target . " " .
join(" ", map {"$PATHQUOTE$_$PATHQUOTE"} @$sources) .
- " $liblist $LDFLAGS $LD_LOAD_FLAGS $PATHQUOTE$LIBPARROT$PATHQUOTE";
+ " $liblist $LDFLAGS $LD_LOAD_FLAGS $LIBPARROT";
}
our $NOW = time();
Modified: branches/headercleanup/config/gen/makefiles/pct.in
==============================================================================
--- branches/headercleanup/config/gen/makefiles/pct.in Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/makefiles/pct.in Tue Apr 21 21:28:29 2009 (r38254)
@@ -18,10 +18,12 @@
$(PARROT_LIBRARY)/PCT.pbc \
$(PARROT_LIBRARY)/PCT/PAST.pbc \
$(PARROT_LIBRARY)/PCT/Grammar.pbc \
- $(PARROT_LIBRARY)/PCT/HLLCompiler.pbc
+ $(PARROT_LIBRARY)/PCT/HLLCompiler.pbc \
+ $(PARROT_LIBRARY)/PCT/Dumper.pbc
PCT_SOURCES := \
PCT.pir \
+ src/PCT/Dumper.pir \
src/PCT/Grammar.pir \
src/PCT/HLLCompiler.pir \
src/PCT/Node.pir \
@@ -38,6 +40,7 @@
$(PARROT) -o $(PARROT_LIBRARY)/PCT/PAST.pbc --output-pbc src/PAST.pir
$(PARROT) -o $(PARROT_LIBRARY)/PCT/Grammar.pbc --output-pbc src/PCT/Grammar.pir
$(PARROT) -o $(PARROT_LIBRARY)/PCT/HLLCompiler.pbc --output-pbc src/PCT/HLLCompiler.pir
+ $(PARROT) -o $(PARROT_LIBRARY)/PCT/Dumper.pbc --output-pbc src/PCT/Dumper.pir
# This is a listing of all targets, that are meant to be called by users
help:
Modified: branches/headercleanup/config/gen/makefiles/root.in
==============================================================================
--- branches/headercleanup/config/gen/makefiles/root.in Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/makefiles/root.in Tue Apr 21 21:28:29 2009 (r38254)
@@ -1221,7 +1221,7 @@
$(IO_DIR)/filehandle$(O) : $(SRC_DIR)/pmc/pmc_filehandle.h $(SRC_DIR)/io/io_private.h
$(OPS_DIR)/core_ops$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops.c \
- $(SRC_DIR)/pmc/pmc_continuation.h $(SRC_DIR)/pmc/pmc_continuation.h
+ $(SRC_DIR)/pmc/pmc_continuation.h $(SRC_DIR)/pmc/pmc_parrotlibrary.h
$(OPS_DIR)/pic.ops : $(SRC_DIR)/pmc/pmc_fixedintegerarray.h
@@ -1237,7 +1237,8 @@
$(SRC_DIR)/pmc/pmc_continuation.h
$(PERL) $(BUILD_TOOLS_DIR)/ops2c.pl C --core
-$(OPS_DIR)/core_ops_switch$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_switch.c
+$(OPS_DIR)/core_ops_switch$(O) : $(GENERAL_H_FILES) $(OPS_DIR)/core_ops_switch.c \
+ $(SRC_DIR)/pmc/pmc_parrotlibrary.h
$(INC_DIR)/oplib/core_ops_switch.h : $(OPS_DIR)/core_ops_switch.c
@@ -1466,11 +1467,17 @@
# Run test cases with a single call of t/harness. Users have to look at only
# one report. The default set of tests to run is contained in t/harness,
-# make any edits there.
+# make any edits there. Some tests are run in a separate harness only because
+# integrating them in a single run is difficult.
+
# Normal test package
-test : test_prep test_pbc_annotation_persistence
+test : test_prep test_pbc_annotation_persistence nqp_test
$(PERL) t/harness $(EXTRA_TEST_ARGS)
+# Test the NQP compiler
+nqp_test : test_prep
+ $(MAKE) compilers/nqp test
+
# run the test suite, create a TAP archive and send it off to smolder
smolder_test : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) --archive --send-to-smolder
@@ -2217,13 +2224,6 @@
mv MANIFEST.real MANIFEST
rm parrot-$(VERSION)
-rpms : release
- mkdir -p rpmbuild/SOURCES rpmbuild/SPEC rpmbuild/BUILD rpmbuild/RPMS rpmbuild/SRPMS
- cp parrot-$(VERSION).tar.gz rpmbuild/SOURCES
- cp parrot.spec rpmbuild/SPEC
- echo '%_topdir '`pwd`'/rpmbuild' > .rpmmacros
- HOME=`pwd`; rpmbuild -ba parrot.spec
-
win32-inno-installer : world installable
$(PERL) tools/dev/mk_inno.pl
$(INNO_SETUP) parrot.iss
Modified: branches/headercleanup/config/gen/parrot_include.pm
==============================================================================
--- branches/headercleanup/config/gen/parrot_include.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/parrot_include.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -37,6 +37,7 @@
include/parrot/io.h
include/parrot/longopt.h
include/parrot/multidispatch.h
+ include/parrot/packfile.h
include/parrot/resources.h
include/parrot/stat.h
include/parrot/string.h
Modified: branches/headercleanup/config/gen/platform/openbsd/math.c
==============================================================================
--- branches/headercleanup/config/gen/platform/openbsd/math.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/gen/platform/openbsd/math.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -26,9 +26,12 @@
*/
#include <math.h>
+#ifdef _IEEE_
_LIB_VERSION_TYPE _LIB_VERSION = _IEEE_;
+#endif
+
#if DOUBLE_SIZE == 2 * INT_SIZE
/*
Modified: branches/headercleanup/config/init/hints/cygwin.pm
==============================================================================
--- branches/headercleanup/config/init/hints/cygwin.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/init/hints/cygwin.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -19,6 +19,8 @@
my $build_dir = $conf->data->get('build_dir');
$build_dir =~ s/ /\\ /g;
+ my $bindir = $conf->data->get('bindir');
+ $bindir =~ s/ /\\ /g;
my $libparrot_shared = $conf->data->get('libparrot_shared');
# force cyg prefix
$libparrot_shared =~ s/^lib/cyg/g;
@@ -49,6 +51,7 @@
libparrot_shared => $libparrot_shared,
blib_dir => '.',
libparrot_ldflags => '-L' . $build_dir . ' -lparrot',
+ inst_libparrot_ldflags => '-L' . $bindir . ' -lparrot',
);
# inet_aton needs to be defined on Cygwin.
Modified: branches/headercleanup/config/init/hints/mswin32.pm
==============================================================================
--- branches/headercleanup/config/init/hints/mswin32.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/init/hints/mswin32.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -37,6 +37,12 @@
$conf->data->set( build_dir => Win32::GetShortPathName($build_dir) );
}
+ my $bindir = $conf->data->get('bindir');
+
+ if ( $bindir =~ /\s/ ) {
+ $conf->data->set( bindir => Win32::GetShortPathName($bindir) );
+ }
+
if ($is_msvc) {
my $msvcversion = $conf->data->get('msvcversion');
@@ -240,6 +246,7 @@
ld_load_flags => '-shared ',
ld_share_flags => '-shared ',
libparrot_ldflags => "\"$build_dir\\libparrot.dll\"",
+ inst_libparrot_ldflags => "\"$bindir\\libparrot.dll\"",
ncilib_link_extra => 'src/libnci_test.def',
sym_export => '__declspec(dllexport)',
sym_import => '__declspec(dllimport)',
Modified: branches/headercleanup/config/inter/libparrot.pm
==============================================================================
--- branches/headercleanup/config/inter/libparrot.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/config/inter/libparrot.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -128,6 +128,14 @@
);
}
+ unless ( defined( $conf->data->get('inst_libparrot_ldflags') ) ) {
+ $conf->data->set(inst_libparrot_ldflags =>
+ '-L'
+ . $conf->data->get('libdir')
+ . ' -lparrot'
+ );
+ }
+
$self->set_result( $parrot_is_shared ? 'yes' : 'no' );
return 1;
Modified: branches/headercleanup/docs/book/appb_patch_submission.pod
==============================================================================
--- branches/headercleanup/docs/book/appb_patch_submission.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/appb_patch_submission.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -131,3 +131,8 @@
Parrot_unblock_GC_sweep(interpreter);
=cut
+
+# Local variables:
+# c-file-style: "parrot"
+# End:
+# vim: expandtab shiftwidth=4:
Modified: branches/headercleanup/docs/book/appd_build_options.pod
==============================================================================
--- branches/headercleanup/docs/book/appd_build_options.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/appd_build_options.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -86,3 +86,8 @@
sudo cpan Perl::Critic Perl::Critic::Bangs Test::Perl::Critic
=cut
+
+# Local variables:
+# c-file-style: "parrot"
+# End:
+# vim: expandtab shiftwidth=4:
Modified: branches/headercleanup/docs/book/appe_source_code.pod
==============================================================================
--- branches/headercleanup/docs/book/appe_source_code.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/appe_source_code.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -65,3 +65,8 @@
respectively.
=cut
+
+# Local variables:
+# c-file-style: "parrot"
+# End:
+# vim: expandtab shiftwidth=4:
Modified: branches/headercleanup/docs/book/ch01_introduction.pod
==============================================================================
--- branches/headercleanup/docs/book/ch01_introduction.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch01_introduction.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -10,12 +10,12 @@
including a register-based system rather than stack-based, and employing
continuations as the core means of flow control.
-The name "Parrot" started with an April Fools' Day joke in 2001. Simon
-Cozens published an article titled "Programming Parrot", with a
-fictional interview between Guido van Rossum and Larry Wall detailing
-their plans to merge Python and Perl into a new language called Parrot
-(U<http://www.perl.com/pub/a/2001/04/01/parrot.htm>), inspired by Monty
-Python's Parrot sketch.
+The name "Parrot" was inspired by Monty Python's Parrot sketch. It
+started with an April Fools' Day joke in 2001. Simon Cozens published an
+article titled "Programming Parrot", with a fictional interview between
+Guido van Rossum and Larry Wall detailing their plans to merge Python
+and Perl into a new language called Parrot
+(U<http://www.perl.com/pub/a/2001/04/01/parrot.htm>).
=head2 Parrot Resources
@@ -36,7 +36,7 @@
The primary mailing list for Parrot is I<parrot-dev at lists.parrot.org>.
If you're interested in getting involved in development, you may also
-want to follow I<parrot-commits> and I<parrot-tickets> lists.
+want to follow the I<parrot-commits> and I<parrot-tickets> lists.
Information on all the Parrot mailing lists and subscription forms for
each is available at U<http://lists.parrot.org/mailman/listinfo>.
@@ -51,7 +51,7 @@
Parrot developers and users congregate on IRC at C<#parrot> on the
U<irc://irc.parrot.org> server. It's a good place to get real-time
-answers to questions, or just to see how things are progressing.
+answers to questions or see how things are progressing.
=head3 Issue Tracking & Wiki
@@ -65,7 +65,7 @@
=head2 Parrot Development
-X<development cycles;Parrot>
+X<development cycles>
First released in September 2001, Parrot hit 1.0 in March 2009. The
Parrot project makes releases on the third Tuesday of each month. Two
@@ -93,6 +93,8 @@
=item Architect
+X<architect role>
+
The architect has primary responsibility for setting the overall
direction of the project, facilitating team communication, and
explaining and evaluating architectural issues. The architect makes
@@ -105,6 +107,8 @@
=item Release Managers
+X<release manager role>
+
Release managers have responsibility for executing a product release
according to the release schedule. Parrot has multiple release managers
who rotate the responsibility for each monthly release. The release
@@ -113,15 +117,18 @@
=item Metacommitter
+X<metacommitter role>
+
Metacommitters manage commit access to the Parrot repository. Once a
contributor is selected for commit access, a metacommitter performs the
necessary magic to give the new committer access to the SVN repository
and the bugtracker. The architect is a metacommitter, but other team
-members may also hold this role.
+members also hold this role.
=item Committer
-X<Committers>
+X<committer role>
+
Contributors who submit numerous, high-quality patches may be considered
to become a committer. Committers have commit access to the full Parrot
repository, but often specialize on particular parts of the project.
@@ -131,28 +138,40 @@
=item Core Developer
+X<core developer role>
+
Core developers develop and maintain core subsystems such as the I/O
subsystem, the exceptions system, or the concurrency scheduler.
=item Compiler Developer
+X<compiler developer role>
+
Compiler developers develop and maintain one or more Parrot front-end
compilers such as IMCC, PIRC, PGE and TGE.
=item High-Level Language Developer
+X<HLL developer role>
+
Developers who work on any of the high-level languages that target
-Parrot such as TCL, Lua or Perl 6, are high-level language developers.
-Some of these language projects are located in the Parrot repository,
-although most are maintained in separate locations.
+ParrotE<mdash>such as Lua, Perl, PHP, Python, Ruby, or TclE<mdash>are
+high-level language developers. Some example languages are located in
+the Parrot repository, but most are hosted independently. A full list of
+languages is maintained at
+U<https://trac.parrot.org/parrot/wiki/Languages>.
=item Build Manager
+X<build manager role>
+
Build managers maintain and extend configuration and build subsystems.
They review smoke reports and attempt to extend platform support.
=item Tester
+X<tester role>
+
Developing, maintaining, and extending test suite coverage and testing
tool are the key tasks for the testers. Testers are also
responsible for testing goals, including complete coverage of core
@@ -160,6 +179,8 @@
=item Patch Monsters
+X<patch monster role>
+
Hackers and developers submit patches to Parrot every day, and it takes
a keen eye and a steady hand to review and apply them all. Patch
monsters, as they are affectionately known, are in charge of checking
@@ -168,6 +189,8 @@
=item Cage Cleaners
+X<cage cleaner role>
+
The cage cleaners ensure that coding standards are followed, that
documentation is complete and accurate, that all tests are functioning
properly, and that there are plenty of coding examples for new users to
@@ -179,6 +202,8 @@
=item General Contributor
+X<contributor role>
+
Contributors are volunteers who write code or documentation patches,
take part in email or online conversations, or contribute to the project
in other important ways. All volunteer contributions are appreciated.
@@ -187,6 +212,8 @@
=head2 Licensing
+X<license>
+
The intellectual property for Parrot is held by the Parrot Foundation, a
non-profit organization formed to support the Parrot development
community. It is licensed under the Artistic License 2.0, allowing free
Modified: branches/headercleanup/docs/book/ch02_getting_started.pod
==============================================================================
--- branches/headercleanup/docs/book/ch02_getting_started.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch02_getting_started.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -8,9 +8,9 @@
The simplest way to install Parrot is with pre-compiled binaries for
your operating system or distribution. Packages are available for many
-packaging systems, including Debian, Fedora, Mandriva, FreeBSD, Cygwin,
-and MacPorts. A current list of available packages is maintained at
-U<http://www.parrot.org/download>. A binary installer for Windows is
+packaging systems, including Debian, Ubuntu, Fedora, Mandriva, FreeBSD,
+Cygwin, and MacPorts. A current list of available packages is maintained
+at U<http://www.parrot.org/download>. A binary installer for Windows is
also available at U<http://parrotwin32.sourceforge.net/>.
If packages aren't available on your system, you can download the latest
@@ -126,41 +126,41 @@
Parrot virtual machine. It serves as a plain-English representation of
Parrot's bytecode format.
-=item Appendix A, I<Glossary>
+=item Chapter 10, I<Instruction Reference>
-A quick reference to common Parrot terms.
+The standard instruction set for the Parrot virtual machine.
-=item Appendix B, I<Command-Line Options>
+=item Chapter 11, I<Directive Reference>
-Further details on running Parrot.
+Out-of-band directives used within PIR/PASM code.
-=item Appendix C, I<Instruction Reference>
+=item Chapter 13, I<Operator Reference>
-The standard instruction set for the Parrot virtual machine.
+Operator syntax in PIR code.
-=item Appendix D, I<Directive Reference>
+=item Appendix A, I<Glossary>
-Out-of-band directives used within PIR/PASM code.
+A quick reference to common Parrot terms.
-=item Appendix E, I<Operator Reference>
+=item Appendix B, I<Command-Line Options>
-Operator syntax in PIR code.
+Further details on running Parrot.
-=item Appendix F, I<Build Options>
+=item Appendix C, I<Build Options>
Dependencies and additional options for building Parrot from source.
-=item Appendix G, I<Source Code>
+=item Appendix D, I<Source Code>
Navigating the Parrot source tree.
-=item Appendix H, I<Patch Submission>
+=item Appendix E, I<Patch Submission>
How to submit a patch to Parrot.
=back
-
+
=cut
# Local variables:
Modified: branches/headercleanup/docs/book/ch03_pir.pod
==============================================================================
--- branches/headercleanup/docs/book/ch03_pir.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch03_pir.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -939,11 +939,11 @@
=head3 Named Parameters
Parameters that are passed in a strict order like we've seen above are
-called '''positional arguments'''. Positional arguments are
+called I<positional arguments>. Positional arguments are
differentiated from one another by their position in the function call.
Putting positional arguments in a different order will produce different
effects, or may cause errors. Parrot supports a second type of parameter,
-a '''named parameter'''. Instead of passing parameters by their position
+a I<named parameter>. Instead of passing parameters by their position
in the string, parameters are passed by name and can be in any order.
Here's an example:
@@ -1004,7 +1004,7 @@
.param string name :optional
.param int has_name :opt_flag
if has_name goto we_have_a_name
- name = "Default value"
+ name = "Default value"
we_have_a_name:
Optional parameters can be positional or named parameters. When using them
@@ -1628,7 +1628,7 @@
.local string methname = "Foo"
object.methname() # Same as object."Foo"()
- object."Foo"() # Same
+ object."Foo"() # Same
The invocant can be a variable or register, and the method name can be
a literal string, string variable, or method object PMC.
@@ -2041,13 +2041,13 @@
=head2 PMCs as Classes
-PMCs aren't exactly "classes" in the way that this term is normally used.
-They are polymorphic data items that can be one of a large variety of
-predefined types. As we have seen briefly, and as we will see in more depth
-later, PMCs have a standard interface called the VTABLE interface. VTABLEs
-are a standard list of functions that all PMCs implement N<or, PMCs can
-choose not to implement each interface explicitly and instead let Parrot
-call the default implementations>.
+PMCs aren't exactly "classes" in the way that this term is normally used in
+object-oriented programming languages. They are polymorphic data items that
+can be one of a large variety of predefined types. As we have seen briefly,
+and as we will see in more depth later, PMCs have a standard interface called
+the VTABLE interface. VTABLEs are a standard list of functions that all PMCs
+implement N<or, PMCs can choose not to implement each interface explicitly and
+instead let Parrot call the default implementations>.
VTABLEs are very strict: There are a fixed number with fixed names and
fixed argument lists. You can't just create any random VTABLE interface that
Modified: branches/headercleanup/docs/book/ch05_pge.pod
==============================================================================
--- branches/headercleanup/docs/book/ch05_pge.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch05_pge.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -15,7 +15,11 @@
=head2 Grammars
-A grammar is a collection of rules, in much the same way that a class is a collection of methods.N<In fact, a grammar is just a special kind of class and a rule is just a special kind of method.> Each rule defines a pattern for matching one piece of text. The basic matching syntax for rules is likely to be somewhat familiar to anyone who has worked with regular expressions.
+A grammar is a collection of rules, in much the same way that a class is a
+collection of methods.N<In fact, a grammar is just a special kind of class
+and a rule is just a special kind of method.> Each rule defines a pattern for
+matching one piece of text. The basic matching syntax for rules is likely to
+be somewhat familiar to anyone who has worked with regular expressions.
rule id { \d+ }
@@ -28,33 +32,46 @@
grammar Contacts;
rule name { 'John' | 'Bob ' | 'Fred' }
-
+
rule id { \d+ }
rule record { <id> <name> }
...
-
=head3 Rules and Tokens
-There are two different kinds of rules, each declared with a different keyword: C<rule> or C<token>. A C<rule> does smart whitespace matching between the various pieces of the pattern. So, the C<record> rule above would match "6355 John" or "6355 John" but not "6355John".
+There are two different kinds of rules, each declared with a different keyword:
+C<rule> or C<token>. A C<rule> does smart whitespace matching between the
+various pieces of the pattern. So, the C<record> rule above would match
+"6355 John" or "6355 John" but not "6355John".
-A C<token> only matches whitespace if you specifically request it. To get the same effect with a token, you'd have to add a C<\s> pattern to the rule:
+A C<token> only matches whitespace if you specifically request it. To get the
+same effect with a token, you'd have to add a C<\s> pattern to the rule:
token record { <id> \s+ <name> }
=head3 The Start Rule
-A recursive descent parser is a top-down parser. This means it starts at the highest-level rule and works its way down through individual rules to match an entire string or file. In PGE, this top-level rule is called C<TOP> by convention.N<The top-level rule can be called anything, but some of the compiler tools expect it to be called C<TOP>.>
+A recursive descent parser is a top-down parser. This means it starts at the
+highest-level rule and works its way down through individual rules to match
+an entire string or file. In PGE, this top-level rule is called C<TOP> by
+convention.N<In "real" Perl 6, the top-level rule can be called anything.
+However, some of the PCT compiler tools expect it to be called C<TOP>.
+Compilers written with PCT should just use the name C<TOP> for all top-level
+tokens.>
rule TOP { <record> }
-This rule matches a single record in a string or file. Once the parser has matched the entire string or file passed to the start rule, the parse is considered successful and a raw parse tree is returned.
+This rule matches a single record in a string or file. Once the parser has
+matched the entire string or file passed to the start rule, the parse is
+considered successful and a raw parse tree is returned.
=head3 Testing a Grammar
-You might want to try out the examples in this chapter as you read along. To compile a simple example, save it to a file called F<Contacts.pg>:
+You might want to try out the examples in this chapter as you read along.
+To compile the following simple example, save it to a file called
+F<Contacts.pg>:
grammar Contacts is PGE::Grammar;
rule TOP { <record> }
@@ -66,11 +83,14 @@
$ parrot Perl6Grammar.pbc --output=Contacts.pir Contacts.pg
-The path to F<parrot> and to the F<Perl6Grammar.pbc> file will vary on different systems. If you compiled Parrot from source, it will be:
+The path to F<parrot> and to the F<Perl6Grammar.pbc> file will vary on
+different systems. If you compiled Parrot from source, it will be:
- $ ./parrot runtime/parrot/library/PGE/Perl6Grammar.pbc --output=Contacts.pir Contacts.pg
+ $ ./parrot runtime/parrot/library/PGE/Perl6Grammar.pbc \
+ --output=Contacts.pir Contacts.pg
-Next, create a small PIR script to run your grammar. You can save it as F<grammar_test.pir>.
+Next, create a small PIR script to run your grammar. You can save it as
+F<grammar_test.pir>.
.sub main :main
load_bytecode 'PGE.pbc' # load some required modules
@@ -89,11 +109,12 @@
_dumper(match, "match")
.end
-When you run the test script:
+Now, you can run the test script with this command:
$ parrot grammar_test.pir
-It will print out a text representation of the raw parse tree stored in the C<match> variable:
+It will print out a text representation of the raw parse tree stored in the
+C<match> variable:
"match" => PMC 'Contacts' => "3 John" @ 0 {
<record> => PMC 'Contacts' => "3 John" @ 0 {
@@ -102,7 +123,11 @@
}
}
-Each rule in the grammar corresponds to a node in the tree. This output shows that the top-level match variable contains one child named "record", that "record" contains two children named "id" and "name", and that "id" contains the number 3, and "name" contains the string "John". Exactly what we would expect from our simple grammar.
+Each rule in the grammar corresponds to a node in the tree. This output shows
+that the top-level match variable contains one child named "record", that
+"record" contains two children named "id" and "name", and that "id" contains
+the number 3, and "name" contains the string "John". Exactly what we would
+expect from our simple grammar.
=head2 Rule Syntax
@@ -116,25 +141,24 @@
=head3 Metacharacters
-The C<.> matches any single character, even a newline character.
-The C<^> and C<$> metacharacters are zero-width
-matches on the beginning and end of a string. They each have doubled
-alternates C<^^> and C<$$> that match at the beginning and end of
-every line within a string.
+The C<.> matches any single character, even a newline character. The C<^> and
+C<$> metacharacters are zero-width matches on the beginning and end of a
+string. They each have doubled alternates C<^^> and C<$$> that match at the
+beginning and end of every line within a string.
The C<|>, C<&>, C<\>, C<#>, and C<:=> metacharacters are all syntax
structure elements. The C<|> is an alternation between two options. The
C<&> matches two patterns simultaneously (the patterns must be the same
length). The C<\> turns literal characters into metacharacters (the
-escape sequences). The
-C<#> marks a comment to the end of the line. You can start a comment at
-any point on any line in a rule. The C<:=> binds a hypothetical variable to
-the result of a subrule or grouped pattern. Hypotheticals are covered
-in L<Hypothetical Variables> later in this chapter.
+escape sequences). The C<#> marks a comment to the end of the line. You can
+start a comment at any point on any line in a rule. The C<:=> binds a
+hypothetical variable to the result of a subrule or grouped pattern.
+Hypotheticals are covered in L<Hypothetical Variables> later in this chapter.
The metacharacters C<()>, C<[]>, C<{}> and C<E<lt>E<gt>> are bracketing
pairs. The pairs always have to be balanced within the rule, unless they
-are literal characters (escaped with a C<\>). The C<()> and C<[]> pairs group patterns to match as a single atom. They're often used to
+are literal characters (escaped with a C<\>). The C<()> and C<[]> pairs
+group patterns to match as a single atom. They're often used to
capture a result, mark the boundaries of an alternation, or mark a group
of patterns with a quantifier. Parentheses C<()> are
capturing and square brackets C<[]> are non-capturing. The C<{}>
@@ -150,64 +174,64 @@
Z<CHP-7-TABLE-2>
-=headrow
+=headrow
-=row
+=row
=cell Symbol
=cell Meaning
-=bodyrows
+=bodyrows
-=row
+=row
=cell C<.>
=cell Match any single character, including a newline.
X<. (dot);. match single character (rules)>
-=row
+=row
=cell C<^>
=cell Match the beginning of a string.
X<^ (caret);^ beginning of string (rules)>
-=row
+=row
=cell C<$>
=cell Match the end of a string.
X<$ (dollar sign);$ end of string (rules)>
-=row
+=row
=cell C<^^>
=cell Match the beginning of a line.
X<^ (caret);^^ beginning of line (rules)>
-=row
+=row
=cell C<$$>
=cell Match the end of a line.
X<$ (dollar sign);$$ end of line (rules)>
-=row
+=row
=cell C<|>
=cell Match alternate patterns (OR).
-=row
+=row
=cell C<&>
=cell Match multiple patterns (AND).
-=row
+=row
=cell C<\>
@@ -216,38 +240,38 @@
X<\ (backslash);\ escape sequences (rules)>
X<\ (backslash);\ to escape metacharacters (rules)>
-=row
+=row
=cell C<#>
=cell Mark a comment (to the end of the line).
-=row
+=row
=cell C<:=>
=cell Bind the result of a match to a hypothetical variable.
X<: (colon);:= (binding);in rules>
-=row
+=row
=cell C<(...)>
=cell Group patterns and capture the result.
-=row
+=row
=cell C<[...]>
=cell Group patterns without capturing.
-=row
+=row
=cell C<{...}>
=cell Execute a closure (Perl 6 code) within a rule.
-=row
+=row
=cell C<E<lt>...E<gt>>
@@ -270,204 +294,204 @@
Some represent limited character classes, like C<\d> for digits or C<\w>
for word characters. Some represent zero-width positions in a match,
like C<\b> for a word boundary. With all the escape sequences that use
-brackets, C<()>, C<{}>, and C<E<lt>E<gt>> work in place of C<[]>.
+brackets, C<()>, C<{}>, and C<E<lt>E<gt>> work in place of C<[]>.
X<variable interpolation in rules>
X<rules;variable interpolation>
Note that since an ordinary variable now interpolates as a literal
string by default, the C<\Q> escape sequence is rarely needed.
-A<CHP-7-TABLE-3>Table 7-3 shows the escape sequences for rules.
+A<CHP-7-TABLE-3>Table 7-3 shows the escape sequences for rules.
=begin table picture Escape sequences
Z<CHP-7-TABLE-3>
-=headrow
+=headrow
-=row
+=row
=cell Escape
=cell Meaning
-=bodyrows
+=bodyrows
-=row
+=row
=cell C<\0[...]>
=cell Match a character given in octal (brackets optional).
-=row
+=row
=cell C<\b>
=cell Match a word boundary.
-=row
+=row
=cell C<\B>
=cell Match when not on a word boundary.
-=row
+=row
=cell C<\c[...]>
=cell Match a named character or control character.
-=row
+=row
=cell C<\C[...]>
=cell Match any character except the bracketed named or control character.
-=row
+=row
=cell C<\d>
=cell Match a digit.
-=row
+=row
=cell C<\D>
=cell Match a non-digit.
-=row
+=row
=cell C<\e>
=cell Match an escape character.
-=row
+=row
=cell C<\E>
=cell Match anything but an escape character.
-=row
+=row
=cell C<\f>
=cell Match the form feed character.
-=row
+=row
=cell C<\F>
=cell Match anything but a form feed.
-=row
+=row
=cell C<\n>
=cell Match a (logical) newline.
-=row
+=row
=cell C<\N>
=cell Match anything but a (logical) newline.
-=row
+=row
=cell C<\h>
=cell Match horizontal whitespace.
-=row
+=row
=cell C<\H>
=cell Match anything but horizontal whitespace.
-=row
+=row
=cell C<\L[...]>
=cell Everything within the brackets is lowercase.
-=row
+=row
=cell C<\Q[...]>
=cell All metacharacters within the brackets match as literal characters.
-=row
+=row
=cell C<\r>
=cell Match a return.
-=row
+=row
=cell C<\R>
=cell Match anything but a return.
-=row
+=row
=cell C<\s>
=cell Match any whitespace character.
-=row
+=row
=cell C<\S>
=cell Match anything but whitespace.
-=row
+=row
=cell C<\t>
=cell Match a tab.
-=row
+=row
=cell C<\T>
=cell Match anything but a tab.
-=row
+=row
=cell C<\U[...]>
=cell Everything within the brackets is uppercase.
-=row
+=row
=cell C<\v>
=cell Match vertical whitespace.
-=row
+=row
=cell C<\V>
=cell Match anything but vertical whitespace.
-=row
+=row
=cell C<\w>
=cell Match a word character (Unicode alphanumeric plus "_").
-=row
+=row
=cell C<\W>
=cell Match anything but a word character.
-=row
+=row
=cell C<\x[...]>
=cell Match a character given in hexadecimal (brackets optional).
-=row
+=row
=cell C<\X[...]>
@@ -476,7 +500,6 @@
=end table
-
=head3 Quantifiers
Z<CHP-7-SECT-2.3>
@@ -498,16 +521,16 @@
C<?>, that matches the shortest possible sequence first.
-A<CHP-7-TABLE-4>Table 7-4 shows the built-in
+A<CHP-7-TABLE-4>Table 7-4 shows the built-in
X<quantifiers, rules> X<rules;quantifiers> quantifiers.
=begin table picture Quantifiers
Z<CHP-7-TABLE-4>
-=headrow
+=headrow
-=row
+=row
=cell Maximal
@@ -515,9 +538,9 @@
=cell Meaning
-=bodyrows
+=bodyrows
-=row
+=row
=cell C<*>
@@ -525,7 +548,7 @@
=cell Match 0 or more times.
-=row
+=row
=cell C<+>
@@ -533,7 +556,7 @@
=cell Match 1 or more times.
-=row
+=row
=cell C<?>
@@ -541,7 +564,7 @@
=cell Match 0 or 1 times.
-=row
+=row
=cell C<E<lt>>R<n>C<E<gt>>
@@ -549,7 +572,7 @@
=cell Match exactly R<n> times.
-=row
+=row
=cell C<E<lt>>R<n>C<..>R<m>C<E<gt>>
@@ -557,7 +580,7 @@
=cell Match at least R<n> and no more than R<m> times.
-=row
+=row
=cell C<E<lt>>R<n>C<...E<gt>>
@@ -576,7 +599,7 @@
X<rules;assertions>
In general, an assertion simply states that some condition or state is
true and the match fails when that assertion is false. Many different
-constructs with many different purposes use assertion syntax.
+constructs with many different purposes use assertion syntax.
X<variable interpolation in rules>
X<rules;variable interpolation>
@@ -620,97 +643,97 @@
Z<CHP-7-TABLE-5>
-=headrow
+=headrow
-=row
+=row
=cell Syntax
=cell Meaning
-=bodyrows
+=bodyrows
-=row
+=row
=cell C<E<lt>...E<gt>>
=cell Generic assertion delimiter.
-=row
+=row
=cell C<E<lt>!...E<gt>>
=cell Negate any assertion.
-=row
+=row
=cell C<E<lt>>R<name>C<E<gt>>
=cell Match a named rule or character class.
-=row
+=row
=cell C<E<lt>[...]E<gt>>
=cell Match an enumerated character class.
-=row
+=row
=cell C<E<lt>-...E<gt>>
=cell Complement a character class (named or enumerated).
-=row
+=row
=cell C<E<lt>"..."E<gt>>
=cell Match a literal string (interpolated at match time).
-=row
+=row
=cell C<E<lt>'...'E<gt>>
=cell Match a literal string (not interpolated).
-=row
+=row
=cell C<E<lt>(...)E<gt>>
=cell Boolean assertion. Execute a closure and match if it returns a true
result.
-=row
+=row
=cell C<E<lt>$scalarE<gt>>
=cell Match an anonymous rule.
-=row
+=row
=cell C<E<lt>@arrayE<gt>>
=cell Match a series of anonymous rules as alternates.
-=row
+=row
=cell C<E<lt>%hashE<gt>>
=cell Match a key from the hash, then its value (which is an anonymous
rule).
-=row
+=row
=cell C<E<lt>E<amp>sub()E<gt>>
=cell Match an anonymous rule returned by a sub.
-=row
+=row
=cell C<E<lt>{>R<code>C<}E<gt>>
=cell Match an anonymous rule returned by a closure.
-=row
+=row
=cell C<E<lt>.E<gt>>
@@ -755,7 +778,7 @@
The C<:R<N>x> modifier matches the rule a counted number of times. If
the modifier expects more matches than the string has, the match fails.
It has an alternate form C<:x(R<N>)> that can take a variable in place
-of the number.
+of the number.
The C<:once> modifier on a rule only allows it to match once. The rule
will not match again until the you call the C<.reset> method on the rule
@@ -790,9 +813,9 @@
Z<CHP-7-TABLE-6>
-=headrow
+=headrow
-=row
+=row
=cell Short
@@ -800,9 +823,9 @@
=cell Meaning
-=bodyrows
+=bodyrows
-=row
+=row
=cell C<:i>
@@ -810,15 +833,15 @@
=cell Case-insensitive match.
-=row
+=row
=cell C<:I>
-=cell
+=cell
=cell Case-sensitive match (on by default).
-=row
+=row
=cell C<:c>
@@ -826,7 +849,7 @@
=cell Continue where the previous match on the string left off.
-=row
+=row
=cell C<:w>
@@ -835,39 +858,39 @@
=cell Literal whitespace in the pattern matches as C<\s+>
or C<\s*>.
-=row
+=row
=cell C<:W>
-=cell
+=cell
=cell Turn off intelligent whitespace matching (return to default).
-=row
+=row
-=cell
+=cell
=cell :R<N>C<x>/C<:x(>R<N>C<)>
=cell Match the pattern R<N> times.
-=row
+=row
-=cell
+=cell
=cell C<:>R<N>C<th>/C<:nth(>R<N>C<)>
=cell Match the R<N>th occurrence of a pattern.
-=row
+=row
-=cell
+=cell
=cell C<:once>
=cell Only match the pattern once.
-=row
+=row
=cell C<:g>
@@ -876,7 +899,7 @@
=cell Match the pattern as many times as possible, but only possibilities
that don't overlap.
-=row
+=row
=cell C<:e>
@@ -885,41 +908,41 @@
=cell Match every possible occurrence of a pattern, even overlapping
possibilities.
-=row
+=row
-=cell
+=cell
=cell C<:u0>
=cell . is a byte.
-=row
+=row
-=cell
+=cell
=cell C<:u1>
=cell . is a Unicode codepoint.
-=row
+=row
-=cell
+=cell
=cell C<:u2>
=cell . is a Unicode grapheme.
-=row
+=row
-=cell
+=cell
=cell C<:u3>
=cell . is language dependent.
-=row
+=row
-=cell
+=cell
=cell C<:p5>
Modified: branches/headercleanup/docs/book/ch06_nqp.pod
==============================================================================
--- branches/headercleanup/docs/book/ch06_nqp.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch06_nqp.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -9,22 +9,26 @@
Not Quite Perl (NQP).
NQP is a small language that's implemented as a subset of Perl 6 syntax and
-semantics. It's represents almost the smallest subset of the Perl 6 language
-necessary to implement the logic of a parser, although some developers have
-complained enough to get a few extra syntactic features added in above the
-bare minimum. NQP also happens to be a Perl 6 subset that's not entirely
-dissimilar from Perl 5, so Perl 5 programmers should not be too lost when
-writing NQP.
+semantics. It was originally developed as a bootstrapping tool to help allow
+the Rakudo Perl 6 compiler to be written in Perl 6 itself. It has since been
+used to implement many other compilers on Parrot as well, and has become a
+permanent member of the Parrot Compiler Toolkit (PCT).
+
+NQP represents almost the smallest subset of the Perl 6 language necessary
+to implement the logic of a parser, although some developers have complained
+enough to get a few extra syntactic features added in above the bare minimum.
+NQP also happens to be a Perl 6 subset that's not entirely dissimilar from
+Perl 5, so Perl 5 programmers should not be too lost when using it.
=head2 NQP Basics
-Like Perl, NQP uses sigils to differentiate different types of variables.
-The C<$> sigil is used for scalars, C<@> is used for arrays, and C<%> is
-used for hashes N<Perl 6 aficionados will know that this isn't entirely
-true, but an in-depth look at Perl 6's context awareness is another topic
-for another book>. A "scalar" is really any single value, and can
-interchangeably be given a string value, or an integer value, or an object.
-In NQP we can write things like this:
+Like all flavors and versions of Perl, NQP uses special prefix symbols called
+I<sigils> to differentiate different types of variables. The C<$> sigil is used
+for scalars, C<@> is used for arrays, and C<%> is used for hashes N<Perl 6
+aficionados will know that this isn't entirely true, but an in-depth look at
+Perl 6's context awareness is another topic for another book>. A "scalar" is
+really any single value, and can interchangeably be given a string value, or an
+integer value, or an object reference. In NQP we can write things like this:
$scalar := "This is a string"
$x := 123
@@ -41,9 +45,9 @@
With hashes and arrays, it might be tempting to do a list assignment like
we've all grown familiar with in Perl 5 and other dynamic languages:
- @small_integers := (1, 2, 3, 4); # WRONG!
- %leading_ladies := ("Leia" => "Starwars",
- "Trillian" => "Hitchhikers Guide"); # WRONG!
+ @small_integers := (1, 2, 3, 4); # WRONG!
+ %leading_ladies := ("Trillian" => "Hitchhikers Guide",
+ "Leia" => "Starwars"); # WRONG!
Here's another little gotcha, NQP doesn't have list or hash context! If
it's necessary to initialize a whole list at once, you can write:
@@ -56,8 +60,22 @@
$array_but_a_scalar := (1, 2, 3, 4)
-Remember how we said NQP was a bare-bones subset of Perl 6? If NQP had too
-many features, people would use it instead of Perl 6!
+Or, you could write a new function in PIR to create a new array from a
+variadic argument list:
+
+ @my_array := create_new_array(1, 2, 3, 4)
+
+Which calls the PIR function:
+
+ .namespace []
+ .sub 'create_new_array'
+ .param pmc elems :slurpy
+ .return(elems)
+ .end
+
+Remember how we said NQP was a bare-bones subset of Perl 6? It really doesn't
+have a lot of features that programmers might expect. In this chapter we will
+talk about some of the features and capabilities that it does have.
=head3 Calling Actions From Rules
@@ -83,18 +101,19 @@
And here is the rule that tells us the result:
method cavepeople($/, $key) {
- if($key eq 'Caveman') {
+ if $key eq 'Caveman' {
say "We've found a caveman!";
- } elsif($key eq 'Cavewoman') {
+ } elsif $key eq 'Cavewoman' {
say "We've found a cavewoman!";
- } elsif($key eq 'Dinosaur') {
+ } elsif $key eq 'Dinosaur' {
say "A dinosaur isn't a caveperson at all!";
}
}
The key is just a string that contains whatever text is on the line after
the C<#=> symbol. If we don't have a C<#=> we don't use a C<$key> in our
-method.
+method. If you attempt to use one without the other, the NQP compiler will
+die with error messages about mismatched argument/parameter numbers.
=head3 The Match Object C<$/>
@@ -103,7 +122,7 @@
since it's a special variable it also gets a special shortcut syntax
that can be used to save a few keystrokes:
- $/('Match_item') is the same as $<Match_item>
+ $/{'Match_item'} is the same as $<Match_item>
$/[0] is the same as $[0]
In the match object, each item in the hash is named after one of the items
Modified: branches/headercleanup/docs/book/ch08_dynops.pod
==============================================================================
--- branches/headercleanup/docs/book/ch08_dynops.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch08_dynops.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -35,7 +35,7 @@
illusion, however. Parrot opcodes are not polymorphic, although certain
features enable it to appear that way. Different argument list formats
are detected during parsing and translated into separate, and unique,
-opcode names.
+opcode names.
=head3 Opcode Multiple Dispatch
Modified: branches/headercleanup/docs/book/ch09_pasm.pod
==============================================================================
--- branches/headercleanup/docs/book/ch09_pasm.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch09_pasm.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -2,47 +2,73 @@
=head1 Parrot Assembly Language
-Z<CHP-5>
+Z<CHP-9>
X<Parrot Assembly Language;;(see PASM)>
X<PASM (Parrot assembly language)>
-Parrot assembly (PASM) is an assembly language written for Parrot's
-virtual CPU. Basic register operations or branches in PASM generally
-translate into a single CPU instruction. N<This means the JIT run time
-has a performance of up to one PASM instruction per processor cycle.>
-On the other hand, because it's designed to implement dynamic
-high-level languages, it has support for many advanced features such as
-lexical and global variables, objects, garbage collection,
-continuations, coroutines, and much more. PASM is very similar in
-many respects to PIR which we've already discussed, and in almost all
-cases PIR should be used instead of using PASM directly. However, all
-PASM syntax is also valid PIR syntax, so it's helpful to have an
-understanding of the underlying operations in PASM.
-
-X<.pasm files> A file with a F<.pasm> extension is treated as pure PASM
-code by Parrot, as is any file run with the C<-a> command-line option.
-This mode is mainly used for running pure PASM tests from the test suite,
-and is not likely to be useful for most developers.
-
-Some people may ask why we have PASM at all, especially with PIR which
-has much nicer syntax. The answer is that PASM, like all assembly languages
-has a one-to-one correspondence with the underlying Parrot Bytecode (PBC).
-This makes it easy to translate from PBC to human-readable PASM code in
-a disassembler program. PIR code is basically just a thin wrapper over
-PASM, and you can write PASM code seamlessly in PIR files. It's always
-around, and it's good to be familiar with it.
+We've seen some of the common ways for programming Parrot in earlier
+chapters: PIR is the intermediate language that's used most often for
+implementing routines in Parrot, NQP is used for writing grammar actions
+for high-level language compilers, PGE is used for specifying grammar
+rules, and various high-level languages that target Parrot are used for
+most other programming tasks. These options, though many and versatile,
+are not the only ways to interface with Parrot.
+
+In regular assemblers, assembly language mnemonics share a one-to-one
+correspondence with the underlying machine code words that they
+represent. A simple assembler (and, for that matter, a simple disassembler)
+could be implemented as a mere lookup table. PIR does not have this kind
+of direct correspondance to PBC. A number of PIR features, especially the
+various directives, typically translate into a number of individual
+operations. Register names, such as C<$P7> don't indicate the actual
+storage location of the register in PIR either. The register allocator
+will intelligently move and rearrange registers to conserve memory, so
+the numbers you use to specify registers in PIR will be mapped to
+different numbers when compiled into PBC.
+
+Because PIR and PBC can't be directly translated to one another, and
+because it can be difficult to disassemble low-level PBC back into the
+higher-level composite statements of PIR, especially after optimization,
+another tool is needed. That tool is PASM.
+
+PASM, the Parrot Assembly Language, is the lowest-level interface to
+Parrot. PASM instruction mnemonics do share a one-to-one correspondence
+to the underlying PBC opcodes, and for this reason is used by the Parrot
+disassembler instead of PIR. PASM is missing some of the features of
+PIR: Most directives, symbolic operators, C<if> and C<unless> compound
+statements, automatic register allocation, and a few other bits of
+syntactic sugar are missing from PASM. Because of these omissions, it is
+strongly recommended that most developers do not use PASM to write any
+large amount of code. Use PIR if you need to, or a higher-level language
+if you can.
+
+=head2 PASM Files
+
+X<.pasm files>
+The Parrot compilers, IMCC and PIRC, differentiate between PIR and PASM
+code files based on the file extension. A file with a F<.pasm> extension
+is treated as pure PASM code by Parrot, as is any file run with the C<-a>
+command-line option.
+
+Early in the Parrot project's history, PIR was treated as a pure superset
+of PASM. All PASM was valid PIR, but PIR added a few extra features that
+the programmers found to be nice. However, this situation has changed and
+PIR is no longer a strict superset of PASM. For this reason, PASM and
+PIR code need to be kept in files with separate extensions. As we mentioned
+before, C<.pasm> files are always treated as containing only PASM, while
+C<.pir> files are used for PIR code, by convention.
=head2 Basics
-Z<CHP-5-SECT-2>
+Z<CHP-9-SECT-2>
X<PASM (Parrot assembly language);overview>
PASM has a simple syntax that will be familiar to people who have experience
programming other assembly languages. Each statement stands on its own line
-and there is no end-of-line delimiter like is used in many other languages.
-Statements begin with a Parrot instruction, commonly referred to
-as an "opcode"N<More accurately, it should probably be referred to as a
-"mnemonic">. The arguments follow, separated by commas:
+and there is no end-of-line delimiter. Statements begin with a Parrot
+instruction, commonly referred to as an "opcode"N<More accurately, it should
+probably be referred to as a "mnemonic">. The arguments follow, separated by
+commas:
[label] opcode dest, source, source ...
@@ -68,9 +94,10 @@
Label names consist of letters, numbers, and underscores, exactly the
same syntax as is used for labels in PIR. Simple labels are often all
capital letters to make them stand out from the rest of the source code
-more clearly. A label definition is simply the name of the label
-followed by a colon. It can be on its own line N<In fact, we recommend
-that it be on its own line, for readability.>:
+more clearly. This is just a common convention and is not a rule. A label
+can be in front of a line of code, or it can be on it's own line. Keeping
+labels separate is usually recommended for readability, but again this is
+just a suggestion and not a rule.
=begin PASM
@@ -79,8 +106,6 @@
=end PASM
-or before a statement on the same line:
-
=begin PASM
LABEL: print "Norwegian Blue\n"
@@ -101,6 +126,8 @@
=cut
+ end
+
=end PASM
Besides POD, there are also ordinary 1-line comments using the # sign,
@@ -108,19 +135,24 @@
=begin PASM
- LABEL: # This is a comment for a label
- print "Norwegian Blue\n" # Print a color
+ LABEL: # This is a comment
+ print "Norwegian Blue\n" # Print a color name
=end PASM
=head3 Constants
-Z<CHP-5-SECT-2.1>
+Z<CHP-9-SECT-2.1>
X<PASM (Parrot assembly language);constants>
-Integer constants are signed integers.N<The size of integers is
-defined when Parrot is configured. It's typically 32 bits on 32-bit
-machines (a range of -2G<31> to +2G<31>-1) and twice that size on
+We've already seen constants in PIR, and for the most part the syntax
+is the same in PASM. We will give a brief refresher here, but see the
+chapter on PIR for a more in-depth discussion of constants and datatypes.
+
+Integer constants in Parrot are signed integers.N<The sizes of integers
+and all other data values like floats are defined when Parrot is
+configured and built. Integers are typically 32 bits wide on 32-bit
+computers (a range of -2G<31> to +2G<31>-1) and twice that size on
64-bit processors.> Decimal integer constants can have a positive (C<+>) or
negative (C<->) sign in front. Binary integers are preceded by C<0b>
or C<0B>, and hexadecimal integers are preceded by C<0x> or C<0X>:
@@ -163,7 +195,7 @@
=head3 Working with Registers
-Z<CHP-5-SECT-2.2>
+Z<CHP-9-SECT-2.2>
X<PASM (Parrot assembly language);registers>
X<registers;Parrot;;(see PASM, registers)>
@@ -173,38 +205,51 @@
the register set type and the number of the register. Register numbers
are non-negative (zero and positive numbers), and do not have a
pre-defined upper limit N<At least not a restrictive limit. Parrot
-registers are stored internally as an array, and the register number is
-an index to that array. If you call C<N2000> you are implicitly creating
-a register array with 2000 entries. This can carry a performance
-penalty>. For example:
+registers are stored internally as an array. More registers means a larger
+allocated array, which can bring penalties on some systems>. For example:
I0 integer register #0
N11 number or floating point register #11
S2 string register #2
P33 PMC register #33
-Integer and number registers hold values, while string and PMC
-registers contain pointers to allocated memory for a string header or
-a Parrot object.
-
-In Chapter 3 we mentioned that a register name was a dollar-sign followed
-by a type identifier and then a number. Now we're naming registers with
-only a letter and number, not a dollar sign. Why the difference? The
-dollar sign indicates to Parrot that the register names are not literal,
-and that the register allocator should assign the identifier to a
-physical memory location. Without the dollar sign, the register number
-is an actual offset into the register array. C<N2000> is going to point
-to the two thousandth register, while C<$N2000> can point to any
-memory location that the register allocator determines to be free. Since
-PIR attempts to protect the programmer from some of the darkest details,
-Parrot requires that registers in PIR use the C<$> form. In PASM you can
-use either form, but we still recommend using the C<$> form so you don't
-have to worry about register allocations (and associated performance
-penalties) yourself.
+We see the immediate difference here that PASM registers do not have the
+C<$> dollar sign in front of them like PIR registers do. The syntactical
+difference indicates that there is an underlying semantic difference:
+In PIR, register numbers are just suggestions and registers are automatically
+allocated; In PASM, register numbers are literal offsets into the register
+array, and registers are not automatically managed. Let's take a look at a
+simple PIR function:
+
+=begin PIR
+
+ .sub 'foo'
+ $I33 = 1
+ .end
+
+=end PIR
+
+This function allocates only one register. The register allocator counts that
+there is only one register needed, and converts C<$I33> to C<I0> internally.
+Now, let's look at a similar PASM subroutine:
+
+=begin PASM
+
+ foo:
+ set I33, 1
+ end
+
+=end PASM
+
+This function, which looks to perform the same simple operation actually is
+a little different. This small snippet of code actually allocates 33
+registers, even though only one of them is needed. It's up to the programmer
+to keep track of memory usage and not allocate more registers then are
+needed.
=head4 Register assignment
-Z<CHP-5-SECT-2.2.1>
+Z<CHP-9-SECT-2.2.1>
X<PASM (Parrot assembly language);registers;assignment>
The most basic operation on registers is assignment using the C<set>
@@ -213,13 +258,12 @@
=begin PASM
set I0, 42 # set integer register #0 to the integer value 42
- set N3, 3.14159 # set number register #3 to an approximation of E<#x3C0>
+ set N3, 3.14159 # set number register #3 to an approximation of pi
set I1, I0 # set register I1 to what I0 contains
set I2, N3 # truncate the floating point number to an integer
=end PASM
-PASM uses registers where a high-level language would use variables.
The C<exchange> opcode swaps the contents of two registers of the same
type:
@@ -230,80 +274,63 @@
=end PASM
-As we mentioned before, string and PMC registers are slightly
-different because they hold a pointer instead of directly holding a
-value. Assigning one string register to another:
-
-=begin PASM
-
- set S0, "Ford"
- set S1, S0
- set S0, "Zaphod"
- print S1 # prints "Ford"
- end
-
-=end PASM
-
-doesn't make a copy of the string; it makes a copy of the pointer.
-N<Strings in Parrot use Copy-On-Write (COW) optimizations. When we
-call C<set S1, S0> we copy the pointer only, so both registers point
-to the same string memory. We don't actually make a copy of the string
-until one of two registers is modified.> Just after C<set> C<S1>, C<S0>,
-both C<S0> and C<S1> point to the same string. But assigning a constant
-string to a string register allocates a new string. When "Zaphod" is
-assigned to C<S0>, the pointer changes to point to the location of the
-new string, leaving the old string untouched. So strings act like simple
-values on the user level, even though they're implemented as pointers.
-
-Unlike strings, assignment to a PMC doesn't automatically create a new
-object; it only calls the PMC's VTABLE method for assignment N<and depending
-on implementation the VTABLE assignment operation might not actually
-assign anything. For now though, we can assume most VTABLE interfaces
-do what they say they do.>. So, rewriting the same example using a PMC
-has a completely different result:
+PMC registers contain references to PMC structures internally. So, the set
+opcode doesn't copy the entire PMC, it only copies the reference to the
+PMC data.
=begin PASM
new P0, "String"
set P0, "Ford"
set P1, P0
- set P0, "Zaphod"
+ set P1, "Zaphod"
+ print P0 # prints "Zaphod"
print P1 # prints "Zaphod"
end
=end PASM
-The C<new> opcode creates an instance of the C<.String> class. The
-class's vtable methods define how the PMC in C<P0> operates. The
-first C<set> statement calls C<P0>'s vtable method
-C<set_string_native>, which assigns the string "Ford" to the PMC. When
-C<P0> is assigned to C<P1>:
+In this example, both C<P0> and C<P1> are both references to the same
+internal data structure, so when we set C<P1> to the string literal
+C<"Zaphod">, it overwrites the previous value C<"Ford">. Now, both C<P0>
+and C<P1> point to the String PMC C<"Zaphod">, even though it appears that
+we only set one of those two registers to that value.
+
+Strings in Parrot are also stored as references to internal data structures
+like PMCs. However, strings use Copy-On-Write (COW) optimizations. When we
+call C<set S1, S0> we copy the pointer only, so both registers point
+to the same string memory. We don't actually make a copy of the string
+until one of two registers is modified. Here's the same example using
+string registers instead of PMC registers:
=begin PASM
- set P1, P0
+ set S0, "Ford"
+ set S1, S0
+ set S1, "Zaphod"
+ print S0 # prints "Ford"
+ print S1 # prints "Zaphod"
+ end
=end PASM
-it copies the pointer, so C<P1> and C<P0> are both aliases to the same
-PMC. Then, assigning the string "Zaphod" to C<P0> changes the
-underlying PMC, so printing C<P1> or C<P0> prints "Zaphod".N<Contrast
-this with C<assign> in "PMC Assignment" later in
-this chapter.>
+Some developers have suggested that PMCs should also use COW semantics to
+help optimize copy operations like this. However, it hasn't been implemented
+yet. One day in the future, Parrot might change this, but it hasn't changed
+yet.
=head4 PMC object types
-Z<CHP-5-SECT-2.2.2>
+Z<CHP-9-SECT-2.2.2>
X<PMCs (Polymorphic Containers);object types>
-Internally, PMC types are represented by positive integers, and
-built-in types by negative integers. PASM provides two opcodes to deal
-with types. Use C<typeof> to look up the name of a type from its
-integer value or to look up the named type of a PMC. Use C<find_type>
-to look up the integer value of a named type.
-
-When the source argument is a PMC and the destination is a string
-register, C<typeof> returns the name of the type:
+Every PMC has a distinct type that determines its behavior through the
+vtable interface. Vtables, as we have mentioned previously, are arrays
+of function pointers to implement various operations and behaviors.
+
+The C<typeof> opcode can be used to determine the type of a PMC. When
+the source argument is a PMC and the destination is a string register,
+C<typeof> returns the name of the type:
=begin PASM
@@ -315,32 +342,24 @@
=end PASM
-In this example, C<typeof> returns the type name "String".
-
-X<PMCs (Polymorphic Containers);inheritance>
-X<Parrot;classes;inheritance>
-X<inheritance;with PMCs>
-All Parrot classes inherit from the class C<default>. The
-C<default>X<default PMC> class provides some
-default functionality, but mainly throws exceptions when the default
-variant of a method is called (meaning the subclass didn't define the
-method).
+Using C<typeof> with a PMC output parameter instead, it returns the Class
+PMC for that type.
=head4 Autoboxing
-Z<CHP-5-SECT-2.2.3>
+Z<CHP-9-SECT-2.2.3>
X<Autoboxing>
As we've seen in the previous chapters about PIR, we can convert between
primitive string, integer, and number types and PMCs. PIR used the C<=>
-operator to make these conversions. PASM doesn't have any symbolic operators
-so we have to use the underlying opcodes directly. In this case, the C<set>
-opcode is used to perform data copying and data conversions automatically.
+operator to make these conversions. PASM uses the C<set> opcode to do the
+same thing. C<set> will perform the type conversions for us automatically,
+in a process called I<autoboxing>.
Assigning a primitive data type to a PMC of a String, Integer, or Float type
converts that PMC to the new type. So, assigning a string to a Number PMC
converts it into a String PMC. Assigning an integer value converts it to a
-C<Integer>, and assigning C<undef> morphs it to C<Undef>:
+C<Integer>, and assigning C<undef> converts it to an C<Undef> PMC:
=begin PASM
@@ -363,9 +382,23 @@
primitive values string, int, and num. Other PMC classes will have different
behaviors when you try to assign a primitive value to them.
+We can also use the C<box> opcode to explicitly convert an integer, a float,
+or a string into an appropriate PMC type.
+
+=begin PASM
+
+ box P0, 3
+ typeof S0, P0 # P0 is an "Integer"
+ box P1, "hello"
+ typeof S0, P1 # P1 is a "String"
+ box P2, 3.14
+ typeof S0, P2 # P2 is a "Number"
+
+=end PASM
+
=head3 Math Operations
-Z<CHP-5-SECT-2.3>
+Z<CHP-9-SECT-2.3>
X<PASM (Parrot assembly language);math operations>
PASM has a full set of math instructions. These work with integers,
@@ -428,7 +461,7 @@
=head4 Unary math opcodes
-Z<CHP-5-SECT-2.3.1>
+Z<CHP-9-SECT-2.3.1>
The unary opcodes have either a destination argument and a source
argument, or a single argument as destination and source. Some of the
@@ -446,7 +479,7 @@
=head4 Binary math opcodes
-Z<CHP-5-SECT-2.3.2>
+Z<CHP-9-SECT-2.3.2>
X<PASM (Parrot assembly language);math operations;binary>
Binary opcodes have two source arguments and a destination argument.
@@ -471,7 +504,7 @@
=head4 Floating-point operations
-Z<CHP-5-SECT-2.3.3>
+Z<CHP-9-SECT-2.3.3>
X<PASM (Parrot assembly language);math operations;floating-point>
Although most of the math operations work with both floating-point
@@ -510,7 +543,7 @@
=head3 Working with Strings
-Z<CHP-5-SECT-2.4>
+Z<CHP-9-SECT-2.4>
X<PASM (Parrot assembly language);string operations>
String operations work with string registers and with PMCs that implement a
@@ -519,7 +552,7 @@
=head4 Concatenating strings
-Z<CHP-5-SECT-2.4.1>
+Z<CHP-9-SECT-2.4.1>
X<PASM (Parrot assembly language);string operations;concatenation>
Use the C<concat>X<concat opcode (PASM)> opcode to concatenate
@@ -569,7 +602,7 @@
=head4 Repeating strings
-Z<CHP-5-SECT-2.4.2>
+Z<CHP-9-SECT-2.4.2>
X<PASM (Parrot assembly language);string operations;repeating strings>
The C<repeat>X<repeat opcode (PASM)> opcode repeats a string a certain
@@ -590,7 +623,7 @@
=head4 Length of a string
-Z<CHP-5-SECT-2.4.3>
+Z<CHP-9-SECT-2.4.3>
X<PASM (Parrot assembly language);string operations;length>
The C<length>X<length opcode (PASM)> opcode returns the length of a
@@ -611,7 +644,7 @@
=head4 Substrings
-Z<CHP-5-SECT-2.4.4>
+Z<CHP-9-SECT-2.4.4>
X<PASM (Parrot assembly language);string operations;substrings>
The simplest version of the C<substr>X<substr opcode (PASM)> opcode
@@ -678,7 +711,7 @@
=head4 Chopping strings
-Z<CHP-5-SECT-2.4.5>
+Z<CHP-9-SECT-2.4.5>
X<PASM (Parrot assembly language);string operations;chopping strings>
The C<chopn>X<chopn opcode (PASM)> opcode removes characters from the
@@ -725,7 +758,7 @@
=head4 Copying strings
-Z<CHP-5-SECT-2.4.6>
+Z<CHP-9-SECT-2.4.6>
X<PASM (Parrot assembly language);string operations;copying>
The C<clone>X<clone opcode (PASM)> opcode makes a deep copy of a
@@ -757,7 +790,7 @@
=head4 Converting characters
-Z<CHP-5-SECT-2.4.7>
+Z<CHP-9-SECT-2.4.7>
X<PASM (Parrot assembly language);string operations;converting strings>
The C<chr>X<chr opcode (PASM)> opcode takes an integer value and
@@ -794,7 +827,7 @@
=head4 Formatting strings
-Z<CHP-5-SECT-2.4.8>
+Z<CHP-9-SECT-2.4.8>
X<PASM (Parrot assembly language);string operations;formatting
strings> The C<sprintf>X<sprintf opcode (PASM)> opcode generates a
@@ -816,11 +849,11 @@
the string starts with a C<%>
X<% (percent sign);% format strings for sprintf opcode (PASM)> and
ends with a character specifying the output format. The output format
-characters are listed in Table 5-1.
+characters are listed in Table 9-1.
=begin table picture Format characters
-Z<CHP-5-TABLE-1>
+Z<CHP-9-TABLE-1>
=headrow
@@ -934,11 +967,11 @@
Each format field can be specified with several options: R<flags>,
R<width>, R<precision>, and R<size>. The format flags are listed in
-Table 5-2.
+Table 9-2.
=begin table picture Format flags
-Z<CHP-5-TABLE-2>
+Z<CHP-9-TABLE-2>
=headrow
@@ -989,11 +1022,11 @@
value from the next argument in the PMC.
The R<size> modifier defines the type of the argument the field takes.
-The flags are listed in Table 5-3.
+The flags are listed in Table 9-3.
=begin table picture Size flags
-Z<CHP-5-TABLE-3>
+Z<CHP-9-TABLE-3>
=headrow
@@ -1084,7 +1117,7 @@
=head4 Testing for substrings
-Z<CHP-5-SECT-2.4.9>
+Z<CHP-9-SECT-2.4.9>
X<PASM (Parrot assembly language);string operations;testing for substrings>
The C<index>X<index opcode (PASM)> opcode searches for a substring
@@ -1168,7 +1201,7 @@
=head3 Logical and Bitwise Operations
-Z<CHP-5-SECT-2.6>
+Z<CHP-9-SECT-2.6>
X<PASM (Parrot assembly language);bitwise operations>
X<PASM (Parrot assembly language);logical operations>
@@ -1284,7 +1317,7 @@
=head2 Working with PMCs
-Z<CHP-5-SECT-3>
+Z<CHP-9-SECT-3>
In most of the examples we've shown so far, X<PMCs (Polymorphic
Containers);working with> PMCs just duplicate the functionality of
@@ -1294,7 +1327,7 @@
=head3 Aggregates
-Z<CHP-5-SECT-3.1>
+Z<CHP-9-SECT-3.1>
PMCs can define complex types that hold multiple values. These are
commonly called "X<PMCs (Polymorphic Containers);aggregate>
@@ -1310,7 +1343,7 @@
=head4 Arrays
-Z<CHP-5-SECT-3.1.1>
+Z<CHP-9-SECT-3.1.1>
X<PMCs (Polymorphic Containers);arrays>
The C<Array>X<Array PMC> PMC is an ordered aggregate with
@@ -1359,7 +1392,7 @@
=head4 Hashes
-Z<CHP-5-SECT-3.1.2>
+Z<CHP-9-SECT-3.1.2>
X<PMCs (Polymorphic Containers);hashes>
The C<Hash>X<Hash PMC> PMC is an unordered aggregate with
@@ -1395,7 +1428,7 @@
=head4 Iterators
-Z<CHP-5-SECT-3.1.3>
+Z<CHP-9-SECT-3.1.3>
Iterators extract values from an aggregate PMC. You create an iterator
by creating a new C<Iterator> PMC, and passing the array to C<new> as
@@ -1461,7 +1494,7 @@
=head4 Data structures
-Z<CHP-5-SECT-3.1.4>
+Z<CHP-9-SECT-3.1.4>
X<PMCs (Polymorphic Containers);data structures>
Arrays and hashes can hold any data type, including other aggregates.
@@ -1499,7 +1532,7 @@
=head3 PMC Assignment
-Z<CHP-5-SECT-3.2>
+Z<CHP-9-SECT-3.2>
We mentioned before that C<set> on two X<PMCs (Polymorphic
Containers);assignment> PMCs simply aliases them both to the same object,
@@ -1535,7 +1568,7 @@
=head3 Properties
-Z<CHP-5-SECT-3.3>
+Z<CHP-9-SECT-3.3>
X<PMCs (Polymorphic Containers);properties>
PMCs can have additional values attached to them as "properties" of
@@ -1597,7 +1630,7 @@
=head2 Flow Control
-Z<CHP-5-SECT-4>
+Z<CHP-9-SECT-4>
X<PASM (Parrot assembly language);flow control>
Although it has many advanced features, at heart PASM is an assembly
@@ -1652,7 +1685,7 @@
=head3 Conditional Branches
-Z<CHP-5-SECT-4.1>
+Z<CHP-9-SECT-4.1>
X<PASM (Parrot assembly language);conditional branches>
X<conditional branches in PASM>
@@ -1740,7 +1773,7 @@
=head3 Iteration
-Z<CHP-5-SECT-4.2>
+Z<CHP-9-SECT-4.2>
X<iteration;in PASM>
X<PASM (Parrot assembly language);iteration>
@@ -1811,7 +1844,7 @@
=head2 Lexicals and Globals
-Z<CHP-5-SECT-6>
+Z<CHP-9-SECT-6>
So far, we've been treating Parrot registers like the variables of a
high-level language. This is fine, as far as it goes, but it isn't the
@@ -1831,7 +1864,7 @@
=head3 Globals
-Z<CHP-5-SECT-6.1>
+Z<CHP-9-SECT-6.1>
X<PASM (Parrot assembly language);global variables>
Global variables are stored in a C<Hash>, so every variable name
@@ -1903,7 +1936,7 @@
=head3 Lexicals
-Z<CHP-5-SECT-6.2>
+Z<CHP-9-SECT-6.2>
X<PASM (Parrot assembly language);lexical variables>
Lexical variables are stored in a lexical scratchpad. There's one pad
@@ -1912,7 +1945,7 @@
=head4 Basic instructions
-Z<CHP-5-SECT-6.2.1>
+Z<CHP-9-SECT-6.2.1>
To store a lexical variable in the current scope pad, use C<store_lex>.
Likewise, use C<find_lex> to retrieve a variable from the current pad.
@@ -1932,7 +1965,7 @@
=head2 Subroutines
-Z<CHP-5-SECT-7>
+Z<CHP-9-SECT-7>
X<subroutines>
Subroutines and methods are the basic building blocks of larger
@@ -1978,7 +2011,7 @@
=head3 Calling Conventions
-Z<CHP-5-SECT-7.1>
+Z<CHP-9-SECT-7.1>
X<registers;usage for subroutine calls>
X<subroutines;register usage>
@@ -1994,7 +2027,7 @@
=head4 Parrot calling conventions
-Z<CHP-5-SECT-7.1.2>
+Z<CHP-9-SECT-7.1.2>
Internal subroutines can use whatever calling convention serves them
best. Externally visible subroutines and methods need stricter rules.
@@ -2019,7 +2052,7 @@
=head3 Native Call Interface
-Z<CHP-5-SECT-7.2>
+Z<CHP-9-SECT-7.2>
X<subroutines;calling conventions;NCI>
A special version of the Parrot calling conventions are used by the
@@ -2030,17 +2063,18 @@
=begin PASM
- loadlib P1, "libnci" # get library object for a shared lib
+ loadlib P1, "libnci_test" # get library object for a shared lib
print "loaded\n"
dlfunc P0, P1, "nci_dd", "dd" # obtain the function object
print "dlfunced\n"
set I0, 1 # prototype used - unchecked
- set N5, 4.0 # first argument
- invoke # call nci_dd
+ set_args "0", 4.0 # set the argument
+ get_results "0", N5 # prepare to store the return value
+ invokecc P0 # call nci_dd
ne N5, 8.0, nok_1 # the test functions returns 2*arg
print "ok 1\n"
end
- nok_1:
+ nok_1:
#...
=end PASM
@@ -2059,11 +2093,11 @@
function signature is a string where the first character is the return
value and the rest of the parameters are the function parameters. The
characters used in X<NCI (Native Call Interface);function signatures>
-NCI function signatures are listed in Table 5-5.
+NCI function signatures are listed in Table 9-5.
=begin table picture Function signature letters
-Z<CHP-5-TABLE-5>
+Z<CHP-9-TABLE-5>
=headrow
@@ -2196,7 +2230,7 @@
=head3 Coroutines
-Z<CHP-5-SECT-7.4>
+Z<CHP-9-SECT-7.4>
As we mentioned in the previous chapter, coroutines are
X<subroutines;coroutines> subroutines that
@@ -2277,7 +2311,7 @@
=head3 Continuations
-Z<CHP-5-SECT-7.5>
+Z<CHP-9-SECT-7.5>
X<continuations>
X<subroutines;continuations>
@@ -2315,7 +2349,7 @@
=head3 Evaluating a Code String
-Z<CHP-5-SECT-7.6>
+Z<CHP-9-SECT-7.6>
X<code strings, evaluating>
This isn't really a subroutine operation, but it does produce a code
@@ -2369,7 +2403,7 @@
=head2 Exceptions and Exception Handlers
-Z<CHP-5-SECT-8>
+Z<CHP-9-SECT-8>
X<exceptions>
X<exception handlers>
@@ -2463,7 +2497,7 @@
=head2 Events
-Z<CHP-5-SECT-9>
+Z<CHP-9-SECT-9>
An event is a notification that something has happened: a timer
expired, an IO operation finished, a thread sent a message to
@@ -2483,7 +2517,7 @@
=head3 Timers
-Z<CHP-5-SECT-9.1>
+Z<CHP-9-SECT-9.1>
C<Timer> objects are the replacement for Perl 5's C<alarm> handlers.
They are also a significant improvement. Timers can fire once or
@@ -2494,7 +2528,7 @@
=head3 Signals
-Z<CHP-5-SECT-9.2>
+Z<CHP-9-SECT-9.2>
Signal handling is related to events. When Parrot gets a signal it
needs to handle from the OS, it converts that signal into an event and
@@ -2532,7 +2566,7 @@
=head2 Threads
-Z<CHP-5-SECT-10>
+Z<CHP-9-SECT-10>
Threads allow multiple pieces of code to run in parallel. This is
useful when you have multiple physical CPUs to share the load of
@@ -2703,7 +2737,7 @@
=head2 Loading Bytecode
-Z<CHP-5-SECT-11>
+Z<CHP-9-SECT-11>
In addition to running Parrot bytecode on the command-line, you can
also load pre-compiled bytecode directly into your PASM source file.
@@ -2790,7 +2824,7 @@
=head2 Classes and Objects
-Z<CHP-5-SECT-12>
+Z<CHP-9-SECT-12>
This section revolves around one complete example that defines a
class, instantiates objects, and uses them. The whole example is
@@ -2798,7 +2832,7 @@
=head3 Class declaration
-Z<CHP-5-SECT-12.1>
+Z<CHP-9-SECT-12.1>
X<classes;in PASM>
The C<newclass>X<newclass opcode (PASM)> opcode defines a new class.
@@ -2829,7 +2863,7 @@
=head3 Attributes
-Z<CHP-5-SECT-12.2>
+Z<CHP-9-SECT-12.2>
X<attributes;in PASM>
X<classes;attributes>
@@ -2916,7 +2950,7 @@
=head3 Methods
-Z<CHP-5-SECT-12.3>
+Z<CHP-9-SECT-12.3>
X<methods;in PASM>
X<classes;methods>
@@ -2981,7 +3015,7 @@
=head4 Overriding vtable functions
-Z<CHP-5-SECT-12.3.1>
+Z<CHP-9-SECT-12.3.1>
Every object inherits a default set of I<vtable> functions from the
C<ParrotObject> PMC, but you can also override them with your own
@@ -3060,7 +3094,7 @@
=head3 Inheritance
-Z<CHP-5-SECT-12.4>
+Z<CHP-9-SECT-12.4>
X<inheritance;in PASM>
X<classes;inheritance>
@@ -3137,7 +3171,7 @@
=head3 Additional Object Opcodes
-Z<CHP-5-SECT-12.5>
+Z<CHP-9-SECT-12.5>
The C<isa> and C<can> opcodes are also useful when working with
objects. C<isa>X<isa opcode (PASM)> checks whether an object belongs to or
@@ -3154,7 +3188,7 @@
=head3 Complete Example
-Z<CHP-5-SECT-12.6>
+Z<CHP-9-SECT-12.6>
=begin PASM
Modified: branches/headercleanup/docs/book/ch10_opcode_reference.pod
==============================================================================
--- branches/headercleanup/docs/book/ch10_opcode_reference.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/book/ch10_opcode_reference.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -2,7 +2,7 @@
=head1 Instruction Reference
-Z<CHP-13>
+Z<CHP-10>
This chapter contains a condensed reference to the Parrot virtual
machine's native instruction set, generally called opcodes. All opcodes
@@ -1223,11 +1223,11 @@
Return information about the interpreter. An integer flag selects
which information to return, as listed in
-Table 13-1.
+Table 10-1.
=begin table picture Interpinfo flags
-Z<CHP-13-TABLE-1>
+Z<CHP-10-TABLE-1>
=headrow
@@ -2362,13 +2362,13 @@
stat R<DEST>, R<VAL>, R<VAL>
Stat the VAL1 file and return stat element VAL2, as listed in
-Table 13-2.
+Table 10-2.
I<Arguments: IR, S, I or IR, I, I>
=begin table picture Stat arguments
-Z<CHP-13-TABLE-2>
+Z<CHP-10-TABLE-2>
=headrow
@@ -2532,11 +2532,11 @@
stringinfo R<DEST>, R<STRING>, R<FLAG>
Return information about a string. An integer flag selects which
-information to return, as listed in Table 13-3.
+information to return, as listed in Table 10-3.
=begin table picture Stringinfo arguments
-Z<CHP-13-TABLE-3>
+Z<CHP-10-TABLE-3>
=headrow
Modified: branches/headercleanup/docs/compiler_faq.pod
==============================================================================
--- branches/headercleanup/docs/compiler_faq.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/compiler_faq.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -107,17 +107,20 @@
created as a Coroutine PMC:
=begin PIR
+
.sub my_coro # automagically a Coroutine PMC
.param pmc result
#...
.yield (result)
#...
.end
+
=end PIR
=head2 How do I generate a tail call in PIR?
=begin PIR
+
.sub foo
# ...
.tailcall bar(42) # tail call sub bar
@@ -128,6 +131,7 @@
inc answer
.return(answer)
.end
+
=end PIR
The sub C<bar> will return to the caller of C<foo>. (Warning! This fails
Modified: branches/headercleanup/docs/parrothist.pod
==============================================================================
--- branches/headercleanup/docs/parrothist.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/parrothist.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -10,7 +10,8 @@
Simon Cozens, Jeff Goff, Steve Fink, Leo Toetsch, Chip Salzenberg, Jerry Gay,
Patrick Michaud, Will Coleda, Matt Diephouse, chromatic, Allison Randal,
-Jonathan Worthington, Bob Rogers, Bernhard Schmalhofer, Andrew Whitworth.
+Jonathan Worthington, Bob Rogers, Bernhard Schmalhofer, Andrew Whitworth,
+Francois Perrad.
=head1 THE RECORDS
@@ -89,4 +90,6 @@
Allison 1.0.0 2009-Mar-17 "Haru Tatsu"
+ Francois 1.1.0 2009-Apr-21 "Half-moon Conure"
+
=cut
Modified: branches/headercleanup/docs/pdds/pdd07_codingstd.pod
==============================================================================
--- branches/headercleanup/docs/pdds/pdd07_codingstd.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/pdds/pdd07_codingstd.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -853,6 +853,8 @@
can be added to the CREDITS file. (Languages are an exception to this rule,
and may follow whatever convention they choose.)
+Don't include Pod sections for License or Copyright in individual files.
+
=item Per-section comments
If there is a collection of functions, structures or whatever which are
@@ -924,6 +926,21 @@
....
}
+=item Copyright notice
+
+The first line of every file (or the second line if the first line is a
+I<shebang> line such as C<#!/usr/bin/perl>) should be a copyright notice, in
+the comment style appropriate to the file type. It should list the first year
+the file was created and the last year the file was modified. (This isn't
+necessarily the current year, the file might not have been modified this
+year.)
+
+ /* Copyright (C) 2001-2008, Parrot Foundation. */
+
+For files that were newly added this year, just list the current year.
+
+ /* Copyright (C) 2009, Parrot Foundation. */
+
=back
=head3 Extensibility
Modified: branches/headercleanup/docs/pdds/pdd13_bytecode.pod
==============================================================================
--- branches/headercleanup/docs/pdds/pdd13_bytecode.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/pdds/pdd13_bytecode.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -805,8 +805,6 @@
=item uuid_type
-=item uuid_length
-
=back
=item * C<get_string_keyed_str> (v-table)
@@ -877,10 +875,8 @@
=head4 PackfileDirectory.pmc (isa PackfileSegment)
-This PMC represents a directory segment. Essentially it is an array of
-PackfileSegment PMCs. When indexed using an integer key, it gets the segment
-at that position in the segments table. When indexed using a string key, it
-looks for a segment of that name. It implements the following methods:
+This PMC represents a directory segment. Essentially it is an hash of
+PackfileSegment PMCs. It implements the following methods:
=over 4
@@ -888,16 +884,6 @@
Gets the number of segments listed in the directory.
-=item * C<get_pmc_keyed_int> (v-table)
-
-Gets a PackfileSegment PMC or an appropriate subclass of it representing the
-segment at the specified index in the directory segment.
-
-=item * C<get_string_keyed_int> (v-table)
-
-Gets a string containing the name of the segment at the specified index in the
-directory segment.
-
=item * C<get_pmc_keyed_str> (v-table)
Searches the directory for a segment with the given name and, if one exists,
@@ -916,9 +902,13 @@
specified by the key. This is the only way to remove a segment from the
directory.
+=item * C<get_iter> (v-table)
+
+Returns iterator for existing keys.
+
=back
-=head4 RawSegment.pmc (isa PackfileSegment)
+=head4 PackfileRawSegment.pmc (isa PackfileSegment)
This PMC presents a segment of a packfile as an array of integers. This is the
lowest possible level of access to a segment, and covers both the default and
@@ -926,6 +916,18 @@
=over 4
+=item * C<get_type>
+
+Get type of PackfileRawSegment.
+
+=item * C<set_type>
+
+Set type of PackfileRawSegment.
+
+=item * C<get_iter>
+
+Returns iterator for Segment.
+
=item * C<get_integer_keyed_int> (v-table)
Reads the integer at the specified offset into the segment, excluding the data
@@ -958,6 +960,10 @@
=over 4
+=item * C<get_iter>
+
+Returns iterator for stored Constants.
+
=item * C<elements> (v-table)
Gets the number of constants contained in the table.
@@ -1030,6 +1036,10 @@
=over 4
+=item * C<get_iter>
+
+Returns iterator for stored fixup entries.
+
=item * C<elements> (v-table)
Gets the number of entries in the fixup table.
@@ -1135,6 +1145,10 @@
=over 4
+=item * C<elements> (v-table)
+
+Get the number of stored Keys.
+
=item * C<get_string_keyed_int> (v-table)
Gets the name of the annotation key specified by the index. An exception will
Modified: branches/headercleanup/docs/project/release_manager_guide.pod
==============================================================================
--- branches/headercleanup/docs/project/release_manager_guide.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/docs/project/release_manager_guide.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -53,8 +53,6 @@
F<VERSION>, F<parrot.spec>, F<MANIFEST.generated>, F<META.yml>,
F<README>.
-Note: C<Source0> in F<parrot.spec> might have to be adapted as well.
-
Also update the version number, date, and your name in the
the file: F<docs/parrothist.pod>.
@@ -349,7 +347,6 @@
The starred releases are Parrot's twice-yearly supported releases, see
F<docs/project/support_policy.pod>.
- - April 21, 2009 - 1.1 - fperrad
- May 19, 2009 - 1.2 - tewk
- June 16, 2009 - 1.3 - whiteknight
- July 21, 2009 - 1.4* - cotto
Modified: branches/headercleanup/examples/streams/FileLines.pir
==============================================================================
--- branches/headercleanup/examples/streams/FileLines.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/examples/streams/FileLines.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,5 +1,3 @@
-# $Id$
-
=head1 Advanced Lines Example
This is an advanced example.
Modified: branches/headercleanup/examples/streams/ParrotIO.pir
==============================================================================
--- branches/headercleanup/examples/streams/ParrotIO.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/examples/streams/ParrotIO.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,5 +1,3 @@
-# $Id$
-
=head1 Filehandle Object Example
This small example shows the usage of C<Stream::ParrotIO>.
Modified: branches/headercleanup/include/parrot/misc.h
==============================================================================
--- branches/headercleanup/include/parrot/misc.h Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/include/parrot/misc.h Tue Apr 21 21:28:29 2009 (r38254)
@@ -147,7 +147,7 @@
PARROT_EXPORT
int Parrot_secret_snprintf(
ARGOUT(char *buffer),
- const size_t len,
+ NULLOK(const size_t len),
ARGIN(const char *format),
...)
__attribute__nonnull__(1)
Modified: branches/headercleanup/include/parrot/packfile.h
==============================================================================
--- branches/headercleanup/include/parrot/packfile.h Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/include/parrot/packfile.h Tue Apr 21 21:28:29 2009 (r38254)
@@ -173,18 +173,22 @@
PackFile_Segment_dump_func_t dump;
} PackFile_funcs;
+/* &gen_from_enum(packfile_segments.pasm) */
+
typedef enum {
- PF_DIR_SEG,
- PF_UNKNOWN_SEG,
- PF_FIXUP_SEG,
- PF_CONST_SEG,
- PF_BYTEC_SEG,
- PF_DEBUG_SEG,
- PF_ANNOTATIONS_SEG,
+ PF_DIR_SEG = 0,
+ PF_UNKNOWN_SEG = 1,
+ PF_FIXUP_SEG = 2,
+ PF_CONST_SEG = 3,
+ PF_BYTEC_SEG = 4,
+ PF_DEBUG_SEG = 5,
+ PF_ANNOTATIONS_SEG = 6,
- PF_MAX_SEG
+ PF_MAX_SEG = 7
} pack_file_types;
+/* &end_gen */
+
#define PF_DIR_FORMAT 1
typedef struct PackFile_Segment {
@@ -229,12 +233,18 @@
PackFile_ByteCode *code; /* where this segment belongs to */
} PackFile_FixupTable;
-#define PFC_NONE '\0'
+
+
+/* &gen_from_def(packfile_constants.pasm) */
+
/* no ascii chars use numbers: for n, s, k, p */
-#define PFC_NUMBER '\156'
-#define PFC_STRING '\163'
-#define PFC_KEY '\153'
-#define PFC_PMC '\160'
+#define PFC_NONE 0x0
+#define PFC_NUMBER 0x6E
+#define PFC_STRING 0x73
+#define PFC_PMC 0x70
+#define PFC_KEY 0x6B
+
+/* &end_gen */
enum PF_VARTYPE { /* s. also imcc/symreg.h */
PF_VT_START_SLICE = 1 << 10, /* x .. y slice range */
@@ -276,12 +286,15 @@
PackFile_ByteCode *code; /* where this segment belongs to */
} PackFile_Debug;
+/* &gen_from_def(packfile_annotation_key_type.pasm) */
/* Key types for annotation segment. */
#define PF_ANNOTATION_KEY_TYPE_INT 0
#define PF_ANNOTATION_KEY_TYPE_STR 1
#define PF_ANNOTATION_KEY_TYPE_NUM 2
+/* &end_gen */
+
typedef struct PackFile_Annotations_Key {
opcode_t name;
opcode_t type;
Modified: branches/headercleanup/include/parrot/scheduler.h
==============================================================================
--- branches/headercleanup/include/parrot/scheduler.h Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/include/parrot/scheduler.h Tue Apr 21 21:28:29 2009 (r38254)
@@ -138,7 +138,7 @@
PARROT_EXPORT
void Parrot_cx_send_message(PARROT_INTERP,
ARGIN(STRING *messagetype),
- ARGIN_NULLOK(PMC *payload))
+ SHIM(PMC *payload))
__attribute__nonnull__(1)
__attribute__nonnull__(2);
Modified: branches/headercleanup/include/parrot/string_funcs.h
==============================================================================
--- branches/headercleanup/include/parrot/string_funcs.h Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/include/parrot/string_funcs.h Tue Apr 21 21:28:29 2009 (r38254)
@@ -418,7 +418,8 @@
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
-INTVAL Parrot_str_to_int(SHIM_INTERP, ARGIN_NULLOK(const STRING *s));
+INTVAL Parrot_str_to_int(PARROT_INTERP, ARGIN_NULLOK(const STRING *s))
+ __attribute__nonnull__(1);
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
@@ -678,7 +679,8 @@
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_str_to_hashval __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_str_to_int __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
+#define ASSERT_ARGS_Parrot_str_to_int __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_Parrot_str_to_num __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(s)
Modified: branches/headercleanup/include/parrot/thread.h
==============================================================================
--- branches/headercleanup/include/parrot/thread.h Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/include/parrot/thread.h Tue Apr 21 21:28:29 2009 (r38254)
@@ -205,7 +205,7 @@
__attribute__nonnull__(1);
void pt_thread_kill(UINTVAL tid);
-void pt_thread_prepare_for_run(Parrot_Interp d, Parrot_Interp s);
+void pt_thread_prepare_for_run(Parrot_Interp d, NULLOK(Parrot_Interp s));
int pt_thread_run(PARROT_INTERP,
ARGOUT(PMC *dest_interp),
ARGIN(PMC *sub),
Modified: branches/headercleanup/lib/Parrot/Docs/Section/Parrot.pm
==============================================================================
--- branches/headercleanup/lib/Parrot/Docs/Section/Parrot.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/lib/Parrot/Docs/Section/Parrot.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -80,7 +80,9 @@
$self->new_group(
'Implementing Languages on Parrot',
'',
- $self->new_item( 'Compiler Tools', 'docs/book/ch09_pct.pod'),
+ $self->new_item( 'Parrot Compiler Tools', 'docs/book/ch04_compiler_tools.pod'),
+ $self->new_item( 'Parrot Grammar Engine', 'docs/book/ch05_pge.pod'),
+ $self->new_item( 'Not Quite Perl', 'docs/book/ch06_nqp.pod'),
$self->new_item( 'Compiler FAQ', 'docs/compiler_faq.pod'),
),
$self->new_group(
@@ -97,20 +99,23 @@
$self->new_group(
'Book',
'',
- $self->new_item( 'Chapter 1 Overview', 'docs/book/ch01_overview.pod'),
+ $self->new_item( 'Chapter 1 Introduction', 'docs/book/ch01_introduction.pod'),
$self->new_item( 'Chapter 2 Getting Started', 'docs/book/ch02_getting_started.pod'),
- $self->new_item( 'Chapter 3 PIR Basics', 'docs/book/ch03_pir_basics.pod'),
- $self->new_item( 'Chapter 4 PIR Subroutines', 'docs/book/ch04_pir_subroutines.pod'),
- $self->new_item( 'Chapter 5 PASM', 'docs/book/ch05_pasm.pod'),
- $self->new_item( 'Chapter 6 Library', 'docs/book/ch06_library.pod'),
- $self->new_item( 'Chapter 7 Testing & Debugging', 'docs/book/ch07_testing_and_debugging.pod'),
- $self->new_item( 'Chapter 8 Architecture', 'docs/book/ch08_architecture.pod'),
- $self->new_item( 'Chapter 9 PCT', 'docs/book/ch09_pct.pod'),
- $self->new_item( 'Chapter 10 HLL', 'docs/book/ch10_hlls.pod'),
- $self->new_item( 'Chapter 11 PMCs', 'docs/book/ch11_pmcs.pod'),
- $self->new_item( 'Chapter 12 Opcodes', 'docs/book/ch12_opcodes.pod'),
- $self->new_item( 'Chapter 13 Reference', 'docs/book/ch13_reference.pod'),
- $self->new_item( 'Appendix 1 Patch Submission', 'docs/book/appX_patch_submission.pod'),
+ $self->new_item( 'Chapter 3 Parrot Intermediate Representation', 'docs/book/ch03_pir.pod'),
+ $self->new_item( 'Chapter 4 Parrot Compiler Tools', 'docs/book/ch04_compiler_tools.pod'),
+ $self->new_item( 'Chapter 5 Parrot Grammar Engine', 'docs/book/ch05_pge.pod'),
+ $self->new_item( 'Chapter 6 Not Quite Perl', 'docs/book/ch06_nqp.pod'),
+ $self->new_item( 'Chapter 7 Dynamic C-level Objects', 'docs/book/ch07_dynpmcs.pod'),
+ $self->new_item( 'Chapter 8 Dynamic Opcodes', 'docs/book/ch08_dynops.pod'),
+ $self->new_item( 'Chapter 9 Parrot Assembly Language', 'docs/book/ch09_pasm.pod'),
+ $self->new_item( 'Chapter 10 Instruction Reference', 'docs/book/ch10_opcode_reference.pod'),
+ $self->new_item( 'Chapter 11 Directive Reference', 'docs/book/ch11_directive_reference.pod'),
+ $self->new_item( 'Chapter 12 PIR Operator Reference', 'docs/book/ch12_operator_reference.pod'),
+ $self->new_item( 'Appendix A Glossary', 'docs/book/appa_glossary.pod'),
+ $self->new_item( 'Appendix B Patch Submission', 'docs/book/appb_patch_submission.pod'),
+ $self->new_item( 'Appendix C ', 'docs/book/appc_command_line_options.pod'),
+ $self->new_item( 'Appendix D ', 'docs/book/appd_build_options.pod'),
+ $self->new_item( 'Appendix E ', 'docs/book/appe_source_code.pod'),
),
# Parrot::Docs::Section::C->new,
Modified: branches/headercleanup/lib/Parrot/Op.pm
==============================================================================
--- branches/headercleanup/lib/Parrot/Op.pm Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/lib/Parrot/Op.pm Tue Apr 21 21:28:29 2009 (r38254)
@@ -438,19 +438,9 @@
1;
-__END__
-
-=begin TODO
-
-=head1 LICENSE
-
-This program is free software. It is subject to the same
-license as Parrot itself.
-
-=head1 COPYRIGHT
-
-Copyright (C) 2001-2008, Parrot Foundation.
-
-=end TODO
-
-=cut
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
Deleted: branches/headercleanup/parrot.spec
==============================================================================
--- branches/headercleanup/parrot.spec Tue Apr 21 21:28:29 2009 (r38253)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,248 +0,0 @@
-Name: parrot
-Version: 1.0.0
-Release: 1%{dist}
-Summary: Parrot Virtual Machine
-License: Artistic 2.0
-Group: Development/Libraries
-URL: http://www.parrot.org/
-Source0: ftp://ftp.parrot.org/pub/parrot/releases/stable/%{version}/parrot-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: readline-devel
-BuildRequires: ncurses-devel
-BuildRequires: gmp-devel
-BuildRequires: gdbm-devel
-BuildRequires: libicu-devel
-BuildRequires: perl-Test-Harness
-
-%package docs
-Summary: Parrot Virtual Machine documentation
-License: Artistic 2.0
-Group: Development/Libraries
-BuildRequires: /usr/bin/perldoc
-
-%package devel
-Summary: Parrot Virtual Machine development headers and libraries
-License: Artistic 2.0
-Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
-Requires: %{_libdir}/pkgconfig
-
-%description
-Parrot is a virtual machine designed to efficiently compile and execute
-bytecode for dynamic languages. Parrot is the target for Rakudo Perl 6,
-as well as variety of other languages.
-
-%description docs
-Documentation in text-, POD- and HTML-format (docs/html-subdirectory) and also
-examples about the Parrot Virtual Machine
-
-%description devel
-Parrot Virtual Machine development headers and libraries.
-
-%prep
-%setup -q
-
-%{__perl} -pi -e 's,"lib/,"%{_lib}/, if (/CONST_STRING\(interp,/)' \
- src/library.c
-%{__perl} -pi -e "s,'/usr/lib','%{_libdir}',;s,runtime/lib/,runtime/%{_lib}/," \
- tools/dev/install_files.pl
-
-%build
-if test "%{_vendor}" = "suse"
-then
- LIBS='-lncurses -lm'
-else
- LIBS='-lcurses -lm'
-fi
-
-%ifarch i386 x86_64
-%{__perl} Configure.pl \
- --prefix=%{_usr} \
- --libdir=%{_libdir} \
- --sysconfdir=%{_sysconfdir} \
- --infodir=%{_datadir}/info \
- --mandir=%{_mandir} \
- --cc="%{__cc}" \
- --cxx=%{__cxx} \
- --optimize="$RPM_OPT_FLAGS -maccumulate-outgoing-args" \
- --parrot_is_shared \
- --lex=/usr/bin/flex \
- --yacc=/usr/bin/yacc \
- --libs="$LIBS"
-%else
-# PowerPC
-%{__perl} Configure.pl \
- --prefix=%{_usr} \
- --libdir=%{_libdir}
-%endif
-
-export LD_LIBRARY_PATH=$( pwd )/blib/lib
-make
-make parrot_utils
-make installable
-make html
-
-%install
-rm -rf $RPM_BUILD_ROOT
-
-export LD_LIBRARY_PATH=$( pwd )/blib/lib
-make install DESTDIR=$RPM_BUILD_ROOT
-
-# Drop the docs so rpm can pick them up itself.
-rm -rf $RPM_BUILD_ROOT%{_usr}/share/doc/parrot # necessary for SuSE
-#rm -rf $RPM_BUILD_ROOT/%{_docdir}/parrot # for Solaris?
-
-# Force permissions on doc directories.
-find docs examples -type d -exec chmod 755 {} \;
-find docs examples -type f -exec chmod 644 {} \;
-
-# Force permissions on shared libs so they get stripped.
-find $RPM_BUILD_ROOT%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) \
- -exec chmod 755 {} \;
-
-# These files *probably* aren't needed.
-rm -rf $RPM_BUILD_ROOT%{_usr}/config \
- $RPM_BUILD_ROOT%{_includedir}/src \
- $RPM_BUILD_ROOT%{_usr}/src \
- $RPM_BUILD_ROOT%{_usr}/tools
-
-%check
-export LD_LIBRARY_PATH=$( pwd )/blib/lib
-# make test < /dev/null
-# %{?_with_fulltest:make fulltest < /dev/null}
-# make test || :
-# %{?_with_fulltest:make fulltest || :}
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%post -p /sbin/ldconfig
-
-%postun -p /sbin/ldconfig
-
-%files
-%defattr(-,root,root,-)
-%exclude %{_bindir}/parrot_config
-%exclude %{_bindir}/parrot_debugger
-%exclude %{_bindir}/pbc_*
-%{_bindir}/*
-%{_libdir}/parrot
-%{_libdir}/libparrot.so.*
-
-%files docs
-%defattr(-,root,root,-)
-%doc ChangeLog CREDITS NEWS PBC_COMPAT PLATFORMS README
-%doc RESPONSIBLE_PARTIES TODO
-%doc docs examples
-
-%files devel
-%defattr(-,root,root,-)
-%{_bindir}/parrot_config
-%{_bindir}/parrot_debugger
-%{_bindir}/pbc_disassemble
-%{_bindir}/pbc_info
-%{_bindir}/pbc_merge
-%{_bindir}/pbc_to_exe
-%{_bindir}/pbc_dump
-%{_includedir}/parrot
-%{_libdir}/libparrot.so
-%{_libdir}/libparrot.a
-%{_libdir}/pkgconfig/*
-
-%changelog
-* Tue Mar 17 2009 Allison Randal <allison at parrot.org> 1.0.0
-- updated to 1.0.0
-
-* Tue Jan 23 2009 Reini Urban <rurban at x-ray.at> 0.9.0
-- added make installable, perl6 is still not installable
-- added parrot_utils to devel
-- fixed Source0 url
-
-* Tue Jan 23 2009 Gerd Pokorra <gp at zimt.uni-siegen.de> 0.9.0
-- added make html
-- make reallyinstall => make install
-
-* Tue Jan 20 2009 chromatic <chromatic at wgz.org> 0.9.0
-- updated to 0.9.0
-
-* Tue Dec 16 2008 Whiteknight <wknight8111 at gmail.com> 0.8.2
-- updated to 0.8.2
-
-* Tue Nov 18 2008 chromatic <chromatic at parrot.org> 0.8.1
-- updated to 0.8.1
-
-* Tue Oct 21 2008 particle <particle at parrot.org> 0.8.0
-- updated to 0.8.0
-
-* Tue Sep 16 2008 pmichaud <pmichaud at pobox.com> 0.7.1
-- updated to 0.7.1
-
-* Wed Sep 3 2008 chromatic <chromatic at wgz.org> 0.7.0
-- install parrot_config (not parrot-config)
-
-* Tue Jun 17 2008 Nuno Carvalho <smash at cpan.org> 0.6.3
-- updated to 0.6.3
-
-* Tue May 20 2008 chromatic <chromatic at wgz.org>> 0.6.2
-- updated to 0.6.2
-
-* Mon Apr 28 2008 chromatic <chromatic at wgz.org> 0.6.1
-- minor fixes; tested with Fedora 7, 8, and 9-beta
-
-* Tue Mar 18 2008 Bernhard Schmalhofer <Bernhard.Schmalhofer at gmx.de> 0.6.0
-- Update to 0.5.3.
-
-* Wed Feb 20 2008 Patrick Michaud <pmichaud at pobox.com> 0.5.3
-- Update to 0.5.3.
-
-* Tue Jan 15 2008 Bob Rogers <rogers at rgrjr.dyndns.org> 0.5.2
-- Update to 0.5.2.
-
-* Tue Dec 18 2007 Jonathan Worthington <jnthn at jnthn.net> 0.5.1
-- Update to 0.5.1.
-
-* Tue Nov 20 2007 chromatic <chromatic at wgz.org> 0.5.0
-- Update to 0.5.0.
-
-* Fri May 25 2007 David Fetter <david at fetter.org> 0.4.12-1
-- Update to 0.4.12.
-
-* Wed Apr 18 2007 Steven Pritchard <steve at kspei.com> 0.4.11-1
-- Update to 0.4.11.
-
-* Wed Mar 21 2007 Steven Pritchard <steve at kspei.com> 0.4.10-1
-- Update to 0.4.10.
-
-* Sat Mar 10 2007 Steven Pritchard <steve at kspei.com> 0.4.9-1
-- Update to 0.4.9.
-- BR ncurses-devel.
-- For some reason now I need to force -lm too.
-- Remove some files/directories that shouldn't be included.
-
-* Wed Jan 17 2007 Steven Pritchard <steve at kspei.com> 0.4.8-1
-- Attempt update to 0.4.8.
-
-* Fri Jun 30 2006 Steven Pritchard <steve at kspei.com> 0.4.5-5
-- Override lib_dir and make various substitutions to try to fix multilib.
-- Remove rpath use from Makefile.
-- Fix a pod error in src/ops/experimental.ops.
-- Enable "make test" since t/doc/pod.t won't fail now.
-
-* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-4
-- Force permissions on shared libraries so rpmbuild strips them.
-
-* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-3
-- Fix URL, description, summary, etc.
-- Add post/postun.
-- Move parrot-config to the devel sub-package.
-- Force permissions on the doc directories.
-
-* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-2
-- Add -lcurses to get readline detection to work.
-- BR libicu-devel.
-
-* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-1
-- Initial packaging attempt.
-
-* Tue Mar 18 2003 Steve Fink <sfink at foxglove.localdomain> 0.0.11
-- first .spec file created
Modified: branches/headercleanup/ports/cpan/cpan_release.pod
==============================================================================
--- branches/headercleanup/ports/cpan/cpan_release.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/ports/cpan/cpan_release.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -10,17 +10,14 @@
=item 1
-To upload a Parrot release to CPAN, your PAUSE ID will need to be a
-member of the PARROTRE group. Adding new members is a manual process
-performed by the PAUSE maintainers, so allow some time for this to
-happen.
-
-=item 2
-
In PAUSE, assign yourself co-maintainer permissions on all modules owned
-by PARROTRE.
+by PARROTRE, or ask a member of PARROTRE to do it for you.
-=item 3
+(You don't have to be a member of PARROTRE to upload a Parrot release to
+CPAN, but you do have to have co-maintainer permissions on the modules.
+See F<ports/cpan/pause_guide.pod> for more details.)
+
+=item 2
Upload the Parrot tarball to CPAN.
@@ -29,7 +26,7 @@
do need to fix META.yml for the next release. Under "no_index" list any
modules that aren't properly part of the Parrot distribution.
-=item 4
+=item 3
Once you get a reply from the PAUSE indexer, log in to PAUSE to clean up
module permissions. Under "View Permissions" search for your PAUSE ID.
Modified: branches/headercleanup/ports/cpan/pause_guide.pod
==============================================================================
--- branches/headercleanup/ports/cpan/pause_guide.pod Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/ports/cpan/pause_guide.pod Tue Apr 21 21:28:29 2009 (r38254)
@@ -4,24 +4,19 @@
In the Parrot distribution, all modules should be owned by the PARROTRE
user in PAUSE. This allows a group of maintainers to manage permissions
-and metadata on the Parrot modules. In the Parrot project, every active
-a release manager will also be made a member of the PARROTRE group.
-Current members are: ARANDAL, BDFOY, CHROMATIC, COKE, JESSE, JONATHAN,
-MDIEP, PARTICLE, PMIC.
+and metadata on the Parrot modules. You don't have to be a release
+manager to be part of the PARROTRE group, you only need a PAUSE ID and
+experience in mainatining CPAN modules. Current members are: ARANDAL,
+BDFOY, CHROMATIC, COKE, JESSE, JONATHAN, MDIEP, PARTICLE, PMIC. (At the
+moment, the only way to edit the list of members in the group is to
+write to modules at perl.org and wait for a PAUSE admin to update the list,
+so it needs to happen well in advance of the release date.)
Membership in the PARROTRE group isn't required for uploading Parrot
distributions to PAUSE. What is required for making a release is that
your individual PAUSE ID be granted co-maintainer permissions on all
PARROTRE modules. Members of the PARROTRE group have access to grant
-this permission.
-
-Generally the project manager will add your name to PARROTRE group when
-you first sign up to take a Parrot release rotation, but it's worth
-checking with the project manager several weeks ahead of your first
-release to make sure. (At the moment, the only way to edit the list of
-members in the group is to write to modules at perl.org and wait for a
-PAUSE admin to update the list, so it needs to happen well in advance of
-the release date.)
+this permission.
=head1 The PAUSE process
Copied: branches/headercleanup/ports/fedora/parrot.spec.fedora (from r38253, trunk/ports/fedora/parrot.spec.fedora)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/ports/fedora/parrot.spec.fedora Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/ports/fedora/parrot.spec.fedora)
@@ -0,0 +1,245 @@
+Name: parrot
+Version: 1.1.0
+Release: 1%{dist}
+Summary: Parrot Virtual Machine
+License: Artistic 2.0
+Group: Development/Libraries
+URL: http://www.parrot.org/
+Source0: ftp://ftp.parrot.org/pub/parrot/releases/stable/%{version}/parrot-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: readline-devel
+BuildRequires: ncurses-devel
+BuildRequires: gmp-devel
+BuildRequires: gdbm-devel
+BuildRequires: libicu-devel
+BuildRequires: perl-Test-Harness
+
+%package docs
+Summary: Parrot Virtual Machine documentation
+License: Artistic 2.0
+Group: Development/Libraries
+BuildRequires: /usr/bin/perldoc
+
+%package devel
+Summary: Parrot Virtual Machine development headers and libraries
+License: Artistic 2.0
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: %{_libdir}/pkgconfig
+
+%description
+Parrot is a virtual machine designed to efficiently compile and execute
+bytecode for dynamic languages. Parrot is the target for Rakudo Perl 6,
+as well as variety of other languages.
+
+%description docs
+Documentation in text-, POD- and HTML-format (docs/html-subdirectory) and also
+examples about the Parrot Virtual Machine
+
+%description devel
+Parrot Virtual Machine development headers and libraries.
+
+%prep
+%setup -q
+
+%{__perl} -pi -e 's,"lib/,"%{_lib}/, if (/CONST_STRING\(interp,/)' \
+ src/library.c
+%{__perl} -pi -e "s,'/usr/lib','%{_libdir}',;s,runtime/lib/,runtime/%{_lib}/," \
+ tools/dev/install_files.pl
+
+%build
+
+%ifarch i386 x86_64
+%{__perl} Configure.pl \
+ --prefix=%{_usr} \
+ --libdir=%{_libdir} \
+ --sysconfdir=%{_sysconfdir} \
+ --infodir=%{_datadir}/info \
+ --mandir=%{_mandir} \
+ --cc="%{__cc}" \
+ --cxx=%{__cxx} \
+ --optimize="$RPM_OPT_FLAGS -maccumulate-outgoing-args" \
+ --parrot_is_shared \
+ --lex=/usr/bin/flex \
+ --yacc=/usr/bin/yacc \
+ --libs="-lcurses -lm"
+%else
+# PowerPC
+%{__perl} Configure.pl \
+ --prefix=%{_usr} \
+ --libdir=%{_libdir}
+%endif
+
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make
+make parrot_utils
+make installable
+make html
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make install DESTDIR=$RPM_BUILD_ROOT
+
+# Drop the docs so rpm can pick them up itself.
+rm -rf $RPM_BUILD_ROOT%{_usr}/share/doc/parrot # necessary for SuSE
+#rm -rf $RPM_BUILD_ROOT/%{_docdir}/parrot # for Solaris?
+
+# Force permissions on doc directories.
+find docs examples -type d -exec chmod 755 {} \;
+find docs examples -type f -exec chmod 644 {} \;
+
+# Force permissions on shared libs so they get stripped.
+find $RPM_BUILD_ROOT%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) \
+ -exec chmod 755 {} \;
+
+# These files *probably* aren't needed.
+rm -rf $RPM_BUILD_ROOT%{_usr}/config \
+ $RPM_BUILD_ROOT%{_includedir}/src \
+ $RPM_BUILD_ROOT%{_usr}/src \
+ $RPM_BUILD_ROOT%{_usr}/tools
+
+%check
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+# make test < /dev/null
+# %{?_with_fulltest:make fulltest < /dev/null}
+# make test || :
+# %{?_with_fulltest:make fulltest || :}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%exclude %{_bindir}/parrot_config
+%exclude %{_bindir}/parrot_debugger
+%exclude %{_bindir}/pbc_*
+%{_bindir}/*
+%{_libdir}/parrot
+%{_libdir}/libparrot.so.*
+
+%files docs
+%defattr(-,root,root,-)
+%doc ChangeLog CREDITS NEWS PBC_COMPAT PLATFORMS README
+%doc RESPONSIBLE_PARTIES TODO
+%doc docs examples
+
+%files devel
+%defattr(-,root,root,-)
+%{_bindir}/parrot_config
+%{_bindir}/parrot_debugger
+%{_bindir}/pbc_disassemble
+%{_bindir}/pbc_info
+%{_bindir}/pbc_merge
+%{_bindir}/pbc_to_exe
+%{_bindir}/pbc_dump
+%{_includedir}/parrot
+%{_libdir}/libparrot.so
+%{_libdir}/libparrot.a
+%{_libdir}/pkgconfig/*
+
+%changelog
+* Tue Apr 21 2009 Francois Perrad <francois.perrad at gadz.org> 1.1.0
+- updated to 1.1.0
+
+* Tue Mar 17 2009 Allison Randal <allison at parrot.org> 1.0.0
+- updated to 1.0.0
+
+* Tue Jan 23 2009 Reini Urban <rurban at x-ray.at> 0.9.0
+- added make installable, perl6 is still not installable
+- added parrot_utils to devel
+- fixed Source0 url
+
+* Tue Jan 23 2009 Gerd Pokorra <gp at zimt.uni-siegen.de> 0.9.0
+- added make html
+- make reallyinstall => make install
+
+* Tue Jan 20 2009 chromatic <chromatic at wgz.org> 0.9.0
+- updated to 0.9.0
+
+* Tue Dec 16 2008 Whiteknight <wknight8111 at gmail.com> 0.8.2
+- updated to 0.8.2
+
+* Tue Nov 18 2008 chromatic <chromatic at parrot.org> 0.8.1
+- updated to 0.8.1
+
+* Tue Oct 21 2008 particle <particle at parrot.org> 0.8.0
+- updated to 0.8.0
+
+* Tue Sep 16 2008 pmichaud <pmichaud at pobox.com> 0.7.1
+- updated to 0.7.1
+
+* Wed Sep 3 2008 chromatic <chromatic at wgz.org> 0.7.0
+- install parrot_config (not parrot-config)
+
+* Tue Jun 17 2008 Nuno Carvalho <smash at cpan.org> 0.6.3
+- updated to 0.6.3
+
+* Tue May 20 2008 chromatic <chromatic at wgz.org>> 0.6.2
+- updated to 0.6.2
+
+* Mon Apr 28 2008 chromatic <chromatic at wgz.org> 0.6.1
+- minor fixes; tested with Fedora 7, 8, and 9-beta
+
+* Tue Mar 18 2008 Bernhard Schmalhofer <Bernhard.Schmalhofer at gmx.de> 0.6.0
+- Update to 0.5.3.
+
+* Wed Feb 20 2008 Patrick Michaud <pmichaud at pobox.com> 0.5.3
+- Update to 0.5.3.
+
+* Tue Jan 15 2008 Bob Rogers <rogers at rgrjr.dyndns.org> 0.5.2
+- Update to 0.5.2.
+
+* Tue Dec 18 2007 Jonathan Worthington <jnthn at jnthn.net> 0.5.1
+- Update to 0.5.1.
+
+* Tue Nov 20 2007 chromatic <chromatic at wgz.org> 0.5.0
+- Update to 0.5.0.
+
+* Fri May 25 2007 David Fetter <david at fetter.org> 0.4.12-1
+- Update to 0.4.12.
+
+* Wed Apr 18 2007 Steven Pritchard <steve at kspei.com> 0.4.11-1
+- Update to 0.4.11.
+
+* Wed Mar 21 2007 Steven Pritchard <steve at kspei.com> 0.4.10-1
+- Update to 0.4.10.
+
+* Sat Mar 10 2007 Steven Pritchard <steve at kspei.com> 0.4.9-1
+- Update to 0.4.9.
+- BR ncurses-devel.
+- For some reason now I need to force -lm too.
+- Remove some files/directories that shouldn't be included.
+
+* Wed Jan 17 2007 Steven Pritchard <steve at kspei.com> 0.4.8-1
+- Attempt update to 0.4.8.
+
+* Fri Jun 30 2006 Steven Pritchard <steve at kspei.com> 0.4.5-5
+- Override lib_dir and make various substitutions to try to fix multilib.
+- Remove rpath use from Makefile.
+- Fix a pod error in src/ops/experimental.ops.
+- Enable "make test" since t/doc/pod.t won't fail now.
+
+* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-4
+- Force permissions on shared libraries so rpmbuild strips them.
+
+* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-3
+- Fix URL, description, summary, etc.
+- Add post/postun.
+- Move parrot-config to the devel sub-package.
+- Force permissions on the doc directories.
+
+* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-2
+- Add -lcurses to get readline detection to work.
+- BR libicu-devel.
+
+* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-1
+- Initial packaging attempt.
+
+* Tue Mar 18 2003 Steve Fink <sfink at foxglove.localdomain> 0.0.11
+- first .spec file created
Copied: branches/headercleanup/ports/mandriva/parrot.spec.mandriva (from r38253, trunk/ports/mandriva/parrot.spec.mandriva)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/ports/mandriva/parrot.spec.mandriva Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/ports/mandriva/parrot.spec.mandriva)
@@ -0,0 +1,168 @@
+%define name parrot
+%define version 0.9.1
+%define release %mkrel 2
+
+%define libname %mklibname %{name}
+%define libname_devel %mklibname -d %{name}
+
+Summary: Parrot Virtual Machine
+Name: %name
+Version: %version
+Release: %release
+Source0: ftp://ftp.parrot.org/pub/parrot/releases/devel/%{version}/%{name}-%{version}.tar.gz
+License: Artistic 2.0
+Group: Development/Perl
+Url: http://www.parrot.org/
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+BuildRequires: readline-devel
+BuildRequires: ncurses-devel
+BuildRequires: gmp-devel
+BuildRequires: gdbm-devel
+BuildRequires: perl-doc
+BuildRequires: libicu-devel
+
+%description
+Parrot is a virtual machine designed to efficiently compile and execute
+bytecode for interpreted languages. Parrot will be the target for the final
+Perl 6 compiler, and is already usable as a backend for Pugs, as well as
+variety of other languages
+
+#--
+
+%package -n %libname
+Summary: Parrot Virtual Machine run time library
+License: Artistic 2.0
+Group: Development/Perl
+Provides: lib%{name} = %{version}-%{release}
+Requires: %{name} = %{version}-%{release}
+Requires: %{_libdir}/pkgconfig
+
+%description -n %libname
+Run time library for %{name}.
+
+#--
+
+%package -n %{name}-doc
+Summary: Parrot Virtual Machine documentation
+License: Artistic 2.0
+Group: Development/Perl
+
+%description -n %{name}-doc
+Documentation for %{name}.
+
+#--
+
+%package -n %libname_devel
+Summary: Parrot Virtual Machine development headers and libraries
+License: Artistic 2.0
+Group: Development/Perl
+Provides: %{name}-devel = %version-%release
+Requires: %libname = %version
+
+%description -n %libname_devel
+Development files for %{name}.
+
+%prep
+%setup -q
+
+%{__perl} -pi -e 's,"lib/,"%{_lib}/, if (/CONST_STRING\(interp,/)' \
+ src/library.c
+%{__perl} -pi -e "s,'/usr/lib','%{_libdir}',;s,runtime/lib/,runtime/%{_lib}/," \
+ tools/dev/install_files.pl \
+ tools/dev/mk_manifest_and_skip.pl
+
+%build
+%{__perl} Configure.pl \
+ --prefix=%{_usr} \
+ --libdir=%{_libdir} \
+ --sysconfdir=%{_sysconfdir} \
+ --infodir=%{_datadir}/info \
+ --mandir=%{_mandir} \
+ --cc="%{__cc}" \
+ --cxx=%{__cxx} \
+ --parrot_is_shared \
+ --lex=/usr/bin/flex \
+ --yacc=/usr/bin/yacc \
+ --libs='-lcurses -lm'
+
+# the following Configure.pl flag makes the compile goes boom
+ #--optimize="$RPM_OPT_FLAGS -maccumulate-outgoing-args" \
+
+make
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make languages
+make parrot_utils
+make installable
+make html
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make install DESTDIR=$RPM_BUILD_ROOT
+
+# Drop the docs so rpm can pick them up itself.
+rm -rf $RPM_BUILD_ROOT/%{_docdir}/parrot
+
+# Force permissions on doc directories.
+find docs examples -type d -exec chmod 755 {} \;
+find docs examples -type f -exec chmod 644 {} \;
+
+# Force permissions on shared libs so they get stripped.
+find $RPM_BUILD_ROOT%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) \
+ -exec chmod 755 {} \;
+
+# These files *probably* aren't needed.
+rm -rf $RPM_BUILD_ROOT%{_usr}/config \
+ $RPM_BUILD_ROOT%{_includedir}/src \
+ $RPM_BUILD_ROOT%{_usr}/src \
+ $RPM_BUILD_ROOT%{_usr}/tools
+
+
+%check
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+#make test
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%if %mdkversion < 200900
+%post -n %libname -p /sbin/ldconfig
+%endif
+
+%if %mdkversion < 200900
+%postun -n %libname -p /sbin/ldconfig
+%endif
+
+%files
+%defattr(-,root,root,-)
+%doc ChangeLog CREDITS NEWS PBC_COMPAT PLATFORMS README
+%doc RESPONSIBLE_PARTIES TODO
+%exclude %{_bindir}/parrot_config
+%exclude %{_bindir}/parrot_debugger
+%exclude %{_bindir}/pbc_*
+%{_bindir}/*
+
+%files -n %{name}-doc
+%defattr(-,root,root,-)
+%doc docs examples
+
+%files -n %libname
+%defattr(-,root,root,-)
+%{_libdir}/parrot
+%{_libdir}/*.so.*
+
+%files -n %libname_devel
+%defattr(-,root,root,-)
+%{_bindir}/parrot_config
+%{_bindir}/parrot_debugger
+%{_bindir}/pbc_disassemble
+%{_bindir}/pbc_info
+%{_bindir}/pbc_merge
+%{_bindir}/pbc_to_exe
+%{_bindir}/pbc_dump
+%{_includedir}/*
+%{_libdir}/pkgconfig/*
+%_libdir/*.so
+%_libdir/*.a
Copied: branches/headercleanup/ports/suse/parrot.spec.suse (from r38253, trunk/ports/suse/parrot.spec.suse)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/ports/suse/parrot.spec.suse Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/ports/suse/parrot.spec.suse)
@@ -0,0 +1,245 @@
+Name: parrot
+Version: 1.1.0
+Release: 1%{dist}
+Summary: Parrot Virtual Machine
+License: Artistic 2.0
+Group: Development/Libraries
+URL: http://www.parrot.org/
+Source0: ftp://ftp.parrot.org/pub/parrot/releases/stable/%{version}/parrot-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: readline-devel
+BuildRequires: ncurses-devel
+BuildRequires: gmp-devel
+BuildRequires: gdbm-devel
+BuildRequires: libicu-devel
+BuildRequires: perl-Test-Harness
+
+%package docs
+Summary: Parrot Virtual Machine documentation
+License: Artistic 2.0
+Group: Development/Libraries
+BuildRequires: /usr/bin/perldoc
+
+%package devel
+Summary: Parrot Virtual Machine development headers and libraries
+License: Artistic 2.0
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: %{_libdir}/pkgconfig
+
+%description
+Parrot is a virtual machine designed to efficiently compile and execute
+bytecode for dynamic languages. Parrot is the target for Rakudo Perl 6,
+as well as variety of other languages.
+
+%description docs
+Documentation in text-, POD- and HTML-format (docs/html-subdirectory) and also
+examples about the Parrot Virtual Machine
+
+%description devel
+Parrot Virtual Machine development headers and libraries.
+
+%prep
+%setup -q
+
+%{__perl} -pi -e 's,"lib/,"%{_lib}/, if (/CONST_STRING\(interp,/)' \
+ src/library.c
+%{__perl} -pi -e "s,'/usr/lib','%{_libdir}',;s,runtime/lib/,runtime/%{_lib}/," \
+ tools/dev/install_files.pl
+
+%build
+
+%ifarch i386 x86_64
+%{__perl} Configure.pl \
+ --prefix=%{_usr} \
+ --libdir=%{_libdir} \
+ --sysconfdir=%{_sysconfdir} \
+ --infodir=%{_datadir}/info \
+ --mandir=%{_mandir} \
+ --cc="%{__cc}" \
+ --cxx=%{__cxx} \
+ --optimize="$RPM_OPT_FLAGS -maccumulate-outgoing-args" \
+ --parrot_is_shared \
+ --lex=/usr/bin/flex \
+ --yacc=/usr/bin/yacc \
+ --libs="-lncurses -lm"
+%else
+# PowerPC
+%{__perl} Configure.pl \
+ --prefix=%{_usr} \
+ --libdir=%{_libdir}
+%endif
+
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make
+make parrot_utils
+make installable
+make html
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+make install DESTDIR=$RPM_BUILD_ROOT
+
+# Drop the docs so rpm can pick them up itself.
+rm -rf $RPM_BUILD_ROOT%{_usr}/share/doc/parrot # necessary for SuSE
+#rm -rf $RPM_BUILD_ROOT/%{_docdir}/parrot # for Solaris?
+
+# Force permissions on doc directories.
+find docs examples -type d -exec chmod 755 {} \;
+find docs examples -type f -exec chmod 644 {} \;
+
+# Force permissions on shared libs so they get stripped.
+find $RPM_BUILD_ROOT%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) \
+ -exec chmod 755 {} \;
+
+# These files *probably* aren't needed.
+rm -rf $RPM_BUILD_ROOT%{_usr}/config \
+ $RPM_BUILD_ROOT%{_includedir}/src \
+ $RPM_BUILD_ROOT%{_usr}/src \
+ $RPM_BUILD_ROOT%{_usr}/tools
+
+%check
+export LD_LIBRARY_PATH=$( pwd )/blib/lib
+# make test < /dev/null
+# %{?_with_fulltest:make fulltest < /dev/null}
+# make test || :
+# %{?_with_fulltest:make fulltest || :}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%exclude %{_bindir}/parrot_config
+%exclude %{_bindir}/parrot_debugger
+%exclude %{_bindir}/pbc_*
+%{_bindir}/*
+%{_libdir}/parrot
+%{_libdir}/libparrot.so.*
+
+%files docs
+%defattr(-,root,root,-)
+%doc ChangeLog CREDITS NEWS PBC_COMPAT PLATFORMS README
+%doc RESPONSIBLE_PARTIES TODO
+%doc docs examples
+
+%files devel
+%defattr(-,root,root,-)
+%{_bindir}/parrot_config
+%{_bindir}/parrot_debugger
+%{_bindir}/pbc_disassemble
+%{_bindir}/pbc_info
+%{_bindir}/pbc_merge
+%{_bindir}/pbc_to_exe
+%{_bindir}/pbc_dump
+%{_includedir}/parrot
+%{_libdir}/libparrot.so
+%{_libdir}/libparrot.a
+%{_libdir}/pkgconfig/*
+
+%changelog
+* Tue Apr 21 2009 Francois Perrad <francois.perrad at gadz.org> 1.1.0
+- updated to 1.1.0
+
+* Tue Mar 17 2009 Allison Randal <allison at parrot.org> 1.0.0
+- updated to 1.0.0
+
+* Tue Jan 23 2009 Reini Urban <rurban at x-ray.at> 0.9.0
+- added make installable, perl6 is still not installable
+- added parrot_utils to devel
+- fixed Source0 url
+
+* Tue Jan 23 2009 Gerd Pokorra <gp at zimt.uni-siegen.de> 0.9.0
+- added make html
+- make reallyinstall => make install
+
+* Tue Jan 20 2009 chromatic <chromatic at wgz.org> 0.9.0
+- updated to 0.9.0
+
+* Tue Dec 16 2008 Whiteknight <wknight8111 at gmail.com> 0.8.2
+- updated to 0.8.2
+
+* Tue Nov 18 2008 chromatic <chromatic at parrot.org> 0.8.1
+- updated to 0.8.1
+
+* Tue Oct 21 2008 particle <particle at parrot.org> 0.8.0
+- updated to 0.8.0
+
+* Tue Sep 16 2008 pmichaud <pmichaud at pobox.com> 0.7.1
+- updated to 0.7.1
+
+* Wed Sep 3 2008 chromatic <chromatic at wgz.org> 0.7.0
+- install parrot_config (not parrot-config)
+
+* Tue Jun 17 2008 Nuno Carvalho <smash at cpan.org> 0.6.3
+- updated to 0.6.3
+
+* Tue May 20 2008 chromatic <chromatic at wgz.org>> 0.6.2
+- updated to 0.6.2
+
+* Mon Apr 28 2008 chromatic <chromatic at wgz.org> 0.6.1
+- minor fixes; tested with Fedora 7, 8, and 9-beta
+
+* Tue Mar 18 2008 Bernhard Schmalhofer <Bernhard.Schmalhofer at gmx.de> 0.6.0
+- Update to 0.5.3.
+
+* Wed Feb 20 2008 Patrick Michaud <pmichaud at pobox.com> 0.5.3
+- Update to 0.5.3.
+
+* Tue Jan 15 2008 Bob Rogers <rogers at rgrjr.dyndns.org> 0.5.2
+- Update to 0.5.2.
+
+* Tue Dec 18 2007 Jonathan Worthington <jnthn at jnthn.net> 0.5.1
+- Update to 0.5.1.
+
+* Tue Nov 20 2007 chromatic <chromatic at wgz.org> 0.5.0
+- Update to 0.5.0.
+
+* Fri May 25 2007 David Fetter <david at fetter.org> 0.4.12-1
+- Update to 0.4.12.
+
+* Wed Apr 18 2007 Steven Pritchard <steve at kspei.com> 0.4.11-1
+- Update to 0.4.11.
+
+* Wed Mar 21 2007 Steven Pritchard <steve at kspei.com> 0.4.10-1
+- Update to 0.4.10.
+
+* Sat Mar 10 2007 Steven Pritchard <steve at kspei.com> 0.4.9-1
+- Update to 0.4.9.
+- BR ncurses-devel.
+- For some reason now I need to force -lm too.
+- Remove some files/directories that shouldn't be included.
+
+* Wed Jan 17 2007 Steven Pritchard <steve at kspei.com> 0.4.8-1
+- Attempt update to 0.4.8.
+
+* Fri Jun 30 2006 Steven Pritchard <steve at kspei.com> 0.4.5-5
+- Override lib_dir and make various substitutions to try to fix multilib.
+- Remove rpath use from Makefile.
+- Fix a pod error in src/ops/experimental.ops.
+- Enable "make test" since t/doc/pod.t won't fail now.
+
+* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-4
+- Force permissions on shared libraries so rpmbuild strips them.
+
+* Wed Jun 28 2006 Steven Pritchard <steve at kspei.com> 0.4.5-3
+- Fix URL, description, summary, etc.
+- Add post/postun.
+- Move parrot-config to the devel sub-package.
+- Force permissions on the doc directories.
+
+* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-2
+- Add -lcurses to get readline detection to work.
+- BR libicu-devel.
+
+* Tue Jun 27 2006 Steven Pritchard <steve at kspei.com> 0.4.5-1
+- Initial packaging attempt.
+
+* Tue Mar 18 2003 Steve Fink <sfink at foxglove.localdomain> 0.0.11
+- first .spec file created
Modified: branches/headercleanup/runtime/parrot/library/P6object.pir
==============================================================================
--- branches/headercleanup/runtime/parrot/library/P6object.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/runtime/parrot/library/P6object.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -672,24 +672,25 @@
.param pmc topic
.local pmc topichow, topicwhat, parrotclass
+ $P0 = self.'HOW'()
+ parrotclass = $P0.'get_parrotclass'(self)
+
+ $S0 = parrotclass
+ if $S0 == 'Perl6Object' goto accept_anyway
+
+ $I0 = isa topic, 'Junction'
+ if $I0 goto normal_check
+
+ if $S0 == 'Any' goto accept_anyway
+
+ normal_check:
+ $I0 = can topic, 'HOW'
+ unless $I0 goto end
topichow = topic.'HOW'()
topicwhat = topic.'WHAT'()
- parrotclass = topichow.'get_parrotclass'(self)
$I0 = isa topicwhat, parrotclass
if $I0 goto end
$I0 = does topic, parrotclass
- if $I0 goto end
-
- # Here comes some special handling for Perl 6, that really shouldn't be in
- # here; we'll figure out a way to let Perl 6 provide it's own ACCEPTS that
- # does this or, better make it so we don't need to do this. The purpose is
- # to make Any accept stuff that doesn't actually inherit from it, aside
- # from Junction, and to make Perl6Object accept anything.
- $S0 = parrotclass
- if $S0 == 'Perl6Object' goto accept_anyway
- if $S0 != 'Any' goto end
- $S0 = topicwhat
- if $S0 != 'Junction' goto accept_anyway
goto end
accept_anyway:
Modified: branches/headercleanup/src/exec_save.c
==============================================================================
--- branches/headercleanup/src/exec_save.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/exec_save.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -150,6 +150,26 @@
# include <elf.h>
# endif
+# if defined(PARROT_PPC)
+# if !defined(R_PPC_ADDR16_HI) && !defined(R_PPC_ADDR16_LO) && \
+ defined(R_PPC_16_HI) && defined(R_PPC_16_LO)
+# define R_PPC_ADDR16_HI R_PPC_16_HI
+# define R_PPC_ADDR16_LO R_PPC_16_LO
+# endif
+ /*
+ * NetBSD/powerpc 3.x and OpenBSD/powerpc doesn't define these constants,
+ * but instead has them as enums, so add some workarounds for those.
+ */
+# if !defined(R_PPC_ADDR16_HI) && !defined(R_PPC_ADDR16_LO) && \
+ (defined(__NetBSD__) || defined(__OpenBSD__))
+# define R_PPC_ADDR16_HI RELOC_16_HI
+# define R_PPC_ADDR16_LO RELOC_16_LO
+# endif
+# if !defined(R_PPC_REL24) && (defined(__NetBSD__) || defined(__OpenBSD__))
+# define R_PPC_REL24 RELOC_REL24
+# endif
+# endif /* PARROT_PPC */
+
/* Add a section to the file
*
* n = Name
Modified: branches/headercleanup/src/hll.c
==============================================================================
--- branches/headercleanup/src/hll.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/hll.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -121,8 +121,8 @@
=item C<void Parrot_init_HLL(PARROT_INTERP)>
-Initialises the HLL_info and HLL_namespace fields. Takes an interpreter and
-calls C<Parrot_register_HLL> to register name within Parrot core.
+Initialises the HLL_info and HLL_namespace fields of the interpreter structure.
+Registers the default HLL namespace "parrot".
=cut
@@ -144,11 +144,13 @@
=item C<INTVAL Parrot_register_HLL(PARROT_INTERP, STRING *hll_name)>
-Return the HLL id if C<hll_name> is already registered in the interpreter.
+Register the HLL with the given STRING name C<hll_name> in the interpreter.
-Otherwise register the HLL C<hll_name> within the interpreter.
-Creates a root namespace for the HLL named C<hll_name>.
-Returns a type ID for this HLL or 0 on error.
+If the HLL has already been registered, the ID of the HLL is returned.
+Otherwise the HLL is registered, a corresponding HLL namespace is created,
+and the HLL ID is returned.
+
+If there is an error, C<-1> is returned.
=cut
@@ -212,9 +214,9 @@
=item C<INTVAL Parrot_register_HLL_lib(PARROT_INTERP, STRING *hll_lib)>
Register an HLL library.
-Takes an interpreter name and a pointer to a library name.
-If the name matches one already registered, return the list position.
-Otherwise, add the entry to the list and return 0.
+Takes a pointer to a library name STRING to add. If the name has already
+been registered the list position of the library in the HLL Info list is
+returned. Otherwise, the library is added to the list and 0 is returned.
=cut
@@ -266,7 +268,9 @@
=item C<INTVAL Parrot_get_HLL_id(PARROT_INTERP, STRING *hll_name)>
-Return the ID of the given HLL name or -1 on error. C<parrot> has ID 0.
+Returns the ID number of the HLL with the given name. The default HLL namespace
+C<parrot> has an ID number of 0. On error, or if an HLL with the given name
+does not exist, returns -1.
=cut
@@ -300,10 +304,9 @@
=item C<STRING * Parrot_get_HLL_name(PARROT_INTERP, INTVAL id)>
-Returns the corresponding PMC's name.
-Takes an interpreter name and an id.
-If the id is out of range, or the PMC name is NULL,
-returns NULL.
+Returns the STRING name of the HLL with the given C<id> number. If the id
+is out of range or does not exist, the NULL value is returned instead. Note
+that some HLLs are anonymous and so might also return NULL.
=cut
@@ -436,8 +439,8 @@
=item C<INTVAL Parrot_get_ctx_HLL_type(PARROT_INTERP, INTVAL core_type)>
-Return an equivalent PMC type number according to the current HLL setings in
-the context. If no type is registered, returns C<core_type>.
+Return an equivalent PMC type number according to the HLL settings in
+the current context. If no type is registered, returns C<core_type>.
=cut
Modified: branches/headercleanup/src/jit/ppc/asm.s
==============================================================================
--- branches/headercleanup/src/jit/ppc/asm.s Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/jit/ppc/asm.s Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,8 +1,33 @@
.text
.align 12
+#if !defined(__NetBSD__) && !defined(__OpenBSD__)
.globl _Parrot_ppc_jit_restore_nonvolatile_registers
_Parrot_ppc_jit_restore_nonvolatile_registers:
+#else
+ .globl Parrot_ppc_jit_restore_nonvolatile_registers
+Parrot_ppc_jit_restore_nonvolatile_registers:
+#endif
+#if defined(__NetBSD__) || defined(__OpenBSD__)
+ lfd %f14,-84(%r1)
+ lfd %f15,-92(%r1)
+ lfd %f16,-100(%r1)
+ lfd %f17,-108(%r1)
+ lfd %f18,-116(%r1)
+ lfd %f19,-124(%r1)
+ lfd %f20,-132(%r1)
+ lfd %f21,-140(%r1)
+ lfd %f22,-148(%r1)
+ lfd %f23,-156(%r1)
+ lfd %f24,-164(%r1)
+ lfd %f25,-172(%r1)
+ lfd %f26,-180(%r1)
+ lfd %f27,-188(%r1)
+ lfd %f28,-196(%r1)
+ lfd %f29,-204(%r1)
+ lfd %f30,-212(%r1)
+ lfd %f31,-220(%r1)
+#else /* !__NetBSD__ && !__OpenBSD__ */
lfd f14,-84(r1)
lfd f15,-92(r1)
lfd f16,-100(r1)
@@ -21,5 +46,6 @@
lfd f29,-204(r1)
lfd f30,-212(r1)
lfd f31,-220(r1)
+#endif /* __NetBSD__ || __OpenBSD__ */
blr
Modified: branches/headercleanup/src/multidispatch.c
==============================================================================
--- branches/headercleanup/src/multidispatch.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/multidispatch.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -154,16 +154,6 @@
__attribute__nonnull__(2)
__attribute__nonnull__(3);
-static void Parrot_mmd_search_classes(PARROT_INTERP,
- ARGIN(STRING *meth),
- ARGIN(PMC *arg_tuple),
- ARGIN(PMC *cl),
- INTVAL start_at_parent)
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4);
-
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static PMC* Parrot_mmd_search_scopes(PARROT_INTERP, ARGIN(STRING *meth))
@@ -234,11 +224,6 @@
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(pmc) \
|| PARROT_ASSERT_ARG(cl)
-#define ASSERT_ARGS_Parrot_mmd_search_classes __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(meth) \
- || PARROT_ASSERT_ARG(arg_tuple) \
- || PARROT_ASSERT_ARG(cl)
#define ASSERT_ARGS_Parrot_mmd_search_scopes __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(meth)
@@ -548,65 +533,6 @@
/*
-=item C<static void Parrot_mmd_search_classes(PARROT_INTERP, STRING *meth, PMC
-*arg_tuple, PMC *cl, INTVAL start_at_parent)>
-
-Search all the classes in all MultiSubs of the candidates C<cl> and return
-a list of all candidates. C<start_at_parent> is 0 to start at the class itself
-or 1 to search from the first parent class.
-
-=cut
-
-*/
-
-static void
-Parrot_mmd_search_classes(PARROT_INTERP, ARGIN(STRING *meth),
- ARGIN(PMC *arg_tuple), ARGIN(PMC *cl), INTVAL start_at_parent)
-{
- ASSERT_ARGS(Parrot_mmd_search_classes)
- INTVAL type1;
-
- /* get the class of the first argument */
- if (!VTABLE_elements(interp, arg_tuple))
- return;
-
- type1 = VTABLE_get_integer_keyed_int(interp, arg_tuple, 0);
-
- if (type1 < 0) {
- return;
- /* RT #45947 create some class namespace */
- }
- else {
- PMC * const mro = interp->vtables[type1]->mro;
- const INTVAL n = VTABLE_elements(interp, mro);
- INTVAL i;
-
- for (i = start_at_parent; i < n; ++i) {
- PMC * const _class = VTABLE_get_pmc_keyed_int(interp, mro, i);
- PMC *ns, *methodobj;
-
- if (PObj_is_class_TEST(_class))
- ns = Parrot_oo_get_namespace(interp, _class);
- else
- ns = VTABLE_get_namespace(interp, _class);
-
- methodobj = VTABLE_get_pmc_keyed_str(interp, ns, meth);
-
- if (!PMC_IS_NULL(methodobj)) {
- /*
- * RT #45949 pass current n so that only candidates from this
- * mro are used?
- */
- if (Parrot_mmd_maybe_candidate(interp, methodobj, cl))
- break;
- }
- }
- }
-}
-
-
-/*
-
=item C<static INTVAL distance_cmp(PARROT_INTERP, INTVAL a, INTVAL b)>
=cut
Modified: branches/headercleanup/src/packfile.c
==============================================================================
--- branches/headercleanup/src/packfile.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/packfile.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -1831,6 +1831,7 @@
/*const size_t align = 16 / sizeof (opcode_t);*/
PackFile_Segment_pack_func_t f =
self->pf->PackFuncs[self->type].pack;
+ opcode_t * old_cursor; /* Used for filling padding with 0 */
#if TRACE_PACKFILE
PackFile * const pf = self->pf;
#endif
@@ -1842,7 +1843,12 @@
TRACE_PRINTF_ALIGN(("-ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
OFFS(pf, cursor), pf->src, cursor));
+ old_cursor = cursor;
ALIGN_16(self->pf, cursor);
+ /* fill padding with zeros */
+ while (old_cursor != cursor)
+ *old_cursor++ = 0;
+
/*if (align && (cursor - self->pf->src) % align)
cursor += align - (cursor - self->pf->src) % align;*/
TRACE_PRINTF_ALIGN(("+ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
@@ -2298,6 +2304,7 @@
/*const size_t align = 16/sizeof (opcode_t);*/
size_t i;
PackFile * const pf = self->pf;
+ opcode_t * old_cursor; /* Used for filling padding with 0 */
*cursor++ = num_segs;
@@ -2311,7 +2318,11 @@
TRACE_PRINTF_ALIGN(("-ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
OFFS(pf, cursor), pf->src, cursor));
+ old_cursor = cursor;
ALIGN_16(pf, cursor);
+ /* fill padding with zeros */
+ while (old_cursor != cursor)
+ *old_cursor++ = 0;
TRACE_PRINTF_ALIGN(("+ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
OFFS(pf, cursor), pf->src, cursor));
/*if (align && (cursor - self->pf->src) % align)
Modified: branches/headercleanup/src/packfile/pf_items.c
==============================================================================
--- branches/headercleanup/src/packfile/pf_items.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/packfile/pf_items.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -1473,8 +1473,14 @@
PF_store_cstring(ARGOUT(opcode_t *cursor), ARGIN(const char *s))
{
ASSERT_ARGS(PF_store_cstring)
+ /*
+ * This is not very efficient for filling padding with zeros.
+ * But it's more efficient than calculate strlen twice.
+ */
+ size_t store_size = PF_size_cstring(s);
+ memset((char *) cursor, 0, store_size * sizeof (opcode_t));
strcpy((char *) cursor, s);
- return cursor + PF_size_cstring(s);
+ return cursor + store_size;
}
/*
Modified: branches/headercleanup/src/pmc/fixedpmcarray.pmc
==============================================================================
--- branches/headercleanup/src/pmc/fixedpmcarray.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/fixedpmcarray.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -44,7 +44,7 @@
*/
METHOD sort(PMC *cmp_func :optional) {
- const UINTVAL n = (UINTVAL) PMC_size(SELF);
+ const INTVAL n = SELF.elements();
if (n > 1)
Parrot_quicksort(interp, (void **)PMC_array(SELF), n, cmp_func);
Modified: branches/headercleanup/src/pmc/hash.pmc
==============================================================================
--- branches/headercleanup/src/pmc/hash.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/hash.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -28,8 +28,6 @@
Lookup the PMC type which is used for storing native integers.
-RT #46641: PMCs extending Hash should probably register themselves.
-
=cut
*/
@@ -46,8 +44,6 @@
Lookup the PMC type which is used for floating point numbers.
-RT #46641: PMCs extending Hash should probably register themselves.
-
=cut
*/
@@ -63,8 +59,6 @@
Lookup the PMC type which is used for storing strings.
-RT #46641: PMCs extending Hash should probably register themselves.
-
=cut
*/
Modified: branches/headercleanup/src/pmc/namespace.pmc
==============================================================================
--- branches/headercleanup/src/pmc/namespace.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/namespace.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -145,7 +145,6 @@
*/
VTABLE void init() {
- SUPER();
PMC_data(SELF) =
mem_allocate_zeroed_typed(Parrot_NameSpace_attributes);
PARROT_NAMESPACE(SELF)->vtable = PMCNULL;
@@ -189,7 +188,8 @@
*/
VTABLE void destroy() {
- mem_sys_free(PARROT_NAMESPACE(SELF));
+ /* Call Hash.destroy. It will free all memory. */
+ SUPER();
}
/*
Modified: branches/headercleanup/src/pmc/packfile.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfile.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfile.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -22,8 +22,41 @@
#include "parrot/parrot.h"
#include "pmc_packfiledirectory.h"
+/*
+Copy attributes from PackFile* to Packfile PMC.
+*/
+static void
+copy_packfile_header(PARROT_INTERP, PMC *self, PackFile *pf) {
+ Parrot_Packfile_attributes *attrs = PARROT_PACKFILE(self);
+
+ attrs->wordsize = pf->header->wordsize;
+ attrs->byteorder = pf->header->byteorder;
+ attrs->fptype = pf->header->floattype;
+ attrs->version_major = pf->header->major;
+ attrs->version_minor = pf->header->minor;
+ attrs->version_patch = pf->header->patch;
+ attrs->bytecode_major = pf->header->bc_major;
+ attrs->bytecode_minor = pf->header->bc_minor;
+ attrs->uuid_type = pf->header->uuid_type;
+
+ attrs->uuid = Parrot_str_new(interp, (char*)pf->header->uuid_data,
+ pf->header->uuid_size);
+
+}
+
pmclass Packfile {
+ ATTR INTVAL wordsize;
+ ATTR INTVAL byteorder;
+ ATTR INTVAL fptype;
+ ATTR INTVAL version_major;
+ ATTR INTVAL version_minor;
+ ATTR INTVAL version_patch;
+ ATTR INTVAL bytecode_major;
+ ATTR INTVAL bytecode_minor;
+ ATTR INTVAL uuid_type;
+ ATTR STRING *uuid;
+ ATTR PMC *directory;
/*
=item C<void init()>
@@ -34,8 +67,20 @@
*/
VTABLE void init() {
- PObj_active_destroy_SET(SELF);
- PMC_data(SELF) = PackFile_new(interp, 0);
+ Parrot_Packfile_attributes *attrs =
+ mem_allocate_zeroed_typed(Parrot_Packfile_attributes);
+ PackFile *pf;
+
+ attrs->uuid = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
+ attrs->directory = pmc_new(INTERP, enum_class_PackfileDirectory);
+ PMC_data(SELF) = attrs;
+
+ /* Create dummy PackFile and copy default attributes to self */
+ pf = PackFile_new(interp, 0);
+ copy_packfile_header(interp, SELF, pf);
+ PackFile_destroy(interp, pf);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
}
@@ -50,27 +95,68 @@
*/
VTABLE void destroy() {
- PackFile_destroy(interp, PMC_data_typed(SELF, PackFile *));
+ if (PARROT_PACKFILE(SELF)) {
+ mem_sys_free(PARROT_PACKFILE(SELF));
+ PMC_data(SELF) = NULL;
+ }
}
/*
+=item C<void mark()>
+
+Marks the Packfile as alive.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_Packfile_attributes * attrs = PARROT_PACKFILE(SELF);
+
+ if (attrs->uuid)
+ pobject_lives(INTERP, (PObj *)attrs->uuid);
+ if (attrs->directory)
+ pobject_lives(INTERP, (PObj *)attrs->directory);
+ }
+/*
+
=item C<STRING *get_string()>
Return raw serialized PBC file data.
=cut
+Implementation note: all hard stuff done by PackfileDirectory.
+
*/
VTABLE STRING *get_string() {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
- opcode_t length = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
- opcode_t *ptr = (opcode_t*)mem_sys_allocate(length);
- STRING *str;
+ Parrot_Packfile_attributes * attrs = PARROT_PACKFILE(SELF);
+ PackFile * pf =
+ (PackFile*)VTABLE_get_pointer(interp, attrs->directory);
+
+ opcode_t length;
+ opcode_t *ptr;
+ STRING *str;
+
+ /* Calculate required memory */
+ length = PackFile_pack_size(interp, pf) * sizeof (opcode_t);
+ ptr = (opcode_t*)mem_sys_allocate(length);
+
+ /* Copy related attributes to header */
+ pf->header->major = attrs->version_major;
+ pf->header->minor = attrs->version_minor;
+ pf->header->patch = attrs->version_patch;
+ pf->header->uuid_type = attrs->uuid_type;
+
+ /* And pack it! */
PackFile_pack(interp, pf, ptr);
+
str = Parrot_str_new_init(interp, (const char*)ptr, length,
PARROT_FIXED_8_ENCODING, PARROT_BINARY_CHARSET, 0);
mem_sys_free(ptr);
+
+ PackFile_destroy(interp, pf);
return str;
}
@@ -85,15 +171,24 @@
Implementation note: taken from the bottom end of Parrot_pbc_read().
*/
VTABLE void set_string_native(STRING *str) {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
- const opcode_t *ptr = (const opcode_t*)Parrot_string_cstring(interp, str);
- int length = Parrot_str_byte_length(interp, str);
- if (!PackFile_unpack(interp, pf, ptr, length))
+ PackFile *pf = PackFile_new(interp, 0);
+ const opcode_t *ptr =
+ (const opcode_t*)Parrot_string_cstring(interp, str);
+ int length = Parrot_str_byte_length(interp, str);
+ Parrot_Packfile_attributes * attrs = PARROT_PACKFILE(SELF);
+
+ if (!PackFile_unpack(interp, pf, ptr, length)) {
+ PackFile_destroy(interp, pf);
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_MALFORMED_PACKFILE,
"Can't unpack packfile.");
+ }
+
+ /* Copy values from PackFile header to own attributes */
+ copy_packfile_header(interp, SELF, pf);
- /* Set :main routine */
- do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
+ VTABLE_set_pointer(interp, attrs->directory, &pf->directory);
+
+ PackFile_destroy(interp, pf);
}
@@ -131,27 +226,25 @@
*/
VTABLE INTVAL get_integer_keyed_str(STRING *key) {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
+ Parrot_Packfile_attributes *attrs = PARROT_PACKFILE(SELF);
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "wordsize")))
- return pf->header->wordsize;
+ return attrs->wordsize;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "byteorder")))
- return pf->header->byteorder;
+ return attrs->byteorder;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "fptype")))
- return pf->header->floattype;
+ return attrs->fptype;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_major")))
- return pf->header->major;
+ return attrs->version_major;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_minor")))
- return pf->header->minor;
+ return attrs->version_minor;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_patch")))
- return pf->header->patch;
+ return attrs->version_patch;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "bytecode_major")))
- return pf->header->bc_major;
+ return attrs->bytecode_major;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "bytecode_minor")))
- return pf->header->bc_minor;
+ return attrs->bytecode_minor;
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid_type")))
- return pf->header->uuid_type;
- if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid_length")))
- return pf->header->uuid_size;
+ return attrs->uuid_type;
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND,
"Packfile: No such integer key \"%s\"",
@@ -174,9 +267,8 @@
*/
VTABLE STRING *get_string_keyed_str(STRING *key) {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid")))
- return Parrot_str_new(interp, (char*)pf->header->uuid_data, pf->header->uuid_size);
+ return PARROT_PACKFILE(SELF)->uuid;
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND,
"Packfile: No such string key \"%s\"",
@@ -237,21 +329,21 @@
*/
VTABLE void set_integer_keyed_str(STRING *key, INTVAL value) {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
+ Parrot_Packfile_attributes *attrs = PARROT_PACKFILE(SELF);
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_major"))) {
- pf->header->major = value;
+ attrs->version_major = value;
return;
}
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_minor"))) {
- pf->header->minor = value;
+ attrs->version_minor = value;
return;
}
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "version_patch"))) {
- pf->header->patch = value;
+ attrs->version_patch = value;
return;
}
if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid_type"))) {
- pf->header->uuid_type = value;
+ attrs->uuid_type = value;
return;
}
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND,
@@ -275,6 +367,79 @@
SELF.set_integer_keyed_str(s, val);
}
+/*
+
+=item * C<get_string_keyed_str> (v-table)
+
+Used to get data about fields in the header that have a string value. Valid
+keys are:
+
+=over 4
+
+=item uuid
+
+=back
+
+=cut
+
+*/
+
+ VTABLE void set_string_keyed_str(STRING *key, STRING *value) {
+ if (!Parrot_str_compare(interp, key, CONST_STRING(interp, "uuid"))) {
+ PARROT_PACKFILE(SELF)->uuid = value;
+ return;
+ }
+
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_KEY_NOT_FOUND,
+ "Packfile: No such string key \"%s\"",
+ Parrot_string_cstring(interp, key));
+ }
+
+/*
+
+=item C<void set_string_keyed(PMC *key, STRING *val)>
+
+Set a keyed string value in the packfile object. Dispatches to
+set_string_keyed_str.
+
+=cut
+
+*/
+ VTABLE void set_string_keyed(PMC *key, STRING *val) {
+ STRING * const s = VTABLE_get_string(INTERP, key);
+ SELF.set_string_keyed_str(s, val);
+ }
+
+
+/*
+
+=item C<STRING * pack()>
+
+Return raw serialized PBC file data. Synonym for get_string.
+
+=cut
+
+*/
+
+ METHOD STRING *pack() {
+ STRING * ret = SELF.get_string();
+ RETURN(STRING * ret);
+ }
+
+/*
+
+=item C<STRING * unpack()>
+
+Parse raw serialized PBC file data into the Packfile data structure.
+Synonym for set_string.
+
+=cut
+
+*/
+
+ METHOD void unpack(STRING *str) {
+ SELF.set_string_native(str);
+ }
/*
@@ -287,9 +452,7 @@
*/
METHOD get_directory() {
- PackFile *pf = PMC_data_typed(SELF, PackFile *);
- PMC *dir = pmc_new(interp, enum_class_PackfileDirectory);
- PMC_data(dir) = &pf->directory;
+ PMC *dir = PARROT_PACKFILE(SELF)->directory;
RETURN(PMC *dir);
}
Modified: branches/headercleanup/src/pmc/packfileannotation.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfileannotation.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfileannotation.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -22,7 +22,47 @@
#include "parrot/parrot.h"
pmclass PackfileAnnotation {
+ ATTR INTVAL value;
+ ATTR INTVAL offset;
+ ATTR INTVAL key_id;
+/*
+
+=item C<init>
+
+Create empty PackfileAnnotation.
+
+=cut
+
+*/
+
+ VTABLE void init() {
+ Parrot_PackfileAnnotation_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileAnnotation_attributes);
+
+ PObj_active_destroy_SET(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileAnnotation_attributes * attrs =
+ PARROT_PACKFILEANNOTATION(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
/*
@@ -33,8 +73,9 @@
=cut
*/
- INTVAL get_offset() {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD get_offset() {
+ INTVAL offset = PARROT_PACKFILEANNOTATION(SELF)->offset;
+ RETURN(INTVAL offset);
}
@@ -47,8 +88,8 @@
=cut
*/
- void set_offset(INTVAL offset) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD set_offset(INTVAL offset) {
+ PARROT_PACKFILEANNOTATION(SELF)->offset = offset;
}
@@ -61,22 +102,23 @@
=cut
*/
- INTVAL get_key_id() {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD get_key_id() {
+ INTVAL key_id = PARROT_PACKFILEANNOTATION(SELF)->key_id;
+ RETURN(INTVAL key_id);
}
/*
-=item C<void set_key_id(INTVAL offset)>
+=item C<void set_key_id(INTVAL key_id)>
Set the ID of the key of the annotation.
=cut
*/
- void set_key_id(INTVAL offset) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD set_key_id(INTVAL key_id) {
+ PARROT_PACKFILEANNOTATION(SELF)->key_id = key_id;
}
@@ -90,21 +132,21 @@
*/
VTABLE INTVAL get_integer() {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ return PARROT_PACKFILEANNOTATION(SELF)->value;
}
/*
-=item C<void set_integer(INTVAL offset)>
+=item C<void set_integer(INTVAL value)>
Set the value of the annotation.
=cut
*/
- VTABLE void set_integer(INTVAL offset) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ VTABLE void set_integer_native(INTVAL value) {
+ PARROT_PACKFILEANNOTATION(SELF)->value = value;
}
}
Modified: branches/headercleanup/src/pmc/packfileannotationkeys.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfileannotationkeys.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfileannotationkeys.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -26,10 +26,94 @@
#include "parrot/parrot.h"
+/*
+Fetch PackfileConstantTable from PackfileAnnotationKeys.
+Throw exception if table wasn't initilized.
+*/
+static PMC *
+fetch_const_table(PARROT_INTERP, PMC *self) {
+ PMC * table = PARROT_PACKFILEANNOTATIONKEYS(self)->const_table;
+ if (!table)
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_PARROT_USAGE_ERROR, "Wrong Annotation initialization");
+
+ return table;
+}
+
pmclass PackfileAnnotationKeys {
+ /* ConstantTable used for names lookup */
+ ATTR PMC *const_table;
+
+ /* RIA of Names */
+ ATTR PMC *names;
+
+ /* RIA of Types */
+ ATTR PMC *types;
+
+/*
+
+=item C<void init()>
+
+Initialize PackfileAnnotationKeys.
+
+=cut
+
+*/
+ VTABLE void init() {
+ Parrot_PackfileAnnotationKeys_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileAnnotationKeys_attributes);
+
+ attrs->const_table = NULL;
+ attrs->names = pmc_new(interp, enum_class_ResizableIntegerArray);
+ attrs->types = pmc_new(interp, enum_class_ResizableIntegerArray);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
/*
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileAnnotationKeys_attributes * attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+
+ if (attrs->const_table)
+ pobject_lives(interp, (PObj *)attrs->const_table);
+ if (attrs->names)
+ pobject_lives(interp, (PObj *)attrs->names);
+ if (attrs->types)
+ pobject_lives(interp, (PObj *)attrs->types);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileAnnotationKeys_attributes * attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
+/*
+
=item C<STRING *get_string_keyed_int(INTVAL index)>
Fetch the given entry's name key.
@@ -38,7 +122,13 @@
*/
VTABLE STRING *get_string_keyed_int(INTVAL index) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+
+ PMC *const_table = fetch_const_table(interp, SELF);
+ INTVAL const_index = VTABLE_get_integer_keyed_int(interp,
+ attrs->names, index);
+ return VTABLE_get_string_keyed_int(interp, attrs->const_table, const_index);
}
@@ -52,9 +142,18 @@
*/
VTABLE void set_string_keyed_int(INTVAL index, STRING *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
- }
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+ PMC *const_table = fetch_const_table(interp, SELF);
+ INTVAL i;
+
+ /* Store constant into ConstantTable. Don't check for duplicates for now. */
+ i = VTABLE_elements(interp, const_table);
+ VTABLE_set_string_keyed_int(interp, const_table, i, value);
+ /* And store C<i> in names */
+ VTABLE_set_integer_keyed_int(interp, attrs->names, index, i);
+ }
/*
@@ -66,7 +165,13 @@
*/
VTABLE INTVAL get_integer_keyed_int(INTVAL index) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+
+ /* Just ensure sematics */
+ PMC * const_table = fetch_const_table(interp, SELF);
+
+ return VTABLE_get_integer_keyed_int(interp, attrs->types, index);
}
@@ -80,11 +185,96 @@
*/
VTABLE void set_integer_keyed_int(INTVAL index, INTVAL value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+ VTABLE_set_integer_keyed_int(interp, attrs->types, index, value);
+ }
+
+/*
+
+=item C<void set_pointer(void *pointer)>
+
+Initialize from PackFile_Annotation pointer.
+
+=cut
+
+*/
+ VTABLE void set_pointer(void *pointer) {
+ PackFile_Annotations *annotations = (PackFile_Annotations*)pointer;
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+ opcode_t i;
+
+ for (i = 0; i < annotations->num_keys; ++i) {
+ VTABLE_set_integer_keyed_int(interp, attrs->names,
+ i, annotations->keys[i]->name);
+ VTABLE_set_integer_keyed_int(interp, attrs->types,
+ i, annotations->keys[i]->type);
+ }
+ }
+
+/*
+
+=item C<INTVAL elements()>
+
+Get the number of stored Keys.
+
+=cut
+
+*/
+ VTABLE INTVAL elements() {
+ return VTABLE_elements(interp,
+ PARROT_PACKFILEANNOTATIONKEYS(SELF)->names);
}
+/*
+
+=item C<void set_constant_table(PMC *table)>
+
+Set PackfileConstantTable associated with Keys.
+
+=cut
+
+*/
+ METHOD set_constant_table(PMC *table) {
+ PARROT_PACKFILEANNOTATIONKEYS(SELF)->const_table = table;
+ }
+
+/*
+
+=item C<PMC *get_constant_table()>
+
+Get PackfileConstantTable associated with PackfileAnnotationKeys.
+Solely for testing purpose only.
+
+=cut
+
+*/
+ METHOD get_constant_table() {
+ PMC * table = PARROT_PACKFILEANNOTATIONKEYS(SELF)->const_table;
+ if (!table)
+ table = PMCNULL;
+ RETURN(PMC* table);
+ }
+
+/*
+
+=item C<INTVAL get_name_constant(INTVAL index)>
+
+Get constant id used for name at given C<index>.
+
+=cut
+
+*/
+ METHOD get_name_constant(INTVAL index) {
+ Parrot_PackfileAnnotationKeys_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONKEYS(SELF);
+ INTVAL res = VTABLE_get_integer_keyed_int(interp, attrs->names, index);
+ RETURN(INTVAL res);
+ }
}
+
/*
=back
Modified: branches/headercleanup/src/pmc/packfileannotations.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfileannotations.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfileannotations.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -16,6 +16,8 @@
for the list of common methods every packfile segment pmc must implement; see
PDD13 for the design spec.
+To works properly PackfileAnnotations has to be added to PackfileDirectory with
+PackfileConstantTable. Otherwise PackfileAnnotationKey can't be created.
=head2 Methods
@@ -26,9 +28,74 @@
*/
#include "parrot/parrot.h"
+#include "pmc_packfileannotation.h"
pmclass PackfileAnnotations extends PackfileSegment {
+ /* RPA of Annotation */
+ ATTR PMC *annotations;
+ /* AnnotationKeys */
+ ATTR PMC *keys;
+
+/*
+
+=item C<void init()>
+
+Initialize PackfileAnnotations.
+
+=cut
+
+*/
+ VTABLE void init() {
+ Parrot_PackfileAnnotations_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileAnnotations_attributes);
+
+ attrs->annotations = pmc_new(interp, enum_class_ResizablePMCArray);
+ attrs->keys = pmc_new(interp, enum_class_PackfileAnnotationKeys);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileAnnotations_attributes * attrs =
+ PARROT_PACKFILEANNOTATIONS(SELF);
+
+ if (attrs->annotations)
+ pobject_lives(interp, (PObj *)attrs->annotations);
+ if (attrs->keys)
+ pobject_lives(interp, (PObj *)attrs->keys);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileAnnotations_attributes * attrs =
+ PARROT_PACKFILEANNOTATIONS(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
/*
@@ -40,8 +107,9 @@
=cut
*/
- PMC *get_key_list() {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD get_key_list() {
+ PMC * keys = PARROT_PACKFILEANNOTATIONS(SELF)->keys;
+ RETURN(PMC* keys);
}
@@ -55,7 +123,8 @@
*/
VTABLE INTVAL elements() {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ return VTABLE_elements(interp,
+ PARROT_PACKFILEANNOTATIONS(SELF)->annotations);
}
@@ -69,7 +138,8 @@
*/
VTABLE PMC *get_pmc_keyed_int(INTVAL index) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ return VTABLE_get_pmc_keyed_int(interp,
+ PARROT_PACKFILEANNOTATIONS(SELF)->annotations, index);
}
@@ -98,10 +168,128 @@
*/
VTABLE void set_pmc_keyed_int(INTVAL index, PMC *annotation) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ PMC * annotations = PARROT_PACKFILEANNOTATIONS(SELF)->annotations;
+
+ /* TODO: add checks desribed above */
+ VTABLE_set_pmc_keyed_int(interp, annotations, index, annotation);
+ }
+
+/*
+
+=item C<void set_directory()>
+
+Handle setting of ownership.
+
+Find PackfileConstantTable in PackfileDirectory and pass it to
+PackfileAnnotationKeys.
+
+=cut
+
+*/
+
+ METHOD set_directory(PMC *directory) {
+ Parrot_PackfileAnnotations_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONS(SELF);
+ STRING *name;
+ PMC *segment;
+
+ PMC *iter = VTABLE_get_iter(interp, directory);
+ while (VTABLE_get_bool(interp, iter)) {
+ name = VTABLE_shift_string(interp, iter);
+ segment = VTABLE_get_pmc_keyed_str(interp, directory, name);
+ if (VTABLE_isa(interp, segment,
+ Parrot_str_new_constant(interp, "PackfileConstantTable"))) {
+ Parrot_PCCINVOKE(interp, attrs->keys,
+ Parrot_str_new_constant(interp, "set_constant_table"),
+ "P->", segment);
+ break;
+ }
+ }
+ }
+
+/*
+
+=item C<void set_pointer(void *ptr)>
+
+Initialize PackfileAnnotations from PackFile_Annotations*.
+
+=cut
+
+*/
+ VTABLE void set_pointer(void *pointer) {
+ PackFile_Annotations * a = (PackFile_Annotations*)pointer;
+ Parrot_PackfileAnnotations_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONS(SELF);
+ opcode_t i;
+ PMC *annotation;
+ Parrot_PackfileAnnotation_attributes *annotation_attrs;
+
+ /* Initialize Keys */
+ VTABLE_set_pointer(interp, attrs->keys, a);
+
+ /* Copy annotations to own array */
+ VTABLE_set_integer_native(interp, attrs->annotations, a->num_entries);
+ for (i = 0; i < a->num_entries; ++i) {
+ annotation = pmc_new(interp, enum_class_PackfileAnnotation);
+
+ /* Poke directly to annotation attributes. */
+ annotation_attrs = PARROT_PACKFILEANNOTATION(annotation);
+ annotation_attrs->value = a->entries[i]->value;
+ annotation_attrs->key_id = a->entries[i]->key;
+ annotation_attrs->offset = a->entries[i]->bytecode_offset;
+
+ VTABLE_set_pmc_keyed_int(interp, attrs->annotations, i, annotation);
+ }
}
+/*
+=item C<void *get_pointer()>
+
+Create PackFile_Annotations* from self.
+
+=cut
+
+*/
+ VTABLE void *get_pointer() {
+ Parrot_PackfileAnnotations_attributes *attrs =
+ PARROT_PACKFILEANNOTATIONS(SELF);
+ PackFile_Annotations *res = mem_allocate_zeroed_typed(PackFile_Annotations);
+ PMC *entity;
+ Parrot_PackfileAnnotation_attributes *entity_attrs;
+ INTVAL i, num;
+ INTVAL key_type;
+
+ res->base.type = PF_ANNOTATIONS_SEG;
+
+ /* Copy keys */
+ num = VTABLE_elements(interp, attrs->keys);
+ res->num_keys = num;
+ res->keys = mem_allocate_n_typed(num, PackFile_Annotations_Key*);
+ for (i = 0; i < num; ++i) {
+ res->keys[i] = mem_allocate_typed(PackFile_Annotations_Key);
+ Parrot_PCCINVOKE(interp, attrs->keys,
+ Parrot_str_new_constant(interp, "get_name_constant"),
+ "I->I", i, &res->keys[i]->name);
+ res->keys[i]->type = VTABLE_get_integer_keyed_int(interp, attrs->keys, i);
+ }
+
+ /* Copy entities */
+ num = VTABLE_elements(interp, attrs->annotations);
+ res->num_entries = num;
+ res->entries = mem_allocate_n_typed(num, PackFile_Annotations_Entry*);
+ for (i = 0; i < num; ++i) {
+ res->entries[i] = mem_allocate_zeroed_typed(PackFile_Annotations_Entry);
+ entity = VTABLE_get_pmc_keyed_int(interp, attrs->annotations, i);
+ entity_attrs = PARROT_PACKFILEANNOTATION(entity);
+
+ res->entries[i]->bytecode_offset = entity_attrs->offset;
+ res->entries[i]->value = entity_attrs->value;
+ res->entries[i]->key = entity_attrs->key_id;
+ }
+
+ return res;
+ }
}
/*
Modified: branches/headercleanup/src/pmc/packfileconstanttable.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfileconstanttable.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfileconstanttable.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -26,26 +26,176 @@
#include "parrot/parrot.h"
-static PackFile_Constant *
-getconst(PARROT_INTERP, PackFile_ConstTable *table, int index, int type)
-{
- PackFile_Constant *rv;
- if (index < 0 || index >= table->const_count)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "Requested data out of range.");
- rv = table->constants[index];
- if (rv->type != type)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
- "Requested constant of the wrong type.");
- return rv;
-}
+pmclass PackfileConstantTable extends PackfileSegment {
+ /* ResizablePMCArray for storing constants */
+ ATTR PMC *constants;
+ /* ResizableIntegerArray for storing constant types */
+ ATTR PMC *types;
+
+/*
+
+=item C<init>
+
+Create empty PackfileConstantTable.
+
+=cut
+
+*/
+
+ VTABLE void init() {
+ Parrot_PackfileConstantTable_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileConstantTable_attributes);
+
+ attrs->constants = pmc_new(interp, enum_class_ResizablePMCArray);
+ attrs->types = pmc_new(interp, enum_class_ResizableIntegerArray);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+
+ if (attrs->constants)
+ pobject_lives(interp, (PObj *)attrs->constants);
+ if (attrs->types)
+ pobject_lives(interp, (PObj *)attrs->types);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
-pmclass PackfileConstantTable extends PackfileSegment {
/*
+=item C<set_pointer>
+
+Set pointer to underlying PackFile_ConstTable
+
+=cut
+
+*/
+
+ VTABLE void set_pointer(void * pointer) {
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+ const PackFile_ConstTable * const table =
+ (const PackFile_ConstTable *)(pointer);
+ const PackFile_Constant * val;
+ opcode_t i;
+
+ /* Preallocate required amount of memory */
+ VTABLE_set_integer_native(interp, attrs->constants, table->const_count);
+ VTABLE_set_integer_native(interp, attrs->types, table->const_count);
+
+ for (i = 0; i < table->const_count; ++i) {
+ val = table->constants[i];
+ switch (val->type) {
+ case PFC_NONE:
+ break;
+ case PFC_NUMBER:
+ SELF.set_number_keyed_int(i, val->u.number);
+ break;
+ case PFC_STRING:
+ SELF.set_string_keyed_int(i, val->u.string);
+ break;
+ case PFC_KEY:
+ /* fall through */
+ case PFC_PMC:
+ SELF.set_pmc_keyed_int(i, val->u.key);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_MALFORMED_PACKFILE,
+ "Unknown PackFile constant type: %d", val->type);
+ }
+ }
+ }
+
+/*
+
+=item C<void *get_pointer()>
+=cut
+
+*/
+ VTABLE void *get_pointer() {
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+ PackFile_ConstTable * pftable =
+ mem_allocate_zeroed_typed(PackFile_ConstTable);
+ PackFile_Constant * value;
+ opcode_t i;
+
+ pftable->base.type = PF_CONST_SEG;
+
+ /* Copy all constanst with respect of type */
+ pftable->const_count = VTABLE_get_integer(interp, attrs->constants);
+ pftable->constants = mem_allocate_n_typed(pftable->const_count,
+ PackFile_Constant*);
+
+ for (i = 0; i < pftable->const_count; ++i) {
+ value = PackFile_Constant_new(interp);
+ value->type = VTABLE_get_integer_keyed_int(interp, attrs->types, i);
+ switch (value->type) {
+ case PFC_NONE:
+ break;
+ case PFC_NUMBER:
+ value->u.number = VTABLE_get_number_keyed_int(interp,
+ attrs->constants, i);
+ break;
+ case PFC_STRING:
+ value->u.string = VTABLE_get_string_keyed_int(interp,
+ attrs->constants, i);
+ break;
+ case PFC_KEY:
+ case PFC_PMC:
+ value->u.key = VTABLE_get_pmc_keyed_int(interp,
+ attrs->constants, i);
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_MALFORMED_PACKFILE,
+ "Unknown PackFile constant type: %d", value->type);
+ }
+
+ pftable->constants[i] = value;
+ }
+
+ return pftable;
+ }
+
+/*
+
=item C<INTVAL elements()>
Get the number of elements in the array.
@@ -54,8 +204,8 @@
*/
VTABLE INTVAL elements() {
- PackFile_ConstTable *pftable = PMC_data_typed(SELF, PackFile_ConstTable *);
- return pftable->const_count;
+ return VTABLE_elements(interp,
+ PARROT_PACKFILECONSTANTTABLE(SELF)->constants);
}
@@ -70,9 +220,8 @@
*/
VTABLE FLOATVAL get_number_keyed_int(INTVAL index) {
- PackFile_ConstTable *pftable = PMC_data_typed(SELF, PackFile_ConstTable *);
- PackFile_Constant *constant = getconst(interp, pftable, index, PFC_NUMBER);
- return constant->u.number;
+ return VTABLE_get_number_keyed_int(interp,
+ PARROT_PACKFILECONSTANTTABLE(SELF)->constants, index);
}
@@ -87,9 +236,8 @@
*/
VTABLE STRING *get_string_keyed_int(INTVAL index) {
- PackFile_ConstTable *pftable = PMC_data_typed(SELF, PackFile_ConstTable *);
- PackFile_Constant *constant = getconst(interp, pftable, index, PFC_STRING);
- return constant->u.string;
+ return VTABLE_get_string_keyed_int(interp,
+ PARROT_PACKFILECONSTANTTABLE(SELF)->constants, index);
}
@@ -103,15 +251,14 @@
*/
VTABLE PMC *get_pmc_keyed_int(INTVAL index) {
- PackFile_ConstTable *pftable = PMC_data_typed(SELF, PackFile_ConstTable *);
- PackFile_Constant *constant = getconst(interp, pftable, index, PFC_PMC);
- return constant->u.key;
+ return VTABLE_get_pmc_keyed_int(interp,
+ PARROT_PACKFILECONSTANTTABLE(SELF)->constants, index);
}
/*
-=item C<void set_number_keyed_int(INTVAL index, INTVAL value)>
+=item C<void set_number_keyed_int(INTVAL index, FLOATVAL value)>
Set the constant to the given number.
@@ -119,7 +266,11 @@
*/
VTABLE void set_number_keyed_int(INTVAL index, FLOATVAL value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+
+ VTABLE_set_number_keyed_int(interp, attrs->constants, index, value);
+ VTABLE_set_integer_keyed_int(interp, attrs->types, index, PFC_NUMBER);
}
@@ -132,8 +283,13 @@
=cut
*/
+
VTABLE void set_string_keyed_int(INTVAL index, STRING *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+
+ VTABLE_set_string_keyed_int(interp, attrs->constants, index, value);
+ VTABLE_set_integer_keyed_int(interp, attrs->types, index, PFC_STRING);
}
@@ -147,7 +303,15 @@
*/
VTABLE void set_pmc_keyed_int(INTVAL index, PMC *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ Parrot_PackfileConstantTable_attributes * attrs =
+ PARROT_PACKFILECONSTANTTABLE(SELF);
+ opcode_t type = VTABLE_isa(interp, value,
+ Parrot_str_new_constant(interp, "Key"))
+ ? PFC_KEY
+ : PFC_PMC;
+
+ VTABLE_set_pmc_keyed_int(interp, attrs->constants, index, value);
+ VTABLE_set_integer_keyed_int(interp, attrs->types, index, type);
}
@@ -175,14 +339,8 @@
*/
METHOD get_type(INTVAL index) {
- PackFile_ConstTable *pftable = PMC_data_typed(SELF, PackFile_ConstTable *);
- PackFile_Constant *constant;
- INTVAL rv;
- if (index < 0 || index >= pftable->const_count)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "Requested data out of range.");
- constant = pftable->constants[index];
- rv = constant->type;
+ INTVAL rv = VTABLE_get_integer_keyed_int(interp,
+ PARROT_PACKFILECONSTANTTABLE(SELF)->types, index);
RETURN(INTVAL rv);
}
Modified: branches/headercleanup/src/pmc/packfiledirectory.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfiledirectory.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfiledirectory.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -28,90 +28,188 @@
#include "parrot/parrot.h"
pmclass PackfileDirectory extends PackfileSegment {
+ /* Directory is a hash of Segments */
+ ATTR PMC *hash;
+/*
+
+=item C<void init()>
+
+Initialize PackfileDirectory.
+
+=cut
+
+*/
+ VTABLE void init() {
+ Parrot_PackfileDirectory_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileDirectory_attributes);
+
+ attrs->hash = pmc_new(interp, enum_class_Hash);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
/*
-=item C<INTVAL elements()>
+=item C<void mark()>
-Get the number of elements in the array.
+Marks the object as live.
=cut
*/
- VTABLE INTVAL elements() {
- PackFile_Directory *pfd = PMC_data_typed(SELF, PackFile_Directory *);
- return pfd->num_segments;
+
+ VTABLE void mark() {
+ Parrot_PackfileDirectory_attributes * attrs =
+ PARROT_PACKFILEDIRECTORY(SELF);
+
+ if (attrs->hash)
+ pobject_lives(interp, (PObj *)attrs->hash);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileDirectory_attributes * attrs =
+ PARROT_PACKFILEDIRECTORY(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
}
/*
-=item C<PMC *get_pmc_keyed_int(INTVAL index)>
+=item C<void set_pointer(void *ptr)>
-Fetch a segment PMC from the array.
+Initialize PackfileDirectory from PackFile_Directory.
=cut
*/
- VTABLE PMC *get_pmc_keyed_int(INTVAL index) {
- const PackFile_Directory * const pfd = PMC_data_typed(SELF, PackFile_Directory *);
+
+ VTABLE void set_pointer(void *ptr) {
+ const PackFile_Directory * const pfd = (const PackFile_Directory *)ptr;
PackFile_Segment *pfseg;
- PMC *rv;
+ PMC *segment;
int pmc_type;
+ unsigned int i;
+ STRING *name;
+ PMC *hash = PARROT_PACKFILEDIRECTORY(SELF)->hash;
+
+ SUPER(ptr);
+
+ /* Iterate over elements and create corresponded PMCs */
+ for (i=0; i < pfd->num_segments; ++i) {
+ pfseg = pfd->segments[i];
+
+ switch (pfseg->type) {
+ case PF_DIR_SEG:
+ pmc_type = enum_class_PackfileDirectory;
+ break;
+ case PF_FIXUP_SEG:
+ pmc_type = enum_class_PackfileFixupTable;
+ break;
+ case PF_CONST_SEG:
+ pmc_type = enum_class_PackfileConstantTable;
+ break;
+ case PF_ANNOTATIONS_SEG:
+ pmc_type = enum_class_PackfileAnnotations;
+ break;
+ case PF_BYTEC_SEG:
+ case PF_UNKNOWN_SEG:
+ case PF_DEBUG_SEG:
+ default:
+ pmc_type = enum_class_PackfileRawSegment;
+ break;
+ }
- if (index < 0 || index >= (INTVAL)pfd->num_segments)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "PackfileDirectory: index out of bounds!");
-
- pfseg = pfd->segments[index];
-
- switch (pfseg->type) {
- case PF_DIR_SEG:
- pmc_type = enum_class_PackfileDirectory;
- break;
- case PF_FIXUP_SEG:
- pmc_type = enum_class_PackfileFixupTable;
- break;
- case PF_CONST_SEG:
- pmc_type = enum_class_PackfileConstantTable;
- break;
- case PF_BYTEC_SEG:
- case PF_UNKNOWN_SEG:
- case PF_DEBUG_SEG:
- default:
- pmc_type = enum_class_PackfileRawSegment;
- break;
- }
+ segment = pmc_new(interp, pmc_type);
+ name = Parrot_str_new(interp, pfseg->name, strlen(pfseg->name));
+ VTABLE_set_pmc_keyed_str(interp, SELF, name, segment);
- rv = pmc_new(interp, pmc_type);
- PMC_data(rv) = pfseg;
- return rv;
+ /* Initialize internal PMC structure */
+ VTABLE_set_pointer(interp, segment, pfseg);
+
+ }
}
+/*
+
+=item C<void *get_pointer()>
+
+Creates PackFile for given directory.
+
+=cut
+
+*/
+
+ VTABLE void *get_pointer() {
+ Parrot_PackfileDirectory_attributes * attrs =
+ PARROT_PACKFILEDIRECTORY(SELF);
+ PackFile * pf = PackFile_new(interp, 0); /* dummy PackFile... */
+ PackFile_Directory * pfdir = &pf->directory;
+ PackFile_Segment * pfseg;
+ PMC * seg;
+ PMC * iter;
+ STRING * name;
+ STRING * res;
+
+ /* Create Segments. Add to Directory with transfering ownership */
+ iter = VTABLE_get_iter(interp, attrs->hash);
+ while (VTABLE_get_bool(interp, iter)) {
+ name = VTABLE_shift_string(interp, iter);
+ seg = VTABLE_get_pmc_keyed_str(interp, attrs->hash, name);
+ pfseg = (PackFile_Segment*)VTABLE_get_pointer(interp, seg);
+ pfseg->pf = pf;
+ pfseg->name = strdup(Parrot_string_cstring(interp, name));
+ PackFile_add_segment(interp, pfdir, pfseg);
+ }
+
+ return pf;
+ }
/*
-=item C<STRING *get_string_keyed_int(INTVAL index)>
+=item C<INTVAL elements()>
-Fetch a string containing the name of the specified segment PMC.
+Get the number of elements in the array.
=cut
*/
- VTABLE STRING *get_string_keyed_int(INTVAL index) {
- const PackFile_Directory * const pfd = PMC_data_typed(SELF, PackFile_Directory *);
- const PackFile_Segment *pfseg;
- if (index < 0 || index >= (INTVAL)pfd->num_segments)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "PackfileDirectory: index out of bounds!");
- pfseg = pfd->segments[index];
- return Parrot_str_new_constant(interp, pfseg->name);
+ VTABLE INTVAL elements() {
+ return VTABLE_elements(interp, PARROT_PACKFILEDIRECTORY(SELF)->hash);
}
/*
+=item C<PMC *get_iter()>
+
+Return a new iterator for the directory.
+
+=cut
+
+*/
+
+ VTABLE PMC *get_iter() {
+ return VTABLE_get_iter(interp, PARROT_PACKFILEDIRECTORY(SELF)->hash);
+ }
+
+/*
+
=item C<PMC *get_pmc_keyed_str(STRING *name)>
Search the array for a segment with the given name, and return it if it exists.
@@ -120,16 +218,8 @@
*/
VTABLE PMC *get_pmc_keyed_str(STRING *name) {
- const PackFile_Directory * const pfd = PMC_data_typed(SELF, PackFile_Directory *);
- const int total = pfd->num_segments;
- int i;
- for (i = 0; i < total; i++) {
- const PackFile_Segment * const pfseg = pfd->segments[i];
- if (!Parrot_str_compare(interp, name, Parrot_str_new_constant(interp, pfseg->name)))
- return VTABLE_get_pmc_keyed_int(interp, SELF, i);
- }
- /* the specified segment name wasn't found. */
- return PMCNULL;
+ return VTABLE_get_pmc_keyed_str(interp,
+ PARROT_PACKFILEDIRECTORY(SELF)->hash, name);
}
@@ -137,15 +227,15 @@
=item C<PMC *get_pmc_keyed(PMC *key)>
-Fetch a keyed string value from the packfiledirectory object. Dispatches to
-get_pmc_keyed_str.
+Fetch a keyed string value from the packfiledirectory object.
=cut
*/
VTABLE PMC *get_pmc_keyed(PMC *key) {
- STRING * const s = VTABLE_get_string(INTERP, key);
- return SELF.get_pmc_keyed_str(s);
+ STRING *s_key = VTABLE_get_string(interp, key);
+ return VTABLE_get_pmc_keyed_str(interp,
+ PARROT_PACKFILEDIRECTORY(SELF)->hash, s_key);
}
@@ -158,29 +248,27 @@
=cut
+TODO: check type
+
*/
VTABLE void set_pmc_keyed_str(STRING *name, PMC *segment) {
- PackFile_Directory * const pfd = PMC_data_typed(SELF, PackFile_Directory *);
- PackFile_Segment *add_seg = PMC_data_typed(segment, PackFile_Segment *);
+ Parrot_PCCINVOKE(interp, segment,
+ Parrot_str_new_constant(interp, "set_directory"),
+ "P->", SELF);
+ VTABLE_set_pmc_keyed_str(interp,
+ PARROT_PACKFILEDIRECTORY(SELF)->hash, name, segment);
+ }
- const int total = pfd->num_segments;
- int i;
+/*
- for (i = 0; i < total; i++) {
- const PackFile_Segment * const pfseg = pfd->segments[i];
+=item C<PMC *set_pmc_keyed(PMC *key)>
- if (!Parrot_str_compare(interp, name,
- Parrot_str_new_constant(interp, pfseg->name))) {
- add_seg->pf = pfd->base.pf;
- pfd->segments[i] = add_seg;
- return;
- }
- }
+Add a segment with the given name to the directory. Dispatches to
+set_pmc_keyed_str.
- add_seg->name = Parrot_str_to_cstring(interp, name);
- add_seg->pf = pfd->base.pf;
- PackFile_add_segment(interp, pfd, add_seg);
- }
+=cut
+
+*/
VTABLE void set_pmc_keyed(PMC *key, PMC *segment) {
STRING *s_key = VTABLE_get_string(interp, key);
Modified: branches/headercleanup/src/pmc/packfilefixupentry.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfilefixupentry.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfilefixupentry.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -22,6 +22,112 @@
#include "parrot/parrot.h"
pmclass PackfileFixupEntry {
+ ATTR INTVAL type;
+ ATTR STRING *name;
+ ATTR INTVAL offset;
+
+
+/*
+
+=item C<void init()>
+
+Initialize PackfileFixupEntry.
+
+=cut
+
+*/
+ VTABLE void init() {
+ Parrot_PackfileFixupEntry_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileFixupEntry_attributes);
+
+ attrs->name = Parrot_str_new_noinit(interp, enum_stringrep_one, 0);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileFixupEntry_attributes * attrs =
+ PARROT_PACKFILEFIXUPENTRY(SELF);
+
+ if (attrs->name)
+ pobject_lives(interp, (PObj *)attrs->name);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileFixupEntry_attributes * attrs =
+ PARROT_PACKFILEFIXUPENTRY(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
+
+
+/*
+
+=item C<void set_pointer(void *pointer)>
+
+Initialize from PackFile_FixupEntry pointer.
+
+=cut
+
+*/
+
+ VTABLE void set_pointer(void * pointer) {
+ Parrot_PackfileFixupEntry_attributes * attrs =
+ PARROT_PACKFILEFIXUPENTRY(SELF);
+ PackFile_FixupEntry *entry = (PackFile_FixupEntry*)pointer;
+
+ attrs->type = entry->type;
+ attrs->name = Parrot_str_new_init(interp, entry->name,
+ strlen(entry->name), PARROT_FIXED_8_ENCODING,
+ PARROT_BINARY_CHARSET, 0);
+ attrs->offset = entry->offset;
+ }
+
+/*
+
+=item C<void *get_pointer()>
+
+Create PackFile_FixupEntry* from self.
+
+=cut
+
+*/
+ VTABLE void *get_pointer() {
+ Parrot_PackfileFixupEntry_attributes * attrs =
+ PARROT_PACKFILEFIXUPENTRY(SELF);
+ PackFile_FixupEntry * entry =
+ mem_allocate_zeroed_typed(PackFile_FixupEntry);
+
+ entry->type = attrs->type;
+ entry->name = strdup(Parrot_string_cstring(interp, attrs->name));
+ entry->offset = attrs->offset;
+ return entry;
+ }
+
/*
@@ -33,8 +139,7 @@
*/
VTABLE STRING *get_string() {
- PackFile_FixupEntry *pfentry = PMC_data_typed(SELF, PackFile_FixupEntry *);
- return Parrot_str_new(interp, pfentry->name, strlen(pfentry->name));
+ return PARROT_PACKFILEFIXUPENTRY(SELF)->name;
}
/*
@@ -47,7 +152,7 @@
*/
VTABLE void set_string_native(STRING *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ SETATTR_PackfileFixupEntry_name(INTERP, SELF, value);
}
@@ -61,8 +166,7 @@
*/
VTABLE INTVAL get_integer() {
- PackFile_FixupEntry *pfentry = PMC_data_typed(SELF, PackFile_FixupEntry *);
- return pfentry->offset;
+ return PARROT_PACKFILEFIXUPENTRY(SELF)->offset;
}
@@ -76,7 +180,7 @@
*/
VTABLE void set_integer_native(INTVAL offset) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ SETATTR_PackfileFixupEntry_offset(INTERP, SELF, offset);
}
@@ -90,8 +194,7 @@
*/
METHOD get_type() {
- PackFile_FixupEntry *pfentry = PMC_data_typed(SELF, PackFile_FixupEntry *);
- int rv = pfentry->type;
+ INTVAL rv = PARROT_PACKFILEFIXUPENTRY(SELF)->type;
RETURN(INTVAL rv);
}
@@ -105,8 +208,8 @@
=cut
*/
- void set_type(INTVAL offset) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ METHOD set_type(INTVAL type) {
+ SETATTR_PackfileFixupEntry_type(INTERP, SELF, type);
}
}
Modified: branches/headercleanup/src/pmc/packfilefixuptable.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfilefixuptable.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfilefixuptable.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -27,6 +27,130 @@
#include "parrot/parrot.h"
pmclass PackfileFixupTable extends PackfileSegment {
+ /* RPA of entries */
+ ATTR PMC *entries;
+
+/*
+
+=item C<init>
+
+Create empty PackfileFixupTable.
+
+=cut
+
+*/
+
+ VTABLE void init() {
+ Parrot_PackfileFixupTable_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileFixupTable_attributes);
+
+ attrs->entries = pmc_new(interp, enum_class_ResizablePMCArray);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileFixupTable_attributes * attrs =
+ PARROT_PACKFILEFIXUPTABLE(SELF);
+
+ if (attrs->entries)
+ pobject_lives(interp, (PObj *)attrs->entries);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileFixupTable_attributes * attrs =
+ PARROT_PACKFILEFIXUPTABLE(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
+
+
+
+/*
+
+=item C<void set_pointer(void *pointer)>
+
+Initialize from PackFile_FixupTable pointer.
+
+=cut
+
+*/
+
+ VTABLE void set_pointer(void * pointer) {
+ Parrot_PackfileFixupTable_attributes * attrs =
+ PARROT_PACKFILEFIXUPTABLE(SELF);
+ PackFile_FixupTable * table = (PackFile_FixupTable*)pointer;
+
+ PMC *entry;
+ PackFile_FixupEntry *val;
+ opcode_t i;
+
+ VTABLE_set_integer_native(interp, attrs->entries, table->fixup_count);
+
+ for (i = 0; i < table->fixup_count; ++i) {
+ val = table->fixups[i];
+ entry = pmc_new(interp, enum_class_PackfileFixupEntry);
+ VTABLE_set_pointer(interp, entry, (void*)val);
+ VTABLE_set_pmc_keyed_int(interp, attrs->entries, i, entry);
+ }
+ }
+
+/*
+
+=item C<void *get_pointer()>
+
+Create PackFile_FixupTable* from self.
+
+=cut
+
+*/
+ VTABLE void *get_pointer() {
+ Parrot_PackfileFixupTable_attributes * attrs =
+ PARROT_PACKFILEFIXUPTABLE(SELF);
+ PackFile_FixupTable * pftable =
+ mem_allocate_zeroed_typed(PackFile_FixupTable);
+ PMC * entry;
+ PackFile_FixupEntry * val;
+ opcode_t i;
+
+ pftable->base.type = PF_FIXUP_SEG;
+ pftable->fixup_count = VTABLE_elements(interp, attrs->entries);
+ pftable->fixups = mem_allocate_n_typed(pftable->fixup_count,
+ PackFile_FixupEntry*);
+
+ /* Copy all entries */
+ for (i = 0; i < pftable->fixup_count; ++i) {
+ entry = VTABLE_get_pmc_keyed_int(interp, attrs->entries, i);
+ val = (PackFile_FixupEntry*)VTABLE_get_pointer(interp, entry);
+ pftable->fixups[i] = val;
+ }
+
+ return pftable;
+ }
/*
@@ -39,8 +163,8 @@
*/
VTABLE INTVAL elements() {
- PackFile_FixupTable *pftable = PMC_data_typed(SELF, PackFile_FixupTable *);
- return pftable->fixup_count;
+ return VTABLE_elements(interp,
+ PARROT_PACKFILEFIXUPTABLE(SELF)->entries);
}
@@ -54,14 +178,8 @@
*/
VTABLE PMC *get_pmc_keyed_int(INTVAL index) {
- PackFile_FixupTable *pftable = PMC_data_typed(SELF, PackFile_FixupTable *);
- PMC *rv;
- if (index < 0 || index >= pftable->fixup_count)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "Requested data out of range.");
- rv = pmc_new(interp, enum_class_PackfileFixupEntry);
- PMC_data(rv) = pftable->fixups[index];
- return rv;
+ return VTABLE_get_pmc_keyed_int(interp,
+ PARROT_PACKFILEFIXUPTABLE(SELF)->entries, index);
}
@@ -75,7 +193,8 @@
*/
VTABLE void set_pmc_keyed_int(INTVAL index, PMC *value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ VTABLE_set_pmc_keyed_int(interp,
+ PARROT_PACKFILEFIXUPTABLE(SELF)->entries, index, value);
}
Modified: branches/headercleanup/src/pmc/packfilerawsegment.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfilerawsegment.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfilerawsegment.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -27,8 +27,122 @@
#include "parrot/parrot.h"
pmclass PackfileRawSegment extends PackfileSegment {
+ /* ResizableIntegerArray of opcodes */
+ ATTR PMC *opcodes;
+/*
+
+=item C<init>
+
+Create empty PackfileRawSegment.
+
+=cut
+
+*/
+
+ VTABLE void init() {
+ Parrot_PackfileRawSegment_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileRawSegment_attributes);
+
+ attrs->opcodes = pmc_new(interp, enum_class_ResizableIntegerArray);
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
+ }
+
+/*
+
+=item C<void mark()>
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileRawSegment_attributes * attrs =
+ PARROT_PACKFILERAWSEGMENT(SELF);
+
+ if (attrs->opcodes)
+ pobject_lives(interp, (PObj *)attrs->opcodes);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileRawSegment_attributes * attrs =
+ PARROT_PACKFILERAWSEGMENT(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
+
+
+
+/*
+
+=item C<set_pointer>
+
+Initialize PackfileRawSegment from PackFile_Segment
+
+=cut
+
+*/
+
+ VTABLE void set_pointer(void * pointer) {
+ const PackFile_Segment * const pfseg =
+ (const PackFile_Segment *)pointer;
+ PMC * opcodes = PARROT_PACKFILERAWSEGMENT(SELF)->opcodes;
+ size_t i;
+
+ if (pfseg->size) {
+ /* copy data to own array */
+ VTABLE_set_integer_native(interp, opcodes, pfseg->size);
+ /* Not very efficient... */
+ for (i = 0; i < pfseg->size; ++i) {
+ VTABLE_set_integer_keyed_int(interp, opcodes, i, pfseg->data[i]);
+ }
+ }
+ }
+
+/*
+
+=item C<void *get_pointer()>
+
+=cut
+
+*/
+
+ VTABLE void *get_pointer() {
+ PackFile_Segment * pfseg =
+ (PackFile_Segment*)mem_allocate_zeroed_typed(PackFile_ByteCode);
+ Parrot_PackfileRawSegment_attributes * attrs =
+ PARROT_PACKFILERAWSEGMENT(SELF);
+ PMC * opcodes = attrs->opcodes;
+ size_t i;
+
+ pfseg->type = PF_BYTEC_SEG;
+ pfseg->size = VTABLE_get_integer(interp, opcodes);
+ pfseg->data = mem_allocate_n_typed(pfseg->size, opcode_t);
+
+ /* Not very efficient... */
+ for (i = 0; i < pfseg->size; ++i) {
+ pfseg->data[i] = VTABLE_get_integer_keyed_int(interp, opcodes, i);
+ }
+
+ return pfseg;
+ }
/*
=item C<INTVAL elements()>
@@ -39,8 +153,8 @@
*/
VTABLE INTVAL elements() {
- PackFile_Segment *pfseg = PMC_data_typed(SELF, PackFile_Segment *);
- return pfseg->size;
+ return VTABLE_elements(interp,
+ PARROT_PACKFILERAWSEGMENT(SELF)->opcodes);
}
@@ -54,11 +168,8 @@
*/
VTABLE INTVAL get_integer_keyed_int(INTVAL key) {
- PackFile_Segment *pfseg = PMC_data_typed(SELF, PackFile_Segment *);
- if (key < 0 || (UINTVAL)key >= pfseg->size)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_OUT_OF_BOUNDS,
- "Requested data out of range.");
- return pfseg->data[key];
+ return VTABLE_get_integer_keyed_int(interp,
+ PARROT_PACKFILERAWSEGMENT(SELF)->opcodes, key);
}
@@ -72,7 +183,8 @@
*/
VTABLE void set_integer_keyed_int(INTVAL key, INTVAL value) {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED, "Not implemented yet.");
+ VTABLE_set_integer_keyed_int(interp,
+ PARROT_PACKFILERAWSEGMENT(SELF)->opcodes, key, value);
}
Modified: branches/headercleanup/src/pmc/packfilesegment.pmc
==============================================================================
--- branches/headercleanup/src/pmc/packfilesegment.pmc Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/pmc/packfilesegment.pmc Tue Apr 21 21:28:29 2009 (r38254)
@@ -26,23 +26,94 @@
#include "parrot/parrot.h"
pmclass PackfileSegment {
+ /*
+ Directory which owns this segment. Required for correct pack/unpack
+ Annotations.
+ */
+ ATTR PMC *directory;
/*
=item C<void init()>
-Initialize the structure. (Create a blank PackFile_Segment object.)
+Initialize PackfileSegment.
=cut
*/
VTABLE void init() {
- PackFile_Segment *seg = PackFile_Segment_new(interp, NULL, "", 0);
- PMC_data(SELF) = seg;
- seg->type = PF_UNKNOWN_SEG;
+ Parrot_PackfileSegment_attributes * attrs =
+ mem_allocate_zeroed_typed(Parrot_PackfileSegment_attributes);
+
+ attrs->directory = NULL;
+
+ PObj_custom_mark_destroy_SETALL(SELF);
+ PMC_data(SELF) = attrs;
}
+/*
+
+=item C<void mark()>
+
+Marks the object as live.
+
+=cut
+
+*/
+
+ VTABLE void mark() {
+ Parrot_PackfileSegment_attributes * attrs =
+ PARROT_PACKFILESEGMENT(SELF);
+
+ if (attrs->directory)
+ pobject_lives(interp, (PObj *)attrs->directory);
+ }
+
+/*
+
+=item C<void destroy()>
+
+Destroys the PMC and frees all allocated memory.
+
+=cut
+
+*/
+
+ VTABLE void destroy() {
+ Parrot_PackfileSegment_attributes * attrs =
+ PARROT_PACKFILESEGMENT(SELF);
+
+ if (attrs) {
+ mem_sys_free(attrs);
+ PMC_data(SELF) = NULL;
+ }
+ }
+
+/*
+
+=item C<void set_pointer(void *ptr)>
+
+Initialize PMC internals.
+
+=cut
+
+*/
+ VTABLE void set_pointer(void *ptr) {
+ }
+
+/*
+
+=item C<void *get_pointer()>
+
+Initialize PMC internals.
+
+=cut
+
+*/
+ VTABLE void *get_pointer() {
+ return NULL;
+ }
/*
@@ -54,16 +125,8 @@
*/
METHOD pack() {
- PackFile_Segment *pfseg = PMC_data_typed(SELF, PackFile_Segment *);
- opcode_t length = PackFile_Segment_packed_size(interp, pfseg) * sizeof (opcode_t);
- opcode_t *newptr, *ptr = (opcode_t*)mem_sys_allocate(length);
- STRING *str;
- newptr = PackFile_Segment_pack(interp, pfseg, ptr);
- str = Parrot_str_new_init(interp, (const char*)ptr,
- (newptr - ptr) * sizeof (opcode_t),
- PARROT_FIXED_8_ENCODING, PARROT_BINARY_CHARSET, 0);
- mem_sys_free(ptr);
- RETURN(STRING *str);
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
+ "PackfileSegment.pack() not implemented yet.");
}
@@ -81,6 +144,35 @@
"PackfileSegment.unpack() not implemented yet.");
}
+/*
+
+=item C<void set_directory(PMC *directory)>
+
+Set owning directory.
+
+=cut
+
+*/
+ METHOD set_directory(PMC *directory) {
+ PARROT_PACKFILESEGMENT(SELF)->directory = directory;
+ }
+
+/*
+
+=item C<void get_directory(PMC *directory)>
+
+Get owning directory.
+
+=cut
+
+*/
+ METHOD get_directory() {
+ PMC * directory = PARROT_PACKFILESEGMENT(SELF)->directory;
+ if (!directory)
+ directory = PMCNULL;
+ RETURN(PMC* directory);
+ }
+
}
/*
Modified: branches/headercleanup/src/string/charset/unicode.c
==============================================================================
--- branches/headercleanup/src/string/charset/unicode.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/string/charset/unicode.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -47,7 +47,7 @@
static INTVAL cs_rindex(PARROT_INTERP,
SHIM(STRING *source_string),
SHIM(STRING *search_string),
- UINTVAL offset)
+ SHIM(UINTVAL offset))
__attribute__nonnull__(1);
PARROT_CANNOT_RETURN_NULL
Modified: branches/headercleanup/src/string/encoding/ucs2.c
==============================================================================
--- branches/headercleanup/src/string/encoding/ucs2.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/string/encoding/ucs2.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -21,6 +21,16 @@
#include "parrot/parrot.h"
#include "../unicode.h"
+#if !PARROT_HAS_ICU
+PARROT_DOES_NOT_RETURN
+static void no_ICU_lib(PARROT_INTERP) /* HEADERIZER SKIP */
+{
+ Parrot_ex_throw_from_c_args(interp, NULL,
+ EXCEPTION_LIBRARY_ERROR,
+ "no ICU lib loaded");
+}
+#endif
+
/* HEADERIZER HFILE: src/string/encoding/ucs2.h */
/* HEADERIZER BEGIN: static */
@@ -41,23 +51,23 @@
static UINTVAL get_byte(PARROT_INTERP,
SHIM(const STRING *src),
- UINTVAL offset)
+ SHIM(UINTVAL offset))
__attribute__nonnull__(1);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static STRING * get_bytes(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count)
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count))
__attribute__nonnull__(1);
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
static STRING * get_bytes_inplace(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *return_string))
__attribute__nonnull__(1);
@@ -80,8 +90,8 @@
PARROT_CANNOT_RETURN_NULL
static STRING * get_codepoints_inplace(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *dest_string))
__attribute__nonnull__(1);
@@ -95,14 +105,14 @@
static void set_byte(PARROT_INTERP,
SHIM(const STRING *src),
- UINTVAL offset,
- UINTVAL byte)
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL byte))
__attribute__nonnull__(1);
static void set_bytes(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *new_bytes))
__attribute__nonnull__(1);
@@ -115,8 +125,8 @@
static void set_codepoints(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *new_codepoints))
__attribute__nonnull__(1);
@@ -257,8 +267,7 @@
return s[offset];
#else
UNUSED(offset)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
- "no ICU lib loaded");
+ no_ICU_lib(interp);
#endif
}
@@ -284,8 +293,7 @@
UNUSED(src)
UNUSED(offset)
UNUSED(codepoint)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
- "no ICU lib loaded");
+ no_ICU_lib(interp);
#endif
}
@@ -508,8 +516,7 @@
#if PARROT_HAS_ICU
return src->bufused / sizeof (UChar);
#else
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
- "no ICU lib loaded");
+ no_ICU_lib(interp);
#endif
}
@@ -541,11 +548,12 @@
*/
-#if PARROT_HAS_ICU
static UINTVAL
ucs2_decode_and_advance(PARROT_INTERP, ARGMOD(String_iter *i))
{
ASSERT_ARGS(ucs2_decode_and_advance)
+
+#if PARROT_HAS_ICU
UChar * const s = (UChar*) i->str->strstart;
size_t pos = i->bytepos / sizeof (UChar);
@@ -556,6 +564,12 @@
i->charpos++;
i->bytepos = pos * sizeof (UChar);
return c;
+#else
+ /* This function must never be called if compiled without ICU.
+ * See TT #557
+ */
+ PARROT_ASSERT(0);
+#endif
}
/*
@@ -574,11 +588,19 @@
ucs2_encode_and_advance(PARROT_INTERP, ARGMOD(String_iter *i), UINTVAL c)
{
ASSERT_ARGS(ucs2_encode_and_advance)
+
+#if PARROT_HAS_ICU
UChar * const s = (UChar*) i->str->strstart;
UINTVAL pos = i->bytepos / sizeof (UChar);
s[pos++] = (UChar)c;
i->charpos++;
i->bytepos = pos * sizeof (UChar);
+#else
+ /* This function must never be called if compiled without ICU.
+ * See TT #557
+ */
+ PARROT_ASSERT(0);
+#endif
}
/*
@@ -595,11 +617,18 @@
ucs2_set_position(SHIM_INTERP, ARGMOD(String_iter *i), UINTVAL n)
{
ASSERT_ARGS(ucs2_set_position)
+
+#if PARROT_HAS_ICU
i->charpos = n;
i->bytepos = n * sizeof (UChar);
+#else
+ /* This function must never be called if compiled without ICU.
+ * See TT #557
+ */
+ PARROT_ASSERT(0);
+#endif
}
-#endif
/*
@@ -624,8 +653,7 @@
iter->set_and_advance = ucs2_encode_and_advance;
iter->set_position = ucs2_set_position;
#else
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
- "no ICU lib loaded");
+ no_ICU_lib(interp);
#endif
}
Modified: branches/headercleanup/src/string/encoding/utf8.c
==============================================================================
--- branches/headercleanup/src/string/encoding/utf8.c Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/src/string/encoding/utf8.c Tue Apr 21 21:28:29 2009 (r38254)
@@ -56,8 +56,8 @@
PARROT_CANNOT_RETURN_NULL
static STRING * get_bytes_inplace(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *return_string))
__attribute__nonnull__(1);
@@ -103,8 +103,8 @@
static void set_bytes(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *new_bytes))
__attribute__nonnull__(1);
@@ -117,8 +117,8 @@
static void set_codepoints(PARROT_INTERP,
SHIM(STRING *src),
- UINTVAL offset,
- UINTVAL count,
+ SHIM(UINTVAL offset),
+ SHIM(UINTVAL count),
SHIM(STRING *new_codepoints))
__attribute__nonnull__(1);
Modified: branches/headercleanup/t/benchmark/benchmarks.t
==============================================================================
--- branches/headercleanup/t/benchmark/benchmarks.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/benchmark/benchmarks.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -169,7 +169,6 @@
is\s1230\nlast\sis:\s9973\n$/x,
q{primes_i.pasm} => qr/^N\sprimes\sup\sto\s10000\sis:\s1229\n
last\sis:\s9973\nElapsed\stime:\s\d+\.\d+\n$/x,
- q{shared_ref.pasm} => qq(),
q{stress.pasm} => qr/^A\stotal\sof\s\d+\sGC\sruns\s
were\smade\n$/x,
q{stress1.pasm} => qr/^\d+\.\d+\n
Modified: branches/headercleanup/t/codingstd/c_function_docs.t
==============================================================================
--- branches/headercleanup/t/codingstd/c_function_docs.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/codingstd/c_function_docs.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -35,7 +35,7 @@
# can't handle .ops or .pmc files yet
my @files = grep {/\.(c|h)$/ } @ARGV ? @ARGV :
- map {s/^$PConfig{build_dir}$PConfig{slash}//; $_} map {$_->path} $DIST->get_c_language_files();
+ map {s/^$PConfig{build_dir}\///; $_} map {s/\\/\//g; $_} map {$_->path} $DIST->get_c_language_files();
plan tests => scalar @files;
@@ -70,7 +70,7 @@
# else: docs!
}
else {
- $missing = 'missing';
+ $missing = 'missing';
}
if ($missing) {
push @missing_docs, "$path ($missing)\n$function_decl\n";
Modified: branches/headercleanup/t/codingstd/copyright.t
==============================================================================
--- branches/headercleanup/t/codingstd/copyright.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/codingstd/copyright.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -4,7 +4,8 @@
use strict;
use warnings;
-
+use Cwd;
+use File::Spec ();
use lib qw( . lib ../lib ../../lib );
use Parrot::Distribution;
use Test::More tests => 3;
@@ -41,9 +42,10 @@
my @all_files = ( @c_files, @perl_files, @make_files );
my @files = @ARGV ? <@ARGV> : @all_files;
-my ( @no_copyright_files,
- @bad_format_copyright_files,
- @duplicate_copyright_files
+my (
+ @no_copyright_files,
+ @bad_format_copyright_files,
+ @duplicate_copyright_files,
);
my $copyright_simple =
@@ -72,7 +74,7 @@
}
# ... and then see if any other copyright notices exist.
elsif ($buf =~ $copyright_simple) {
- push @duplicate_copyright_files, $path;
+ push @duplicate_copyright_files, $path;
}
}
@@ -107,19 +109,64 @@
"Please update to read something like:",
$suggested_version
);
-}
-ok( !scalar(@duplicate_copyright_files), 'Duplicate Copyright statements' )
+# Certain files contain the string 'Copyright (c)' more than once
+# because they contain heredocs for generated files, correctly cite the
+# copyright information for non-Parrot code, etc. We shall exclude them
+# from our test for duplicate copyright statements.
+
+my @permitted_duplicate_copyright_files = (
+ {
+ file => 'examples/c/test_main.c',
+ reason => 'sample code',
+ },
+ {
+ file => 'Configure.pl',
+ reason => 'cite automake copyright statement',
+ },
+ {
+ file => 'config/gen/opengl.pm',
+ reason => 'heredoc text for generated file',
+ },
+ {
+ file => 'lib/Parrot/Configure/Messages.pm',
+ reason => 'heredoc for print_introduction()',
+ },
+ {
+ file => 't/tools/dev/searchops/samples.pm',
+ reason => 'sample code used in testing',
+ },
+ {
+ file => 'tools/build/nativecall.pl',
+ reason => 'heredoc text for generated file',
+ },
+ {
+ file => 'tools/build/vtable_extend.pl',
+ reason => 'heredoc text for generated file',
+ },
+);
+my $cwd = cwd();
+my %permitted_duplicate_copyright_files =
+ map { ( File::Spec->catfile( $cwd, $_->{file} ) ) => 1 }
+ @permitted_duplicate_copyright_files;
+
+my @non_permitted_duplicate_copyright_files =
+ grep { ! $permitted_duplicate_copyright_files{ $_ } }
+ @duplicate_copyright_files;
+
+ok( !scalar(@non_permitted_duplicate_copyright_files),
+ 'Duplicate Copyright statements' )
or diag(
join
$/ => "Duplicate copyright statement found in "
- . scalar @duplicate_copyright_files
+ . scalar @non_permitted_duplicate_copyright_files
. " files:",
- @duplicate_copyright_files,
+ @non_permitted_duplicate_copyright_files,
"Please get copyright assigned to Parrot Foundation",
- "and remove alternate notice; Or remove duplicated",
+ "and remove alternate notice; or remove duplicated",
"notice for Parrot Foundation."
);
+}
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/codingstd/svn_id.t
==============================================================================
--- branches/headercleanup/t/codingstd/svn_id.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/codingstd/svn_id.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -4,8 +4,9 @@
use strict;
use warnings;
+use Cwd;
+use File::Spec ();
use lib qw( . lib ../lib ../../lib );
-
use Parrot::Distribution;
use Test::More tests => 1;
@@ -34,22 +35,35 @@
=cut
my $DIST = Parrot::Distribution->new;
+my $cwd = cwd();
+
+# Certain files, for various reasons, cannot have an
+# SVN Id tag. We exclude them from examination by this test.
-my @files = @ARGV ? <@ARGV> : (
- $DIST->get_c_language_files(),
- $DIST->get_make_language_files(),
- $DIST->get_perl_language_files(),
- $DIST->get_pir_language_files(),
+my %known_exceptions = map {
+ $_ => 1,
+ ( File::Spec->catdir( $cwd, $_ ) ) => 1,
+ } qw(
+ examples/pir/quine_ord.pir
+ examples/streams/FileLines.pir
+ examples/streams/ParrotIO.pir
+ );
+
+my @files = grep { ! $known_exceptions{$_} }
+ ( @ARGV
+ ? <@ARGV>
+ : map { $_->path } (
+ $DIST->get_c_language_files(),
+ $DIST->get_make_language_files(),
+ $DIST->get_perl_language_files(),
+ $DIST->get_pir_language_files(),
+ )
);
my @no_id_files;
foreach my $file (@files) {
- # if we have command line arguments, the file is the full path
- # otherwise, use the relevant Parrot:: path method
- my $path = @ARGV ? $file : $file->path;
-
- my $buf = $DIST->slurp($path);
+ my $buf = $DIST->slurp($file);
if ( $buf !~ m/\$Id
(?:
@@ -58,7 +72,7 @@
:.*\$ # expanded tag, colon required
)
/xm ) {
- push @no_id_files, $path;
+ push @no_id_files, $file;
next;
}
}
Modified: branches/headercleanup/t/compilers/imcc/syn/pcc.t
==============================================================================
--- branches/headercleanup/t/compilers/imcc/syn/pcc.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/compilers/imcc/syn/pcc.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -258,7 +258,7 @@
pir_output_is( <<'CODE', <<'OUT', ".set_arg :flat" );
.sub _main
- .local pmc x, y, z, ar, ar2, s
+ .local pmc x, y, z, ar, ar2
x = new 'String'
x = "first\n"
y = new 'String'
Modified: branches/headercleanup/t/compilers/pge/perl6regex/rx_quantifiers
==============================================================================
--- branches/headercleanup/t/compilers/pge/perl6regex/rx_quantifiers Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/compilers/pge/perl6regex/rx_quantifiers Tue Apr 21 21:28:29 2009 (r38254)
@@ -202,4 +202,9 @@
a**!2..4 baaabbb y three "a" characters (explicit greed)
a**:!2..4 baaabbb y three "a" characters (explicit greed)
-
+^\w+ ** ','$ foo,bar,baz y ** with a term
+^\w+ **? ',' ....$ foo,bar,baz y **? with a term
+^\w+ **[','\s*]$ foo, bar, baz y **? with term + ws
+:sigspace ^\w+ ** ',' $ foo, bar ,baz y **? under :sigspace
+:sigspace ^\w+**',' $ foo, bar ,baz n **? under :sigspace w/o ws
+:sigspace ^\w+**',' $ foo,bar,baz y **? under :sigspace w/o ws
Modified: branches/headercleanup/t/library/streams.t
==============================================================================
--- branches/headercleanup/t/library/streams.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/library/streams.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1356,7 +1356,6 @@
.sub _main
.local pmc stream
- .local pmc temp
load_bytecode "library/Stream/Base.pir"
load_bytecode "library/Stream/Sub.pir"
Copied: branches/headercleanup/t/native_pbc/annotations.pbc (from r38253, trunk/t/native_pbc/annotations.pbc)
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/integer_2.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/number_2.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Modified: branches/headercleanup/t/native_pbc/string_2.pbc
==============================================================================
Binary file (source and/or target). No diff available.
Copied: branches/headercleanup/t/native_pbc/testdata/README (from r38253, trunk/t/native_pbc/testdata/README)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/t/native_pbc/testdata/README Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/t/native_pbc/testdata/README)
@@ -0,0 +1 @@
+This directory contains various PIR files for generating PBC in t/native_pbc.
Copied: branches/headercleanup/t/native_pbc/testdata/annotations.pir (from r38253, trunk/t/native_pbc/testdata/annotations.pir)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/t/native_pbc/testdata/annotations.pir Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/t/native_pbc/testdata/annotations.pir)
@@ -0,0 +1,18 @@
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+.sub 'main'
+.annotate "file", "annotations.pir"
+.annotate "creator", "Parrot Foundation"
+.annotate "line", 1
+ say "Hi"
+ say "line"
+.annotate "line", 2
+ .return ()
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/headercleanup/t/pmc/class.t
==============================================================================
--- branches/headercleanup/t/pmc/class.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/class.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -218,7 +218,7 @@
# L<PDD15/Class PMC API/=item add_method>
.sub 'add_method'
- .local pmc class, attribs, meth_to_add, test_attr_val, obj_inst
+ .local pmc class, attribs, test_attr_val, obj_inst
.local int test_val
class = new ['Class']
Modified: branches/headercleanup/t/pmc/nci.t
==============================================================================
--- branches/headercleanup/t/pmc/nci.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/nci.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -2647,6 +2647,11 @@
3
OUTPUT
+{
+ local $TODO = 0;
+ if ($PConfig{jitcapable}){
+ $TODO = "TT #551 - jitted NCI sig with V is broken";
+ }
pir_output_is( << 'CODE', << 'OUTPUT', "nci_vVi - void** out parameter" );
.sub test :main
.local string library_name
@@ -2669,6 +2674,7 @@
CODE
got 10
OUTPUT
+}
pir_output_is( << 'CODE', << 'OUTPUT', "nci_ttt - t_tt parameter" );
.sub test :main
@@ -2706,6 +2712,11 @@
1
OUTPUT
+{
+ local $TODO = 0;
+ if ($PConfig{jitcapable}){
+ $TODO = "TT #551 - jitted NCI sig with V is broken";
+ }
pir_output_is( << 'CODE', << 'OUTPUT', "nci_vV - char** out parameter" );
.sub test :main
.local string library_name
@@ -2753,6 +2764,7 @@
It is a beautiful day!
Go suck a lemon.
OUTPUT
+}
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/packfile.t
==============================================================================
--- branches/headercleanup/t/pmc/packfile.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfile.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#! parrot
# Copyright (C) 2006-2008, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 6;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfile.t - test the Packfile PMC
@@ -24,96 +17,115 @@
=cut
+.include 't/pmc/testlib/packfile_common.pir'
+
+.sub main :main
+.include 'test_more.pir'
+
+ plan(34)
+ 'test_new'()
+ 'test_get_string'()
+ 'test_set_string'()
+ 'test_get_integer'()
+ 'test_set_integer'()
+ 'test_get_directory'()
+ 'test_load'()
+ 'test_pack_fresh_packfile'()
+ 'test_pack'()
+ # This test will crash on many platforms. See TT#545.
+ #'test_synonyms'()
+.end
-# Packfile constructor
-pir_output_is( <<'CODE', <<'OUT', 'new' );
-.sub 'test' :main
+# Packfile constructor
+.sub 'test_new'
.local pmc pf
pf = new ['Packfile']
$I0 = defined pf
- say $I0
+ ok($I0, 'new')
+ _check_header(pf)
.end
-CODE
-1
-OUT
# Packfile.get_integer_keyed_str
-
-pir_output_is( <<'CODE', <<'OUT', 'get_integer_keyed_str' );
-.sub 'test' :main
+.sub 'test_get_string'
.local pmc pf
pf = new ['Packfile']
- $S0 = 'version_major'
- $I0 = pf[$S0]
- say $I0
-.end
-CODE
-1
-OUT
-
-
-# Packfile.get_directory
+ $S0 = pf["uuid"]
+ ok(1, 'get_string(uuid)')
+
+ # Requesting unknown key should throw exception
+ push_eh unknown_key
+ $S0 = pf["foo"]
+ ok(0, "get_string_keyed_int return unknown key")
+ .return ()
+
+ unknown_key:
+ pop_eh
+ ok(1, "get_string_keyed_int handle unknown key properly")
+ .return ()
+.end
-pir_output_is( <<'CODE', <<'OUT', 'get_directory' );
-.sub 'test' :main
+# Packfile.get_integer_keyed_str
+.sub 'test_set_string'
.local pmc pf
pf = new ['Packfile']
- $P1 = pf.'get_directory'()
- $S0 = typeof $P1
- say $S0
-.end
-CODE
-PackfileDirectory
-OUT
-
-
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
+ pf["uuid"] = "fe9ab64082e0f6bbbd7b1e8264127908"
+ ok(1, 'set_string(uuid)')
+
+ # Special check for 0
+ $S0 = "\0"
+ $I0 = length $S0
+ is($I0, 1, "Length is 1")
+ pf["uuid"] = $S0
+ $S1 = pf["uuid"]
+ $I1 = length $S1
+ is($I1, 1, "Fetched length is 1")
+
+ # Requesting unknown key should throw exception
+ push_eh unknown_key
+ pf["foo"] = "fe9ab64082e0f6bbbd7b1e8264127908"
+ ok(0, "set_string_keyed_int set unknown key")
+ .return ()
+
+ unknown_key:
+ pop_eh
+ ok(1, "set_string_keyed_int handle unknown key properly")
+ .return ()
.end
-EOF
+
+
# Packfile.set_string_native, Packfile.get_integer_keyed_str
-pir_output_is( <<'CODE' . $get_uuid_pbc, $PConfig{VERSION}, 'set_string_native' );
-.sub 'test' :main
+.sub 'test_get_integer'
.local pmc pf
- pf = _pbc()
- $S0 = "version_major"
- $I0 = pf[$S0]
- $S0 = "version_minor"
- $I1 = pf[$S0]
- $S0 = "version_patch"
- $I2 = pf[$S0]
- print $I0
- print "."
- print $I1
- print "."
- print $I2
+ pf = _pbc()
+ $I0 = pf["version_major"]
+ ok(1, "get_integer_keyed_str(version_major)")
+
+ $I1 = pf["version_minor"]
+ ok(1, "get_integer_keyed_str(version_minor)")
+
+ $I2 = pf["version_patch"]
+ ok(1, "get_integer_keyed_str(version_patch)")
+
+ # Requesting unknown key should throw exception
+ push_eh unknown_key
+ $I3 = pf["foo"]
+ ok(0, "get_integer_keyed_str return unknown key")
+ .return ()
+
+ unknown_key:
+ pop_eh
+ ok(1, "get_integer_keyed_str handle unknown key properly")
+ .return ()
+
.end
-CODE
# Packfile.set_integer_keyed_str
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
-.sub 'test' :main
+.sub 'test_set_integer'
.local pmc pf
pf = _pbc()
$S1 = 'version_major'
@@ -122,38 +134,177 @@
inc $I1
pf[$S1] = $I1
$I2 = pf[$S1]
- eq $I0, $I1, OUT1
- print "not "
- OUT1:
- say "equal"
- eq $I1, $I2, OUT2
- print "not "
- OUT2:
- say "equal"
-.end
-CODE
-not equal
-equal
-OUT
+ $I3 = cmp $I0, $I2
+ $I3 = cmp $I3, 0
+ ok($I3, 'set_integer_keyed_str version bumped')
+.end
+# Packfile.get_directory
+.sub 'test_get_directory'
+ .local pmc pf
+ pf = new ['Packfile']
+ $P0 = pf.'get_directory'()
+ isa_ok($P0, 'PackfileDirectory')
+.end
-# PackfileSegment.pack (via subclass PackfileDirectory)
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
-.sub 'test' :main
+# PackfileSegment.pack (via subclass PackfileDirectory)
+.sub 'test_get_directory'
.local pmc pf, pfdir
pf = _pbc()
pfdir = pf.'get_directory'()
$S0 = pfdir.'pack'()
$I0 = length $S0
- eq $I0, 0, OUT1
- print "not "
- OUT1:
- say "equal"
-.end
-CODE
-not equal
-OUT
+ $I1 = cmp $I0, 0
+ ok($I1, 'get_directory')
+.end
+
+
+# Packfile.set_string_native
+# Check that packfile was loaded properly and set various attributes
+.sub 'test_load'
+ .local pmc pf
+ pf = _pbc()
+
+ _check_header(pf)
+.end
+
+# Helper sub to check fields in Packfile header
+.sub '_check_header'
+ .param pmc pf
+
+ # wordsize always greater than 0
+ $I0 = pf["wordsize"]
+ ok($I0, "Wordsize set")
+
+ # We are living in post-1.0 era.
+ $I0 = pf["version_major"]
+ ok($I0, "version_major set")
+
+ $I0 = pf["bytecode_major"]
+ ok($I0, "bytecode_major set")
+.end
+
+# Create very simple Packfile and pack it
+.sub 'test_pack_fresh_packfile'
+ .local pmc pf, pfdir
+ pf = new 'Packfile'
+ pfdir = pf.'get_directory'()
+ #$P0 = new 'PackfileConstantTable'
+ #$P0[0] = 42.0
+ $P0 = new 'PackfileFixupTable'
+ $P1 = new 'PackfileFixupEntry'
+ $P1 = 42
+ $P1.'set_type'(1)
+ $P1 = "The fixup"
+ $P0[0] = $P1
+ pfdir["FIXUP_t/pmc/packfile.t"] = $P0
+
+ $P1 = new 'PackfileRawSegment'
+ pfdir["BYTECODE_t/pmc/packfile.t"] = $P1
+
+ $P2 = new 'PackfileConstantTable'
+ $P2[0] = 42.0
+ $P2[1] = "42"
+ $P3 = new 'Integer'
+ $P3 = 42
+ $P2[2] = $P3
+ $P4 = new 'Key'
+ $P4 = 42
+ $P2[3] = $P4
+ pfdir["CONSTANTS_t/pmc/packfile.t"] = $P2
+
+ # Set uuid_type
+ pf['uuid_type'] = 1
+ $S0 = pf
+
+ # Pack it
+ ok(1, "PackFile packed")
+
+ #$P1 = open "/tmp/1.pbc", "w"
+ #$P1.'puts'($S0)
+ #close $P1
+
+ pf = new 'Packfile'
+ pf = $S0
+ ok(1, "PackFile unpacked after pack")
+
+ $I0 = pf['uuid_type']
+ is($I0, 1, "uuid_type preserved")
+
+ # Check that FixupTable contains our Entry.
+ $P0 = _get_fixup_table(pf)
+ $I1 = elements $P0
+ is($I1, 1, "FixupTable contains one element")
+ $P1 = $P0[0]
+ isa_ok($P1, "PackfileFixupEntry")
+ $I0 = $P1
+ is($I0, 42, "FixupEntry offset preserved")
+ $S0 = $P1
+ is($S0, "The fixup", "FixupEntry name preserved")
+
+ # Check unpacked ConstTable
+ $P0 = _find_segment_by_type(pf, "PackfileConstantTable")
+ $I0 = defined $P0
+ ok($I0, "ConstantTable unpacked")
+ $I0 = elements $P0
+ is($I0, 4, " and contains 4 elements")
+ $N0 = $P0[0]
+ is($N0, 42.0, " first is number")
+ $S0 = $P0[1]
+ is($S0, "42", " second is string")
+ $P1 = $P0[2]
+ isa_ok($P1, "Integer")
+ $I0 = $P1
+ is($I0, 42, " with proper value")
+ $P1 = $P0[3]
+ isa_ok($P1, "Key")
+.end
+
+# Packfile.pack.
+# Check that unpack-pack produce correct result.
+.sub 'test_pack'
+ .local string filename, first
+ $S0 = '_filename'()
+ $P0 = open $S0, 'r'
+
+ first = $P0.'readall'()
+
+ .local pmc packfile
+ packfile = new 'Packfile'
+ packfile = first
+
+ # Packed file should be exactly the same as loaded
+ .local string second
+ # Pack
+ second = packfile
+
+ $I0 = cmp first, second
+ $I0 = not $I0
+ todo($I0, 'pack produced same result twice')
+.end
+
+# Test pack/set_string unpack/get_string equivalency
+.sub 'test_synonyms'
+ .local pmc pf
+ pf = '_pbc'()
+
+ $S0 = pf
+ $S1 = pf.'pack'()
+ $I0 = cmp $S0, $S1
+ is($I0, 0, "pack and get_string are synonyms")
+
+ # Unpack data in two ways
+ $P0 = new ['Packfile']
+ $P0 = $S0
+ $P1 = new ['Packfile']
+ $P1.'unpack'($S0)
+
+ $S0 = $P0
+ $S1 = $P1
+ $I0 = cmp $S0, $S1
+ is($I0, 0, "unpack and set_string are synonyms")
+.end
# Local Variables:
@@ -161,4 +312,4 @@
# cperl-indent-level: 4
# fill-column: 100
# End:
-# vim: expandtab shiftwidth=4:
+# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/headercleanup/t/pmc/packfileannotation.t
==============================================================================
--- branches/headercleanup/t/pmc/packfileannotation.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfileannotation.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,13 +1,6 @@
-#!perl
+#!parrot
# Copyright (C) 2006-2009, Parrot Foundation.
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 1;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfileannotation.t - test the PackfileAnnotation PMC
@@ -23,16 +16,26 @@
=cut
+# PackfileAnnotation constructor
+.sub 'test' :main
+.include 'test_more.pir'
+ .local pmc pa
+
+ plan(4)
-# Packfile constructor
+ pa = new ['PackfileAnnotation']
+ $I0 = defined pa
+ ok($I0, 'PackfileAnnotation created')
+
+ pa = 42
+ pa.'set_key_id'(1)
+ pa.'set_offset'(115200)
+
+ $I0 = pa
+ is($I0, 42, 'Value stored and fetched')
+ $I0 = pa.'get_key_id'()
+ is($I0, 1, 'KeyId stored and fetched')
+ $I0 = pa.'get_offset'()
+ is($I0, 115200, 'Offset stored and fetched')
-pir_output_is( <<'CODE', <<'OUT', 'new' );
-.sub 'test' :main
- .local pmc pf
- pf = new ['PackfileAnnotation']
- $I0 = defined pf
- say $I0
.end
-CODE
-1
-OUT
Modified: branches/headercleanup/t/pmc/packfileannotationkeys.t
==============================================================================
--- branches/headercleanup/t/pmc/packfileannotationkeys.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfileannotationkeys.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,13 +1,6 @@
-#!perl
+#!parrot
# Copyright (C) 2006-2009, Parrot Foundation.
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 1;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfileannotationkeys.t - test the PackfileAnnotationKeys PMC
@@ -23,16 +16,103 @@
=cut
+.include 'packfile_annotation_key_type.pasm'
+.include 't/pmc/testlib/packfile_common.pir'
# Packfile constructor
-
-pir_output_is( <<'CODE', <<'OUT', 'new' );
.sub 'test' :main
+.include 'test_more.pir'
+ plan(14)
+
+ test_sanity()
+ test_pack_unpack()
+
+.end
+
+# Sanity test for creating PackfileAnnotationKeys
+.sub 'test_sanity'
.local pmc pf
pf = new ['PackfileAnnotationKeys']
$I0 = defined pf
- say $I0
+ ok($I0, "PackfileAnnotationKeys created")
.end
-CODE
-1
-OUT
+
+# Pack PackfileAnnotationKeys
+.sub 'test_pack_unpack'
+ .local pmc pf, pfdir, ctable, annotations, keys
+
+ pf = new 'Packfile'
+ pfdir = pf.'get_directory'()
+
+ # Fixup table and Bytecode is mandatory
+ $P0 = new 'PackfileFixupTable'
+ pfdir["FIXUP_t/pmc/packfileannotationkeys.t"] = $P0
+ $P1 = new 'PackfileRawSegment'
+ pfdir["BYTECODE_t/pmc/packfileannotationkeys.t"] = $P1
+
+ ctable = new 'PackfileConstantTable'
+ pfdir["CONSTANT_t/pmc/packfileannotationkeys.t"] = ctable
+
+ # Annotation associated with bytecode by interesting
+ annotations = new 'PackfileAnnotations'
+ pfdir["BYTECODE_t/pmc/packfileannotationkeys.t_ANN"] = annotations
+
+ # Initialize kyes
+ keys = annotations.'get_key_list'()
+ keys[0] = "line"
+ keys[0] = .PF_ANNOTATION_KEY_TYPE_INT
+
+ # Set couple of annotations
+ $P0 = new 'PackfileAnnotation'
+ $P0.'set_key_id'(0)
+ $P0.'set_offset'(0)
+ $P0 = 1
+ annotations[0] = $P0
+
+ $P1 = new 'PackfileAnnotation'
+ $P1.'set_key_id'(0)
+ $P1.'set_offset'(1)
+ $P1 = 42
+ annotations[1] = $P1
+
+ # Pack/unpack
+ $S0 = pf
+ $I0 = length $S0
+ ok($I0, "Packfile with annotations packed")
+
+ pf = $S0
+ annotations = _find_segment_by_type(pf, 'PackfileAnnotations')
+ $I0 = defined annotations
+ ok($I0, "PackfileAnnotations was unpacked successfully")
+
+ # Check unpacked keys
+ keys = annotations.'get_key_list'()
+ $I0 = elements keys
+ is($I0, 1, "Got 1 unpacked key")
+ $S0 = keys[0]
+ is($S0, "line", "With expected name")
+ $I0 = keys[0]
+ is($I0, .PF_ANNOTATION_KEY_TYPE_INT, "With expected type")
+
+ # Check unpacked entries
+ $P0 = annotations[0]
+ isa_ok($P0, "PackfileAnnotation")
+ $I0 = $P0.'get_key_id'()
+ is($I0, 0, "First key_id is correct")
+ $I0 = $P0.'get_offset'()
+ is($I0, 0, "First offset is correct")
+ $I0 = $P0
+ is($I0, 1, "First value is correct")
+
+ $P0 = annotations[1]
+ isa_ok($P0, "PackfileAnnotation")
+ $I0 = $P0.'get_key_id'()
+ is($I0, 0, "Second key_id is correct")
+ $I0 = $P0.'get_offset'()
+ is($I0, 1, "Second offset is correct")
+ $I0 = $P0
+ is($I0, 42, "Second value is correct")
+
+
+.end
+
Modified: branches/headercleanup/t/pmc/packfileannotations.t
==============================================================================
--- branches/headercleanup/t/pmc/packfileannotations.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfileannotations.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,12 +1,6 @@
-#!perl
+#!parrot
# Copyright (C) 2006-2009, Parrot Foundation.
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 1;
-use Parrot::Config;
=head1 NAME
@@ -23,16 +17,113 @@
=cut
+.include 't/pmc/testlib/packfile_common.pir'
-# Packfile constructor
+.sub 'main' :main
+.include 'test_more.pir'
+ plan(14)
+ test_sanity()
+ test_handling_directory()
+ test_unpack()
+.end
-pir_output_is( <<'CODE', <<'OUT', 'new' );
-.sub 'test' :main
+
+# Packfile constructor
+.sub 'test_sanity'
.local pmc pf
pf = new ['PackfileAnnotations']
$I0 = defined pf
- say $I0
+ ok($I0, "PackfileAnnotations created")
+.end
+
+# Annotations should propogate ConstantTable to Keys.
+.sub 'test_handling_directory'
+ .local pmc keys, anns, pfdir
+
+ anns = new 'PackfileAnnotations'
+ keys = anns.'get_key_list'()
+ $I0 = defined keys
+ ok($I0, "Keys created")
+ $P0 = keys.'get_constant_table'()
+ $I0 = defined $P0
+ is($I0, 0, " without ConstantTable")
+
+ pfdir = new 'PackfileDirectory'
+ $P0 = new 'PackfileConstantTable'
+ # Order does matter
+ pfdir['CONSTANTS'] = $P0
+ pfdir['ANNOTATIONS'] = anns
+ $P0 = keys.'get_constant_table'()
+ $I0 = defined $P0
+ ok($I0, 'PackfileConstantTable found and propogated to Keys')
+.end
+
+# PackfileAnnotations unpack from PBC
+.sub 'test_unpack'
+ .local pmc pf, pfdir, pfanns, it
+
+ $P0 = open 't/native_pbc/annotations.pbc'
+ $S0 = $P0.'readall'()
+ pf = new 'Packfile'
+ pf = $S0
+
+ # Find annotations
+ pfdir = pf.'get_directory'()
+ it = iter pfdir
+ loop:
+ unless it goto fail
+ $S0 = shift it
+ $P0 = pfdir[$S0]
+ $I0 = isa $P0, 'PackfileAnnotations'
+ unless $I0 goto loop
+ ok(1, "PackfileAnnotations unpacked")
+ pfanns = $P0
+
+ # Check keys
+ .local pmc keys
+ keys = pfanns.'get_key_list'()
+ $I0 = elements keys
+ is($I0, 3, 'Keys were successfully unpacked')
+
+ $S0 = keys[0]
+ is($S0, "file", "First key is correct")
+ $S0 = keys[1]
+ is($S0, "creator", "Second key is correct")
+ $S0 = keys[2]
+ is($S0, "line", "Third key is correct")
+
+ # Test entities
+ $I0 = elements pfanns
+ is($I0, 4, "Annotations were unpack correctly")
+
+ .local pmc a
+ .local pmc constants
+ constants = _find_segment_by_type(pf, "PackfileConstantTable")
+ # "file"
+ a = pfanns[0]
+ $I0 = a
+ $S0 = constants[$I0]
+ is($S0, "annotations.pir", "First annotation is correct")
+
+ # "creator"
+ a = pfanns[1]
+ $I0 = a
+ $S0 = constants[$I0]
+ is($S0, "Parrot Foundation", "Second annotation is correct")
+
+ # Two "line"
+ a = pfanns[2]
+ $I0 = a
+ is($I0, 1, "Third annotation is correct")
+ a = pfanns[3]
+ $I0 = a
+ is($I0, 2, "Forth annotation is correct")
+
+
+ .return()
+
+ fail:
+ nok(1, "PackfileAnnotations wasn't found in Directory")
+ # BAIL_OUT
+ skip(9, "PackfileAnnotations tests failed")
.end
-CODE
-1
-OUT
Modified: branches/headercleanup/t/pmc/packfileconstanttable.t
==============================================================================
--- branches/headercleanup/t/pmc/packfileconstanttable.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfileconstanttable.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#!parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 3;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfileconstanttable.t - test the PackfileConstantTable PMC
@@ -29,113 +22,141 @@
# fetches for the found types don't crash.
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
+.include 't/pmc/testlib/packfile_common.pir'
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
+.sub 'main' :main
+.include 'test_more.pir'
+.include 'packfile_constants.pasm'
+ 'plan'(10)
+
+ 'test_sanity'()
+ 'test_elements'()
+ 'test_get'()
+ 'test_set'()
.end
-EOF
-# sanity check we have a PackfileConstantTable
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'sanity' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
+# sanity check we have a PackfileConstantTable
+.sub 'test_sanity'
+ .local pmc pbc, pftable
.local string name
- pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[2]
- name = typeof pftable
- say name
-.end
-CODE
-PackfileConstantTable
-OUT
+ pbc = _pbc()
+ pftable = _get_consttable(pbc)
+ isa_ok(pftable, "PackfileConstantTable")
+.end
# PackfileConstantTable.elements
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'elements' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
+.sub 'test_elements'
+ .local pmc pf, pftable
.local int size
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[2]
+ pftable = _get_consttable(pf)
size = elements pftable
- gt size, 0, DONE
- say 'not '
- DONE:
- say 'greater'
-.end
-CODE
-greater
-OUT
+ ok(size, "PackfileConstantTable.elements returns non-zero")
+.end
# PackfileConstantTable.get_type and PackfileConstantTable.get_*_keyed_int
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'get_type, get_*_keyed_int', todo=> 'See TT #385.' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
+.sub 'test_get'
+ .local pmc pf, pftable
.local int size, this, type
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[2]
+ pftable = _get_consttable(pf)
size = elements pftable
this = 0
- LOOP:
+ loop:
type = pftable.'get_type'(this)
- eq type, 0x00, NEXT
- eq type, 0x6E, CONST_NUM
- eq type, 0x73, CONST_STR
- eq type, 0x70, CONST_PMC
- eq type, 0x6B, CONST_KEY
- goto BAD
- CONST_NUM:
+ eq type, .PFC_NONE, next
+ eq type, .PFC_NUMBER, const_num
+ eq type, .PFC_STRING, const_str
+ eq type, .PFC_PMC, const_pmc
+ eq type, .PFC_KEY, const_key
+ goto bad
+ const_num:
$N0 = pftable[this]
- goto NEXT
- CONST_STR:
+ goto next
+ const_str:
$S0 = pftable[this]
- goto NEXT
- CONST_PMC:
+ goto next
+ const_pmc:
$P0 = pftable[this]
- goto NEXT
- CONST_KEY:
+ goto next
+ const_key:
$P0 = pftable[this]
$S0 = typeof $P0
- eq $S0, 'Key', NEXT
- print 'constant Key with wrong type: '
- say $S0
- goto BAD
- NEXT:
+ eq $S0, 'Key', next
+ $S0 = concat 'constant Key with wrong type: ', $S0
+ ok(0, $S0)
+ .return()
+
+ next:
this = this + 1
- ge this, size, DONE
- goto LOOP
- gt size, 0, DONE
- BAD:
- say 'unknown constant type found!'
- DONE:
- say 'done.'
-.end
-CODE
-done.
-OUT
+ ge this, size, done
+ goto loop
+ gt size, 0, done
+
+ done:
+ ok(1, 'PackfileConstantTable.get_*_int works')
+ .return()
+ bad:
+ ok(0, 'Unknown constant type')
+ .return()
+.end
+
+# Test setting constants into PackfileConstantTable
+.sub 'test_set'
+ .local pmc ct
+ .local int size
+ ct = new ['PackfileConstantTable']
+
+ # Initial PackfileConstantTable is empty
+ size = elements ct
+ is(size, 0, "Empty PackfileConstantTable created")
+
+ # Set first string
+ ct[0] = "string"
+ $I0 = elements ct
+ is($I0, 1, "String element added")
+
+ ct[1] = 1.0
+ $I0 = elements ct
+ is($I0, 2, "Number elements added")
+
+ $P0 = new 'Integer'
+ $P0 = 42
+ ct[2] = $P0
+ $I0 = elements ct
+ is($I0, 3, "PMC elements added")
+
+ # Check types of created constants
+ $I0 = ct.'get_type'(0)
+ is($I0, .PFC_STRING, "First element is string")
+ $I0 = ct.'get_type'(1)
+ is($I0, .PFC_NUMBER, "Second element is number")
+ $I0 = ct.'get_type'(2)
+ is($I0, .PFC_PMC, "Third element is PMC")
+.end
+
+
+.sub '_get_consttable'
+ .param pmc pf
+ .local pmc dir, it
+ dir = pf.'get_directory'()
+ it = iter dir
+ loop:
+ unless it goto done
+ $S0 = shift it
+ $P0 = dir[$S0]
+ $I0 = isa $P0, 'PackfileConstantTable'
+ unless $I0 goto loop
+ .return ($P0)
+ done:
+ die "Can't find ConstantTable in Packfile!"
+ .return ()
+.end
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/packfiledirectory.t
==============================================================================
--- branches/headercleanup/t/pmc/packfiledirectory.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfiledirectory.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#! parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 6;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfiledirectory.t - test the PackfileDirectory PMC
@@ -24,170 +17,125 @@
=cut
+.include 't/pmc/testlib/packfile_common.pir'
-# PackfileDirectory.typeof
+.sub 'main' :main
+.include 'test_more.pir'
+ plan(21)
+
+ 'test_create'()
+ 'test_typeof'()
+ 'test_elements'()
+ 'test_get_iter'()
+ 'test_set_pmc_keyed_str'()
+.end
+
+# Test creation of fresh directory
+.sub 'test_create'
+ .local pmc dir, seg
+ dir = new 'PackfileDirectory'
+ isa_ok(dir, 'PackfileDirectory')
+
+ seg = new 'PackfileRawSegment'
+ # We should set owner
+ $P0 = seg.'get_directory'()
+ $I0 = defined $P0
+ $I0 = not $I0
+ ok($I0, "Owner of fresh segment unknown")
+
+ dir['RAWSEGMENT'] = seg
+
+ # We should set owner
+ $P0 = seg.'get_directory'()
+ $I0 = defined $P0
+ ok($I0, "Owner of segment set correctly")
+.end
-pir_output_is( <<'CODE', <<'OUT', 'get_directory' );
-.sub 'test' :main
+# PackfileDirectory.typeof
+.sub 'test_typeof'
.local pmc pf
pf = new ['Packfile']
$P1 = pf.'get_directory'()
- $S0 = typeof $P1
- say $S0
+ isa_ok($P1, 'PackfileDirectory', 'PackfileDirectory.get_directory')
.end
-CODE
-PackfileDirectory
-OUT
-
-
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
-.end
-EOF
-
# PackfileDirectory.elements
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'PackfileDirectory.elements' );
-.sub 'test' :main
+.sub 'test_elements'
.local pmc pf, pfdir
pf = _pbc()
pfdir = pf.'get_directory'()
$I0 = elements pfdir
- say $I0
+ is($I0, 5, 'PackfileDirectory.elements')
.end
-CODE
-5
-OUT
-# PackfileDirectory.get_pmc_keyed_int
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'PackfileDirectory.get_pmc_keyed_int' );
-.sub 'test' :main
- .local pmc pf, pfdir
- pf = _pbc()
- pfdir = pf.'get_directory'()
- $I0 = elements pfdir
- $I1 = 0
- LOOP:
- $P0 = pfdir[$I1]
- $I2 = defined $P0
- eq $I2, 0, ERROR
- inc $I1
- eq $I0, $I1, DONE
- goto LOOP
- DONE:
- say "done"
- .return()
- ERROR:
- say "error"
-.end
-CODE
-done
-OUT
-
-
-# PackfileDirectory.get_string_keyed_int
-my $EXPECTED = <<EXPECTED;
-BYTECODE_runtime/parrot/library/uuid.pir
-FIXUP_runtime/parrot/library/uuid.pir
-CONSTANT_runtime/parrot/library/uuid.pir
-PIC_idx_runtime/parrot/library/uuid.pir
-BYTECODE_runtime/parrot/library/uuid.pir_DB
-EXPECTED
+# PackfileDirectory.get_iter
+.sub 'test_get_iter'
+ .local pmc pf, pfdir, it, expected
+ .local string name
-$EXPECTED =~ s/\//\\/g
- if $^O eq 'MSWin32';
+ # expected contains all expected segment "prefixes" with count
+ expected = new 'Hash'
+ expected["BYTECODE"] = 2
+ expected["FIXUP"] = 1
+ expected["CONSTANT"] = 1
+ expected["PIC"] = 1
-pir_output_is( <<'CODE' . $get_uuid_pbc, $EXPECTED, 'PackfileDirectory.get_string_keyed_int' );
-.sub 'test' :main
- .local pmc pf, pfdir
pf = _pbc()
pfdir = pf.'get_directory'()
$I0 = elements pfdir
- $I1 = 0
- LOOP:
- $S0 = pfdir[$I1]
- say $S0
- inc $I1
- eq $I0, $I1, DONE
- goto LOOP
- DONE:
- .return()
-.end
-CODE
-
-
-# PackfileDirectory.get_pmc_keyed_str
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'PackfileDirectory.get_pmc_keyed_str' );
-.sub 'test' :main
- .local pmc pf, pfdir
+ it = iter pfdir
+ loop:
+ unless it goto done
+ name = shift it
+
+ # Get prefix
+ $P0 = split '_', name
+ $S0 = shift $P0
+ $I0 = expected[$S0]
+ ok($I0, $S0)
+ # Decrease expectation count
+ dec $I0
+ expected[$S0] = $I0
+
+ $P1 = pfdir[name]
+ isa_ok($P1, 'PackfileSegment')
+ $P2 = $P1.'get_directory'()
+ $I0 = defined $P2
+ ok($I0, "Loaded Segment has proper directory")
+ goto loop
+ done:
+ .return ()
+.end
+
+## PackfileDirectory.set_pmc_keyed_str
+.sub 'test_set_pmc_keyed_str'
+ .local pmc pf, pfdir, seg
pf = _pbc()
pfdir = pf.'get_directory'()
- $I0 = elements pfdir
- $I1 = 0
- LOOP:
- $P0 = pfdir[$I1]
- $S1 = pfdir[$I1]
- $P1 = pfdir[$S1]
- $S0 = typeof $P0
- $S1 = typeof $P1
- eq $S0, $S1, GOOD
- goto ERROR
- GOOD:
- inc $I1
- eq $I0, $I1, DONE
- goto LOOP
- DONE:
- say 'good'
- .return()
- ERROR:
- say 'mismatch'
-.end
-CODE
-good
-OUT
+ seg = new [ 'PackfileRawSegment' ]
+ # Adding segment with same name replaces old one
+ $I0 = elements pfdir
+ $P0 = iter pfdir
+ $S0 = shift $P0
+ pfdir[$S0] = seg
+ $I1 = elements pfdir
+ is($I0, $I1, "Segment with old name was added")
+ goto done
+
+ # Add segment with new name
+ add_new:
+ seg = new [ 'PackfileRawSegment' ]
+ $S0 = 'BYTECODE_foo'
+ pfdir[$S0] = seg
+ $I1 = elements pfdir
+ inc $I0
+ is($I0, $I1, "New segment added")
-# PackfileDirectory.set_pmc_keyed_str
-my $EXPECTED_foo = $EXPECTED . "BYTECODE_foo\n";
-pir_output_is( <<'CODE' . $get_uuid_pbc, $EXPECTED_foo, 'PackfileDirectory.set_pmc_keyed_str' );
-.sub 'test' :main
- .local pmc pf, pfdir
- pf = _pbc()
- pfdir = pf.'get_directory'()
- $P0 = new [ 'PackfileRawSegment' ]
- $S0 = 'BYTECODE_foo'
- pfdir[$S0] = $P0
- $I0 = elements pfdir
- $I1 = 0
- LOOP:
- $S0 = pfdir[$I1]
- say $S0
- inc $I1
- eq $I0, $I1, DONE
- goto LOOP
- DONE:
+ done:
.return()
.end
-CODE
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/packfilefixupentry.t
==============================================================================
--- branches/headercleanup/t/pmc/packfilefixupentry.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfilefixupentry.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,19 +1,11 @@
-#!perl
+#! parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 3;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfilefixupentry.t - test the PackfileFixupEntry PMC
-
=head1 SYNOPSIS
% prove t/pmc/packfilefixupentry.t
@@ -27,95 +19,67 @@
# Having some known data would be helpful, here. For now, just make sure
# the values returned seem sane.
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
+.include 't/pmc/testlib/packfile_common.pir'
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
+.sub 'main' :main
+.include 'test_more.pir'
+ plan(3)
+ test_sanity()
+ test_sanity_entry()
+ test_methods()
.end
-EOF
-# sanity check we start with a PackfileFixupTable
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'sanity1' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
+# sanity check we start with a PackfileFixupTable
+.sub 'test_sanity'
+ .local pmc pf, pftable
.local string name
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
- name = typeof pftable
- say name
+ pftable = _get_fixup_table(pf)
+ isa_ok(pftable, 'PackfileFixupTable')
.end
-CODE
-PackfileFixupTable
-OUT
# sanity check we end up with a PackfileFixupTable
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'sanity2' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable, pfentry
+.sub 'test_sanity_entry'
+ .local pmc pf, pftable, pfentry
.local string name
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
+ pftable = _get_fixup_table(pf)
pfentry = pftable[0]
- name = typeof pfentry
- say name
+ isa_ok(pfentry, 'PackfileFixupEntry')
.end
-CODE
-PackfileFixupEntry
-OUT
# PackfileFixupEntry methods .get_string(), .get_integer(), .get_type()
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'sanity' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable, pfentry
+.sub 'test_methods'
+ .local pmc pf, pftable, pfentry
.local int size, this, data
.local string name, label
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
+ pftable = _get_fixup_table(pf)
size = elements pftable
this = 0
- LOOP:
+ loop:
pfentry = pftable[this]
name = typeof pfentry
- eq name, "PackfileFixupEntry", NEXT
- print "PackfileFixupTable["
- print this
- print "] returned an object of type: "
- say name
- goto DONE
- NEXT:
+ eq name, "PackfileFixupEntry", next
+ $S0 = "PackfileFixupTable["
+ $S1 = this
+ $S0 = concat $S1
+ $S0 = concat "] returned an object of type: "
+ $S0 = concat name
+ ok(0, $S0)
+ .return ()
+ next:
this = this + 1
- ge this, size, DONE
- goto LOOP
- gt size, 0, DONE
- DONE:
- say 'done.'
+ ge this, size, done
+ goto loop
+ gt size, 0, done
+ done:
+ ok(1, "Got entries")
.end
-CODE
-done.
-OUT
-
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/packfilefixuptable.t
==============================================================================
--- branches/headercleanup/t/pmc/packfilefixuptable.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfilefixuptable.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#!parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 3;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfilefixuptable.t - test the PackfileFixupTable PMC
@@ -27,98 +20,46 @@
# Having some known data would be helpful, here. For now, just make sure
# the values returned have the right types.
+.include 't/pmc/testlib/packfile_common.pir'
+.sub 'main' :main
+.include 'test_more.pir'
+ plan(3)
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
+ test_unpack()
.end
-EOF
-
-
-# sanity check we have a PackfileFixupTable
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'sanity' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
+# Check unpackging FixupTable
+.sub 'test_unpack'
+ .local pmc pf, pfdir, pftable, pfentry
+ .local int size, this, data
.local string name
pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
- name = typeof pftable
- say name
-.end
-CODE
-PackfileFixupTable
-OUT
-
-
-# PackfileFixupTable.elements
+ pftable = _get_fixup_table(pf)
+ isa_ok(pftable, 'PackfileFixupTable')
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'elements' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable
- .local int size
- pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
size = elements pftable
- gt size, 0, DONE
- say 'not '
- DONE:
- say 'greater'
-.end
-CODE
-greater
-OUT
-
-
-# PackfileFixupTable.get_pmc_keyed_int
+ ok(size, "Got some elements")
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'get_pmc_keyed_int' );
-.sub 'test' :main
- .local pmc pf, pfdir, pftable, pfentry
- .local int size, this
- .local string type
- pf = _pbc()
- pfdir = pf.'get_directory'()
- pftable = pfdir[1]
- size = elements pftable
this = 0
- LOOP:
+ loop:
pfentry = pftable[this]
- type = typeof pfentry
- eq type, "PackfileFixupEntry", NEXT
- print "PackfileFixupTable["
- print this
- print "] returned an object of type: "
- say type
- goto DONE
- NEXT:
+ name = typeof pfentry
+ eq name, "PackfileFixupEntry", next
+ $S0 = "PackfileFixupTable["
+ $S1 = this
+ $S0 = concat $S1
+ $S0 = concat "] returned an object of type: "
+ $S0 = concat name
+ ok(0, $S0)
+ .return ()
+ next:
this = this + 1
- ge this, size, DONE
- goto LOOP
- gt size, 0, DONE
- DONE:
- say 'done.'
+ ge this, size, done
+ goto loop
+ gt size, 0, done
+ done:
+ ok(1, "All elements of Table are Entries")
.end
-CODE
-done.
-OUT
-
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/packfilerawsegment.t
==============================================================================
--- branches/headercleanup/t/pmc/packfilerawsegment.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfilerawsegment.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#!parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 2;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfilerawsegment.t - test the PackfileRawSegment PMC
@@ -28,55 +21,35 @@
# the value returned by elements() is greater than zero, and that
# get_integer_keyed_int doesn't return all zeroes either.
-
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
+.include 't/pmc/testlib/packfile_common.pir'
+.sub 'main' :main
+.include 'test_more.pir'
+ plan(2)
+ test_elements()
+ test_get_integer()
.end
-EOF
-
# PackfileRawSegment.elements
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'elements' );
-.sub 'test' :main
+.sub 'test_elements'
.local pmc pf, pfdir, pfseg
pf = _pbc()
pfdir = pf.'get_directory'()
- pfseg = pfdir[0]
+ $P0 = iter pfdir
+ $S0 = shift $P0
+ pfseg = pfdir[$S0]
$I0 = elements pfseg
- gt $I0, 0, DONE
- say 'not '
- DONE:
- say 'greater'
+ ok($I0, 'PackfileRawSegment contains some data')
.end
-CODE
-greater
-OUT
-
# PackfileRawSegment.get_integer_keyed_int
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'get_integer_keyed_int' );
-.sub 'test' :main
+.sub 'test_get_integer'
.local pmc pf, pfdir, pfseg
pf = _pbc()
pfdir = pf.'get_directory'()
- pfseg = pfdir[0]
+ $P0 = iter pfdir
+ $S0 = shift $P0
+ pfseg = pfdir[$S0]
+
$I0 = 0
$I1 = pfseg[0]
$I0 = $I0 + $I1
@@ -88,14 +61,8 @@
$I0 = $I0 + $I1
$I1 = pfseg[4]
$I0 = $I0 + $I1
- gt $I0, 0, DONE
- say 'not '
- DONE:
- say 'greater'
+ ok($I0, "PackfileRawSegment.get_integer_keyed_int returns some data")
.end
-CODE
-greater
-OUT
# Local Variables:
Modified: branches/headercleanup/t/pmc/packfilesegment.t
==============================================================================
--- branches/headercleanup/t/pmc/packfilesegment.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/packfilesegment.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,14 +1,7 @@
-#!perl
+#!parrot
# Copyright (C) 2009, Parrot Foundation.
# $Id$
-use strict;
-use warnings;
-use lib qw( . lib ../lib ../../lib );
-use Test::More;
-use Parrot::Test tests => 1;
-use Parrot::Config;
-
=head1 NAME
t/pmc/packfilesegment.t - test the PackfileSegment PMC
@@ -24,46 +17,13 @@
=cut
-
-# common setup code for later tests
-
-my $get_uuid_pbc = <<'EOF';
-
-.sub _pbc
- .include "stat.pasm"
- .include "interpinfo.pasm"
- .local pmc pf, pio
- pf = new ['Packfile']
- $S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
- $S0 .= "/runtime/parrot/library/uuid.pbc"
- $I0 = stat $S0, .STAT_FILESIZE
- pio = open $S0, 'r'
- $S0 = read pio, $I0
- close pio
- pf = $S0
- .return(pf)
-.end
-EOF
-
-
-# PackfileSegment.pack (via subclass PackfileDirectory)
-
-pir_output_is( <<'CODE' . $get_uuid_pbc, <<'OUT', 'set_integer_keyed_str' );
.sub 'test' :main
- .local pmc pf, pfdir
- pf = _pbc()
- pfdir = pf.'get_directory'()
- $S0 = pfdir.'pack'()
- $I0 = length $S0
- eq $I0, 0, OUT1
- print "not "
- OUT1:
- say "equal"
-.end
-CODE
-not equal
-OUT
+.include 'test_more.pir'
+ plan(1)
+ $P0 = new 'PackfileSegment'
+ isa_ok($P0, 'PackfileSegment')
+.end
# Local Variables:
# mode: cperl
Modified: branches/headercleanup/t/pmc/resizablepmcarray.t
==============================================================================
--- branches/headercleanup/t/pmc/resizablepmcarray.t Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/t/pmc/resizablepmcarray.t Tue Apr 21 21:28:29 2009 (r38254)
@@ -21,7 +21,7 @@
.include 'fp_equality.pasm'
.include 'test_more.pir'
- plan(118)
+ plan(121)
resize_tests()
negative_array_size()
@@ -47,6 +47,7 @@
iterate_subclass_of_rpa()
method_forms_of_unshift_etc()
sort_with_broken_cmp()
+ addr_tests()
.end
@@ -895,6 +896,23 @@
.return ($I0)
.end
+.sub 'addr_tests'
+ $P0 = new 'ResizablePMCArray'
+ $I0 = get_addr $P0
+ $P1 = new 'ResizablePMCArray'
+ $I1 = get_addr $P1
+
+ $I2 = $I0 != 0
+ ok($I2, 'ResizablePMCArray address is not zero')
+ $I2 = $I0 != $I1
+ ok($I2, 'Two empty RPAs do not have same address')
+
+ push $P0, 3
+ $I1 = get_addr $P0
+ is($I0, $I1, 'Adding element to RPA keeps same addr')
+.end
+
+
# don't forget to change the test plan
# Local Variables:
Copied: branches/headercleanup/t/pmc/testlib/packfile_common.pir (from r38253, trunk/t/pmc/testlib/packfile_common.pir)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/t/pmc/testlib/packfile_common.pir Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/t/pmc/testlib/packfile_common.pir)
@@ -0,0 +1,62 @@
+#! parrot
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+# Common functions for various Packfile* PMCs tests.
+# Return test filename
+# Currently parrot doesn't support system independent PBCs. So, cross your
+# fingers and try different filename for binary-dependent tests...
+
+.sub '_filename'
+ .local string filename
+ filename = 't/native_pbc/number_1.pbc'
+ .return (filename)
+.end
+
+# common pbc loading function
+.sub '_pbc'
+ .include "stat.pasm"
+ .include "interpinfo.pasm"
+ .local pmc pf, pio
+ pf = new ['Packfile']
+ #$S0 = interpinfo .INTERPINFO_RUNTIME_PREFIX
+ #$S0 .= "/runtime/parrot/library/uuid.pbc"
+ $S0 = '_filename'()
+ pio = open $S0, 'r'
+ $S0 = pio.'readall'()
+ close pio
+ pf = $S0
+ .return(pf)
+.end
+
+.sub '_find_segment_by_type'
+ .param pmc pf
+ .param string type
+ .local pmc pfdir, it
+
+ pfdir = pf.'get_directory'()
+ it = iter pfdir
+ loop:
+ unless it goto done
+ $S0 = shift it
+ $P0 = pfdir[$S0]
+ $I0 = isa $P0, type
+ unless $I0 goto loop
+ .return ($P0)
+ done:
+ .return ()
+.end
+
+.sub '_get_fixup_table'
+ .param pmc pf
+
+ .tailcall '_find_segment_by_type'(pf, "PackfileFixupTable")
+.end
+
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
Modified: branches/headercleanup/tools/build/nativecall.pl
==============================================================================
--- branches/headercleanup/tools/build/nativecall.pl Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/build/nativecall.pl Tue Apr 21 21:28:29 2009 (r38254)
@@ -554,7 +554,9 @@
jit_key_name = Parrot_str_concat(interp, jit_key_name, signature, 0);
b = VTABLE_get_pmc_keyed_str(interp, HashPointer, jit_key_name);
- if (b && b->vtable->base_type == enum_class_ManagedStruct) {
+ PARROT_ASSERT(PMC_IS_NULL(b) || b->vtable);
+
+ if ((!PMC_IS_NULL(b)) && b->vtable->base_type == enum_class_ManagedStruct) {
*jitted = 1;
return F2DPTR(VTABLE_get_pointer(interp, b));
}
@@ -584,7 +586,9 @@
b = VTABLE_get_pmc_keyed_str(interp, HashPointer, signature);
- if (b && b->vtable->base_type == enum_class_UnManagedStruct)
+ PARROT_ASSERT(PMC_IS_NULL(b) || b->vtable);
+
+ if ((!PMC_IS_NULL(b)) && b->vtable->base_type == enum_class_UnManagedStruct)
return F2DPTR(VTABLE_get_pointer(interp, b));
/*
Copied: branches/headercleanup/tools/dev/create_language.pl (from r38253, trunk/tools/dev/create_language.pl)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/headercleanup/tools/dev/create_language.pl Tue Apr 21 21:28:29 2009 (r38254, copy of r38253, trunk/tools/dev/create_language.pl)
@@ -0,0 +1,936 @@
+#! perl
+# Copyright (C) 2007-2009, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+create_language.pl -- create initial files for a new language
+
+=head1 SYNOPSIS
+
+% perl tools/dev/create_language.pl Xyz [path]
+
+=head1 DESCRIPTION
+
+This script populates a directory with files for building a
+new language translator in Parrot. The first argument is the
+name of the language to be built. The C<path> argument
+says where to populate the directory, if not given then the
+lowercase version of the language name is used.
+
+For a language 'Xyz', this script will create the following
+files and directories in C<path>:
+
+ README
+ Configure.pl
+ xyz.pir
+ build/Makefile.in
+ build/gen_builtins_pir.pl
+ build/gen_parrot.pl
+ src/pct/grammar.pg
+ src/pct/grammar-oper.pg
+ src/pct/actions.pm
+ src/builtins/say.pir
+ t/harness
+ t/00-sanity.t
+
+Any files that already exist are skipped, so this script can
+be used to repopulate a language directory with omitted files.
+
+If all goes well, after creating the language shell one can simply
+change to the language directory and type
+
+ $ make test
+
+to verify that the new language compiles and configures properly.
+
+=cut
+
+use strict;
+use warnings;
+use lib 'lib';
+use File::Path;
+use File::Spec;
+
+unless (@ARGV) {
+ die "usage: $0 language [path]\n";
+}
+
+## determine the language we're trying to build
+my $lang = $ARGV[0];
+my $lclang = lc $lang;
+my $uclang = uc $lang;
+
+## the name and revision of the script, for use in the generated README
+my $script = $0;
+my $rev = '$Revision$';
+$rev =~ s/^\D*(\d+)\D*$/r$1/;
+
+## get the path from the command line, or if not supplied then
+## use languages/$lclang.
+my $path = $ARGV[1] || $lclang;
+
+## now loop through the file information (see below), substituting
+## any instances of @lang@, @lclang@, @UCLANG@, and @Id@ with
+## the language name or the svn id tag. If the line has the form
+## __filepath__, then start a new file.
+my $fh;
+while (<DATA>) {
+ last if /^__DATA__$/;
+ s{\@lang\@} {$lang}g;
+ s{\@lclang\@} {$lclang}ig;
+ s{\@UCLANG\@} {$uclang}ig;
+ s{\@Id\@} {\$Id\$}ig;
+ s{\@script\@} {$script}ig;
+ s{\@rev\@} {$rev}ig;
+ if (/^__(.*)__$/) { start_new_file("$path/$1"); }
+ elsif ($fh) { print $fh $_; }
+}
+## close the last file
+close($fh) if $fh;
+
+print <<"END";
+
+Your new language has been created in the $path directory.
+To do an initial build and test of the language:
+
+ cd $path
+ perl Configure.pl
+ make
+ make test
+
+END
+
+## we're done
+1;
+
+
+## this function closes any previous opened file, and determines
+## if we're creating a new file. It also calls C<mkpath> to
+## create any needed parent subdirectories.
+sub start_new_file {
+ my ($filepath) = @_;
+ if ($fh) { close $fh; undef $fh; }
+ if (-e $filepath) { print "skipping $filepath\n"; return; }
+ my ($volume, $dir, $base) = File::Spec->splitpath($filepath);
+ my $filedir = File::Spec->catpath($volume, $dir);
+ unless (-d $filedir) {
+ print "creating $filedir\n";
+ mkpath($filedir);
+ }
+ print "creating $filepath\n";
+ open $fh, '>', $filepath;
+}
+
+
+
+### The section below contains the text of the files to be created.
+### The name of the file to be created is given as C<__filepath__>,
+### and all subsequent lines up to the next C<__filepath__> are
+### placed in the file (performing substitutions on @lang@, @lclang@,
+### @UCLANG@, and @Id@ as appropriate).
+
+__DATA__
+__README__
+Language '@lang@' was created with @script@, @rev at .
+
+__Configure.pl__
+#! perl
+use 5.008;
+use strict;
+use warnings;
+use Getopt::Long;
+
+MAIN: {
+ my %options;
+ GetOptions(\%options, 'help!', 'parrot-config=s',
+ 'gen-parrot!', 'gen-parrot-option=s@');
+
+ # Print help if it's requested
+ if ($options{'help'}) {
+ print_help();
+ exit(0);
+ }
+
+ # Update/generate parrot build if needed
+ if ($options{'gen-parrot'}) {
+ my @opts = @{ $options{'gen-parrot-option'} || [] };
+ my @command = ($^X, "build/gen_parrot.pl", @opts);
+
+ print "Generating Parrot ...\n";
+ print "@command\n\n";
+ system @command;
+ }
+
+ # Get a list of parrot-configs to invoke.
+ my @parrot_config_exe = qw(
+ parrot/parrot_config
+ ../../parrot_config
+ parrot_config
+ );
+
+ if ($options{'parrot-config'} && $options{'parrot-config'} ne '1') {
+ @parrot_config_exe = ($options{'parrot-config'});
+ }
+
+ # Get configuration information from parrot_config
+ my %config = read_parrot_config(@parrot_config_exe);
+ unless (%config) {
+ die <<'END';
+Unable to locate parrot_config.
+To automatically checkout (svn) and build a copy of parrot,
+try re-running Configure.pl with the '--gen-parrot' option.
+Or, use the '--parrot-config' option to explicitly specify
+the location of parrot_config.
+END
+ }
+
+# Create the Makefile using the information we just got
+ create_makefile(%config);
+
+ my $make = $config{'make'};
+ print <<"END";
+
+You can now use '$make' to build @lang at .
+After that, you can use '$make test' to run some local tests.
+
+END
+ exit 0;
+
+}
+
+
+sub read_parrot_config {
+ my @parrot_config_exe = @_;
+ my %config = ();
+ for my $exe (@parrot_config_exe) {
+ no warnings;
+ if (open my $PARROT_CONFIG, '-|', "$exe --dump") {
+ print "\nReading configuration information from $exe ...\n";
+ while (<$PARROT_CONFIG>) {
+ if (/(\w+) => '(.*)'/) { $config{$1} = $2 }
+ }
+ close $PARROT_CONFIG or die $!;
+ last if %config;
+ }
+ }
+ return %config;
+}
+
+
+# Generate a Makefile from a configuration
+sub create_makefile {
+ my %config = @_;
+
+ my $maketext = slurp( 'build/Makefile.in' );
+
+ $config{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(BUILD_DIR)\libparrot.dll .' : '';
+ $maketext =~ s/@(\w+)@/$config{$1}/g;
+ if ($^O eq 'MSWin32') {
+ $maketext =~ s{/}{\\}g;
+ $maketext =~ s{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg;
+ }
+
+ my $outfile = 'Makefile';
+ print "\nCreating $outfile ...\n";
+ open(my $MAKEOUT, '>', $outfile) ||
+ die "Unable to write $outfile\n";
+ print {$MAKEOUT} $maketext;
+ close $MAKEOUT or die $!;
+
+ return;
+}
+
+sub slurp {
+ my $filename = shift;
+
+ open my $fh, '<', $filename or die "Unable to read $filename\n";
+ local $/ = undef;
+ my $maketext = <$fh>;
+ close $fh or die $!;
+
+ return $maketext;
+}
+
+
+# Print some help text.
+sub print_help {
+ print <<'END';
+Configure.pl - @lang@ Configure
+
+General Options:
+ --help Show this text
+ --parrot-config=(config)
+ Use configuration information from config
+ --gen-parrot Download and build a copy of Parrot to use
+ --gen-parrot-option='--option=value'
+ Set parrot config option when using --gen-parrot
+END
+
+ return;
+}
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
+__build/PARROT_REVISION__
+ at rev@
+__build/Makefile.in__
+# $Id$
+
+# arguments we want to run parrot with
+PARROT_ARGS =
+
+# values from parrot_config
+BUILD_DIR = @build_dir@
+LOAD_EXT = @load_ext@
+O = @o@
+EXE = @exe@
+MAKE = @make_c@
+PERL = @perl@
+RM_F = @rm_f@
+HAS_ICU = @has_icu@
+
+# Various paths
+PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
+PERL6GRAMMAR = $(BUILD_DIR)/runtime/parrot/library/PGE/Perl6Grammar.pbc
+NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc
+PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
+PMC_DIR = src/pmc
+OPSDIR = src/ops
+OPSLIB = @lclang@
+OPS_FILE = src/ops/@lclang at .ops
+
+# Setup some commands
+PARROT = $(BUILD_DIR)/parrot$(EXE)
+CAT = $(PERL) -MExtUtils::Command -e cat
+BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
+BUILD_DYNOPS = $(PERL) $(BUILD_DIR)/tools/build/dynoplibs.pl
+PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe$(EXE)
+
+SOURCES = @lclang at .pir \
+ src/gen_grammar.pir \
+ src/gen_actions.pir \
+ src/gen_builtins.pir \
+ $(@uclang at _GROUP)
+
+BUILTINS_PIR = \
+ src/builtins/say.pir \
+
+# PMCS = @lclang@
+# PMC_SOURCES = $(PMC_DIR)/@lclang at .pmc
+# @uclang at _GROUP = $(PMC_DIR)/@lclang at _group$(LOAD_EXT)
+
+CLEANUPS = \
+ @lclang at .pbc \
+ @lclang at .c \
+ *.manifest \
+ *.pdb \
+ @lclang@$(O) \
+ @lclang@$(EXE) \
+ src/gen_*.pir \
+ src/gen_*.pm \
+ $(PMC_DIR)/*.h \
+ $(PMC_DIR)/*.c \
+ $(PMC_DIR)/*.dump \
+ $(PMC_DIR)/*$(O) \
+ $(PMC_DIR)/*$(LOAD_EXT) \
+ $(PMC_DIR)/*.exp \
+ $(PMC_DIR)/*.ilk \
+ $(PMC_DIR)/*.manifest \
+ $(PMC_DIR)/*.pdb \
+ $(PMC_DIR)/*.lib \
+ $(PMC_DIR)/objectref.pmc \
+ $(OPSDIR)/*.h \
+ $(OPSDIR)/*.c \
+ $(OPSDIR)/*$(O) \
+ $(OPSDIR)/*$(LOAD_EXT) \
+
+HARNESS = $(PERL) t/harness --keep-exit-code --icu=$(HAS_ICU)
+HARNESS_JOBS = $(HARNESS) --jobs
+
+# the default target
+all: @lclang@$(EXE)
+
+## targets for building a standalone executable
+ at lclang@$(EXE): @lclang at .pbc
+ $(PBC_TO_EXE) @lclang at .pbc
+ @win32_libparrot_copy@
+
+# the compiler .pbc
+ at lclang@.pbc: Makefile $(PARROT) $(SOURCES) $(BUILTINS_PIR)
+ $(PARROT) $(PARROT_ARGS) -o @lclang at .pbc @lclang at .pir
+
+src/gen_grammar.pir: $(PARROT) $(PERL6GRAMMAR) src/pct/grammar.pg src/pct/grammar-oper.pg
+ $(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
+ --output=src/gen_grammar.pir \
+ src/pct/grammar.pg src/pct/grammar-oper.pg
+
+src/gen_actions.pir: $(PARROT) $(NQP) $(PCT) src/pct/actions.pm
+ $(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
+ --encoding=fixed_8 --target=pir src/pct/actions.pm
+
+src/gen_builtins.pir: Makefile build/gen_builtins_pir.pl
+ $(PERL) build/gen_builtins_pir.pl $(BUILTINS_PIR) > src/gen_builtins.pir
+
+$(@uclang at _GROUP): Makefile $(PARROT) $(PMC_SOURCES)
+ cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS)
+ cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS)
+ cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS)
+ cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS)
+
+src/ops/@lclang at _ops$(LOAD_EXT) : $(PARROT) $(OPS_FILE)
+ @cd $(OPSDIR) && $(BUILD_DYNOPS) generate $(OPSLIB)
+ @cd $(OPSDIR) && $(BUILD_DYNOPS) compile $(OPSLIB)
+ @cd $(OPSDIR) && $(BUILD_DYNOPS) linklibs $(OPSLIB)
+ @cd $(OPSDIR) && $(BUILD_DYNOPS) copy "--destination=$(PARROT_DYNEXT)" $(OPSLIB)
+
+## local copy of Parrot
+parrot: parrot/parrot_config build/PARROT_REVISION
+ $(PERL) build/gen_parrot.pl
+
+parrot/parrot_config:
+ @echo "Don't see parrot/parrot_config."
+
+test: @lclang@$(EXE)
+ $(PERL) t/harness t/
+
+# Run a single test
+t/*.t t/*/*.t t/*/*/*.t: all Test.pir
+ @$(HARNESS_WITH_FUDGE) --verbosity=1 $@
+
+## cleaning
+clean:
+ $(RM_F) $(CLEANUPS)
+
+distclean: realclean
+
+realclean: clean
+ $(RM_F) src/utils/Makefile Makefile
+
+testclean:
+
+
+## miscellaneous targets
+# a listing of all targets meant to be called by users
+help:
+ @echo ""
+ @echo "Following targets are available for the user:"
+ @echo ""
+ @echo " all: @lclang at .exe"
+ @echo " This is the default."
+ @echo ""
+ @echo "Testing:"
+ @echo " test: Run Rakudo's sanity tests."
+ @echo ""
+ @echo "Cleaning:"
+ @echo " clean: Basic cleaning up."
+ @echo " distclean: Removes also anything built, in theory."
+ @echo " realclean: Removes also files generated by 'Configure.pl'."
+ @echo " testclean: Clean up test results."
+ @echo ""
+ @echo "Misc:"
+ @echo " help: Print this help message."
+ @echo ""
+
+Makefile: build/Makefile.in
+ @echo ""
+ @echo "warning: Makefile is out of date... re-run Configure.pl"
+ @echo ""
+
+manifest:
+ echo MANIFEST >MANIFEST
+ git ls-files | $(PERL) -ne '/^\./ || print' >>MANIFEST
+
+release: manifest
+ [ -n "$(VERSION)" ] || ( echo "\nTry 'make release VERSION=yyyymm'\n\n"; exit 1 )
+ [ -d @lclang at -$(VERSION) ] || ln -s . @lclang at -$(VERSION)
+ $(PERL) -ne 'print "@lclang at -$(VERSION)/$$_"' MANIFEST | \
+ tar -zcv -T - -f @lclang at -$(VERSION).tar.gz
+ rm @lclang at -$(VERSION)
+
+__build/gen_builtins_pir.pl__
+#!/usr/bin/perl
+# $Id$
+
+use strict;
+use warnings;
+
+my @files = @ARGV;
+
+print <<"END_PRELUDE";
+# This file automatically generated by $0.
+
+END_PRELUDE
+
+foreach my $file (@files) {
+ print ".include '$file'\n";
+}
+
+
+__build/gen_parrot.pl__
+#! perl
+
+=head1 TITLE
+
+gen_parrot.pl - script to obtain and build Parrot
+
+=head2 SYNOPSIS
+
+ perl gen_parrot.pl [--parrot --configure=options]
+
+=head2 DESCRIPTION
+
+Maintains an appropriate copy of Parrot in the parrot/ subdirectory.
+The revision of Parrot to be used in the build is given by the
+build/PARROT_REVISION file.
+
+=cut
+
+use strict;
+use warnings;
+use 5.008;
+
+# Work out slash character to use.
+my $slash = $^O eq 'MSWin32' ? '\\' : '/';
+
+## determine what revision of Parrot we require
+open my $REQ, "build/PARROT_REVISION"
+ || die "cannot open build/PARROT_REVISION\n";
+my $required = 0+<$REQ>;
+close $REQ;
+
+{
+ no warnings;
+ if (open my $REV, '-|', "parrot${slash}parrot_config revision") {
+ my $revision = 0+<$REV>;
+ close $REV;
+ if ($revision >= $required) {
+ print "Parrot r$revision already available (r$required required)\n";
+ exit(0);
+ }
+ }
+}
+
+print "Checking out Parrot r$required via svn...\n";
+system(qw(svn checkout -r), $required , qw(https://svn.parrot.org/parrot/trunk parrot));
+
+chdir('parrot');
+
+
+## If we have a Makefile from a previous build, do a 'make realclean'
+if (-f 'Makefile') {
+ my %config = read_parrot_config();
+ my $make = $config{'make'};
+ if ($make) {
+ print "\nPerforming '$make realclean' ...\n";
+ system($make, "realclean");
+ }
+}
+
+print "\nConfiguring Parrot ...\n";
+my @config_command = ($^X, 'Configure.pl', @ARGV);
+print "@config_command\n";
+system @config_command;
+
+print "\nBuilding Parrot ...\n";
+my %config = read_parrot_config();
+my $make = $config{'make'} or exit(1);
+system($make);
+
+sub read_parrot_config {
+ my %config = ();
+ if (open my $CFG, "config_lib.pasm") {
+ while (<$CFG>) {
+ if (/P0\["(.*?)"], "(.*?)"/) { $config{$1} = $2 }
+ }
+ close $CFG;
+ }
+ %config;
+}
+
+__ at lclang@.pir__
+=head1 TITLE
+
+ at lclang@.pir - A @lang@ compiler.
+
+=head2 Description
+
+This is the base file for the @lang@ compiler.
+
+This file includes the parsing and grammar rules from
+the src/ directory, loads the relevant PGE libraries,
+and registers the compiler under the name '@lang@'.
+
+=head2 Functions
+
+=over 4
+
+=item onload()
+
+Creates the @lang@ compiler using a C<PCT::HLLCompiler>
+object.
+
+=cut
+
+.HLL '@lclang@'
+
+.namespace [ '@lang@';'Compiler' ]
+
+.loadlib '@lclang at _group'
+
+.sub '' :anon :load :init
+ load_bytecode 'PCT.pbc'
+ .local pmc parrotns, hllns, exports
+ parrotns = get_root_namespace ['parrot']
+ hllns = get_hll_namespace
+ exports = split ' ', 'PAST PCT PGE'
+ parrotns.'export_to'(hllns, exports)
+.end
+
+.include 'src/gen_grammar.pir'
+.include 'src/gen_actions.pir'
+
+.sub 'onload' :anon :load :init
+ $P0 = get_hll_global ['PCT'], 'HLLCompiler'
+ $P1 = $P0.'new'()
+ $P1.'language'('@lclang@')
+ $P0 = get_hll_namespace ['@lang@';'Grammar']
+ $P1.'parsegrammar'($P0)
+ $P0 = get_hll_namespace ['@lang@';'Grammar';'Actions']
+ $P1.'parseactions'($P0)
+.end
+
+=item main(args :slurpy) :main
+
+Start compilation by passing any command line C<args>
+to the @lang@ compiler.
+
+=cut
+
+.sub 'main' :main
+ .param pmc args
+
+ $P0 = compreg '@lclang@'
+ $P1 = $P0.'command_line'(args)
+.end
+
+.include 'src/gen_builtins.pir'
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
+__src/pct/grammar.pg__
+# @Id@
+
+=begin overview
+
+This is the grammar for @lang@ written as a sequence of Perl 6 rules.
+
+=end overview
+
+grammar @lang@::Grammar is PCT::Grammar;
+
+rule TOP {
+ <statement>*
+ [ $ || <panic: 'Syntax error'> ]
+ {*}
+}
+
+## this <ws> rule treats # as "comment to eol"
+## you may want to replace it with something appropriate
+token ws {
+ <!ww>
+ [ '#' \N* \n? | \s+ ]*
+}
+
+rule statement {
+ 'say' <expression> [ ',' <expression> ]* ';'
+ {*}
+}
+
+rule value {
+ | <integer> {*} #= integer
+ | <quote> {*} #= quote
+}
+
+token integer { \d+ {*} }
+
+token quote {
+ [ \' <string_literal: '\'' > \' | \" <string_literal: '"' > \" ]
+ {*}
+}
+
+## terms
+token term {
+ | <value> {*} #= value
+}
+
+rule expression is optable { ... }
+
+__src/pct/grammar-oper.pg__
+# @Id@
+
+## expressions and operators
+proto 'term:' is precedence('=') is parsed(&term) { ... }
+
+## multiplicative operators
+proto infix:<*> is looser(term:) is pirop('mul') { ... }
+proto infix:</> is equiv(infix:<*>) is pirop('div') { ... }
+
+## additive operators
+proto infix:<+> is looser(infix:<*>) is pirop('add') { ... }
+proto infix:<-> is equiv(infix:<+>) is pirop('sub') { ... }
+
+__src/pct/actions.pm__
+# @Id@
+
+=begin comments
+
+ at lang@::Grammar::Actions - ast transformations for @lang@
+
+This file contains the methods that are used by the parse grammar
+to build the PAST representation of an @lang@ program.
+Each method below corresponds to a rule in F<src/parser/grammar.pg>,
+and is invoked at the point where C<{*}> appears in the rule,
+with the current match object as the first argument. If the
+line containing C<{*}> also has a C<#= key> comment, then the
+value of the comment is passed as the second argument to the method.
+
+=end comments
+
+class @lang@::Grammar::Actions;
+
+method TOP($/) {
+ my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ), :hll('@lang@') );
+ for $<statement> {
+ $past.push( $_.ast );
+ }
+ make $past;
+}
+
+
+method statement($/) {
+ my $past := PAST::Op.new( :name('say'), :pasttype('call'), :node( $/ ) );
+ for $<expression> {
+ $past.push( $_.ast );
+ }
+ make $past;
+}
+
+## expression:
+## This is one of the more complex transformations, because
+## our grammar is using the operator precedence parser here.
+## As each node in the expression tree is reduced by the
+## parser, it invokes this method with the operator node as
+## the match object and a $key of 'reduce'. We then build
+## a PAST::Op node using the information provided by the
+## operator node. (Any traits for the node are held in $<top>.)
+## Finally, when the entire expression is parsed, this method
+## is invoked with the expression in $<expr> and a $key of 'end'.
+method expression($/, $key) {
+ if ($key eq 'end') {
+ make $<expr>.ast;
+ }
+ else {
+ my $past := PAST::Op.new( :name($<type>),
+ :pasttype($<top><pasttype>),
+ :pirop($<top><pirop>),
+ :lvalue($<top><lvalue>),
+ :node($/)
+ );
+ for @($/) {
+ $past.push( $_.ast );
+ }
+ make $past;
+ }
+}
+
+
+## term:
+## Like 'statement' above, the $key has been set to let us know
+## which term subrule was matched.
+method term($/, $key) {
+ make $/{$key}.ast;
+}
+
+
+method value($/, $key) {
+ make $/{$key}.ast;
+}
+
+
+method integer($/) {
+ make PAST::Val.new( :value( ~$/ ), :returns('Integer'), :node($/) );
+}
+
+
+method quote($/) {
+ make PAST::Val.new( :value( $<string_literal>.ast ), :node($/) );
+}
+
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
+__src/builtins/say.pir__
+# @Id@
+
+=head1
+
+say.pir -- simple implementation of a say function
+
+=cut
+
+.namespace []
+
+.sub 'say'
+ .param pmc args :slurpy
+ .local pmc iter
+ iter = new 'Iterator', args
+ iter_loop:
+ unless iter goto iter_end
+ $P0 = shift iter
+ print $P0
+ goto iter_loop
+ iter_end:
+ print "\n"
+ .return ()
+.end
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
+__t/harness__
+#! perl
+
+# $Id$
+
+use strict;
+use warnings;
+
+use FindBin;
+use File::Spec;
+use Getopt::Long qw(:config pass_through);
+
+$ENV{'HARNESS_PERL'} = './@lclang@';
+use Test::Harness;
+$Test::Harness::switches = '';
+
+GetOptions(
+ 'tests-from-file=s' => \my $list_file,
+ 'verbosity=i' => \$Test::Harness::verbose,
+ 'jobs:3' => \my $jobs,
+ 'icu:1' => \my $do_icu,
+);
+
+my @pass_through_options = grep m/^--?[^-]/, @ARGV;
+my @files = grep m/^[^-]/, @ARGV;
+
+my $slash = $^O eq 'MSWin32' ? '\\' : '/';
+
+if ($list_file) {
+ open(my $f, '<', $list_file)
+ or die "Can't open file '$list_file' for reading: $!";
+ while (<$f>) {
+ next if m/^\s*#/;
+ next unless m/\S/;
+ chomp;
+ my ($fn, $flags) = split /\s+#\s*/;
+ next if ($flags && ($flags =~ m/icu/) && !$do_icu);
+ $fn = "t/spec/$fn" unless $fn =~ m/^t\Q$slash\Espec\Q$slash\E/;
+ $fn =~ s{/}{$slash}g;
+ if ( -r $fn ) {
+ push @files, $fn;
+ }
+ else {
+ warn "Missing test file: $fn\n";
+ }
+ }
+ close $f or die $!;
+}
+
+my @tfiles = map { all_in($_) } sort @files;
+
+if (eval { require TAP::Harness; 1 }) {
+ my %harness_options = (
+ exec => ['./perl6'],
+ verbosity => 0+$Test::Harness::verbose,
+ jobs => $jobs || 1,
+ );
+ TAP::Harness->new( \%harness_options )->runtests(@tfiles);
+}
+else {
+ runtests(@tfiles);
+}
+
+# adapted to return only files ending in '.t'
+sub all_in {
+ my $start = shift;
+
+ return $start unless -d $start;
+
+ my @skip = ( File::Spec->updir, File::Spec->curdir, qw( .svn CVS .git ) );
+ my %skip = map {($_,1)} @skip;
+
+ my @hits = ();
+
+ if ( opendir( my $dh, $start ) ) {
+ my @files = sort readdir $dh;
+ closedir $dh or die $!;
+ for my $file ( @files ) {
+ next if $skip{$file};
+
+ my $currfile = File::Spec->catfile( $start, $file );
+ if ( -d $currfile ) {
+ push( @hits, all_in( $currfile ) );
+ }
+ else {
+ push( @hits, $currfile ) if $currfile =~ /\.t$/;
+ }
+ }
+ }
+ else {
+ warn "$start: $!\n";
+ }
+
+ return @hits;
+}
+
+__t/00-sanity.t__
+# This just checks that the basic parsing and call to builtin say() works.
+say '1..4';
+say 'ok 1';
+say 'ok ', 2;
+say 'ok ', 2 + 1;
+say 'ok', ' ', 4;
+
+__DATA__
+
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
+
Modified: branches/headercleanup/tools/dev/fetch_languages.pl
==============================================================================
--- branches/headercleanup/tools/dev/fetch_languages.pl Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/dev/fetch_languages.pl Tue Apr 21 21:28:29 2009 (r38254)
@@ -63,8 +63,8 @@
{
name => 'cardinal',
- scm => 'SVN',
- repository => 'https://svn.parrot.org/languages/cardinal/trunk'
+ scm => 'GIT',
+ repository => 'git://github.com/cardinal/cardinal.git'
},
{
Modified: branches/headercleanup/tools/dev/mk_language_shell.pl
==============================================================================
--- branches/headercleanup/tools/dev/mk_language_shell.pl Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/dev/mk_language_shell.pl Tue Apr 21 21:28:29 2009 (r38254)
@@ -316,7 +316,7 @@
CFLAGS := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
CC_OUT := @cc_o_out@
LD_OUT := @ld_out@
-#IF(parrot_is_shared):LIBPARROT := @libparrot_ldflags@
+#IF(parrot_is_shared):LIBPARROT := @inst_libparrot_ldflags@
#ELSE:LIBPARROT :=
OPS2C := $(PERL) $(LIB_DIR)/tools/build/ops2c.pl
@@ -409,7 +409,7 @@
CFLAGS := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
CC_OUT := @cc_o_out@
LD_OUT := @ld_out@
-#IF(parrot_is_shared):LIBPARROT := @libparrot_ldflags@
+#IF(parrot_is_shared):LIBPARROT := @inst_libparrot_ldflags@
#ELSE:LIBPARROT :=
PMC2C_INCLUDES := --include $(SRC_DIR) --include $(SRC_DIR)/pmc
Modified: branches/headercleanup/tools/dev/pbc_to_exe.pir
==============================================================================
--- branches/headercleanup/tools/dev/pbc_to_exe.pir Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/dev/pbc_to_exe.pir Tue Apr 21 21:28:29 2009 (r38254)
@@ -352,16 +352,16 @@
embed_manifest:
# MSVC app manifest exists, embed it
- .local string embed_manifest
- embed_manifest = 'mt.exe -nologo -manifest '
- embed_manifest .= manifest_file_name
- embed_manifest .= ' -outputresource:'
- embed_manifest .= exefile
- embed_manifest .= ';1'
+ .local string embed_manifest_str
+ embed_manifest_str = 'mt.exe -nologo -manifest '
+ embed_manifest_str .= manifest_file_name
+ embed_manifest_str .= ' -outputresource:'
+ embed_manifest_str .= exefile
+ embed_manifest_str .= ';1'
- say embed_manifest
+ say embed_manifest_str
.local int embed_manifest_status
- embed_manifest_status = spawnw embed_manifest
+ embed_manifest_status = spawnw embed_manifest_str
unless embed_manifest_status goto linked
die 'manifest embedding failed'
Modified: branches/headercleanup/tools/install/smoke_languages.pl
==============================================================================
--- branches/headercleanup/tools/install/smoke_languages.pl Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/install/smoke_languages.pl Tue Apr 21 21:28:29 2009 (r38254)
@@ -364,7 +364,7 @@
$filename = 'test.py';
open $FH, '>', $filename
or die "Can't open $filename ($!).\n";
-print $FH "print 'Hello, World!'\n";
+print $FH "print('Hello, World!')\n";
close $FH;
$out = `$parrot $langdir/pynie/pynie.pbc $filename`;
ok($out eq "Hello, World!\n", "check pynie");
Modified: branches/headercleanup/tools/util/release.json
==============================================================================
--- branches/headercleanup/tools/util/release.json Tue Apr 21 21:10:14 2009 (r38253)
+++ branches/headercleanup/tools/util/release.json Tue Apr 21 21:28:29 2009 (r38254)
@@ -1,9 +1,9 @@
{
- "release.version" : "1.0.0",
- "release.name" : "Haru Tatsu",
+ "release.version" : "1.1.0",
+ "release.name" : "Half-moon Conure",
"release.day" : "Tuesday",
- "release.date" : "17 March 2009",
- "release.nextdate" : "21 April 2009",
+ "release.date" : "21 April 2009",
+ "release.nextdate" : "19 May 2009",
"web.root" : "http://parrot.org/",
"web.source" : "download",
@@ -11,13 +11,13 @@
"web.repository" : "https://svn.parrot.org/parrot/trunk/",
"bugday.day" : "Saturday",
- "bugday.date" : "18 Mar 2009",
+ "bugday.date" : "16 May 2009",
"wiki.root" : "https://trac.parrot.org/parrot/wiki/",
- "wiki.bugday" : "bug_day_2009_04_18",
+ "wiki.bugday" : "bug_day_2009_05_16",
"cpan.search" : "http://search.cpan.org/dist/parrot",
- "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/stable/1.0.0/",
+ "ftp.path" : "ftp://ftp.parrot.org/pub/parrot/releases/stable/1.1.0/",
"subversion.root" : "http://subversion.tigris.org/",
"svk.root" : "http://svk.bestpractical.com/"
}
More information about the parrot-commits
mailing list