[svn:parrot] r44053 - in branches/rm_cflags: . compilers/data_json compilers/imcc compilers/json compilers/nqp compilers/pct compilers/pge compilers/tge config/auto/sizes docs/book/draft docs/book/pct docs/dev docs/pdds examples/embed examples/languages/abc examples/languages/squaak examples/pge ext/nqp-rx include/parrot lib/Parrot lib/Parrot/Configure/Step ports/cpan ports/cygwin ports/debian ports/fedora ports/mandriva ports/suse runtime/parrot/languages runtime/parrot/library runtime/parrot/library/Math runtime/parrot/library/Math/Random src/call src/gc src/interp src/pmc src/runcore t/compilers/tge t/library t/native_pbc t/oo t/pmc t/src t/steps/init/hints tools/build tools/dev tools/util

coke at svn.parrot.org coke at svn.parrot.org
Tue Feb 16 21:56:14 UTC 2010


Author: coke
Date: Tue Feb 16 21:56:13 2010
New Revision: 44053
URL: https://trac.parrot.org/parrot/changeset/44053

Log:
merge latest changes from trunk.

(again)

(we need to figure out where all these wrong mergeinfo records are coming from)

Added:
   branches/rm_cflags/src/pmc/opcode.pmc
      - copied unchanged from r44052, trunk/src/pmc/opcode.pmc
   branches/rm_cflags/src/pmc/oplib.pmc
      - copied unchanged from r44052, trunk/src/pmc/oplib.pmc
   branches/rm_cflags/t/pmc/opcode.t
      - copied unchanged from r44052, trunk/t/pmc/opcode.t
   branches/rm_cflags/t/pmc/oplib.t
      - copied unchanged from r44052, trunk/t/pmc/oplib.t
Modified:
   branches/rm_cflags/   (props changed)
   branches/rm_cflags/PBC_COMPAT
   branches/rm_cflags/compilers/data_json/Rules.mak   (props changed)
   branches/rm_cflags/compilers/imcc/Rules.mak   (props changed)
   branches/rm_cflags/compilers/json/Rules.mak   (props changed)
   branches/rm_cflags/compilers/nqp/Rules.mak   (props changed)
   branches/rm_cflags/compilers/pct/Rules.mak   (props changed)
   branches/rm_cflags/compilers/pge/Rules.mak   (props changed)
   branches/rm_cflags/compilers/tge/Rules.mak   (props changed)
   branches/rm_cflags/config/auto/sizes/intval_maxmin_c.in   (props changed)
   branches/rm_cflags/docs/book/draft/README   (props changed)
   branches/rm_cflags/docs/book/draft/appa_glossary.pod   (props changed)
   branches/rm_cflags/docs/book/draft/appb_patch_submission.pod   (props changed)
   branches/rm_cflags/docs/book/draft/appc_command_line_options.pod   (props changed)
   branches/rm_cflags/docs/book/draft/appd_build_options.pod   (props changed)
   branches/rm_cflags/docs/book/draft/appe_source_code.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch01_introduction.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch02_getting_started.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch07_dynpmcs.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch08_dynops.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch10_opcode_reference.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch11_directive_reference.pod   (props changed)
   branches/rm_cflags/docs/book/draft/ch12_operator_reference.pod   (props changed)
   branches/rm_cflags/docs/book/draft/chXX_hlls.pod   (props changed)
   branches/rm_cflags/docs/book/draft/chXX_library.pod   (props changed)
   branches/rm_cflags/docs/book/draft/chXX_testing_and_debugging.pod   (props changed)
   branches/rm_cflags/docs/book/pct/ch01_introduction.pod   (props changed)
   branches/rm_cflags/docs/book/pct/ch02_getting_started.pod   (props changed)
   branches/rm_cflags/docs/book/pct/ch03_compiler_tools.pod   (props changed)
   branches/rm_cflags/docs/book/pct/ch04_pge.pod   (props changed)
   branches/rm_cflags/docs/book/pct/ch05_nqp.pod   (props changed)
   branches/rm_cflags/docs/dev/c_functions.pod   (props changed)
   branches/rm_cflags/docs/pdds/pdd30_install.pod   (props changed)
   branches/rm_cflags/examples/embed/cotorra.c   (props changed)
   branches/rm_cflags/examples/languages/abc/   (props changed)
   branches/rm_cflags/examples/languages/squaak/   (props changed)
   branches/rm_cflags/examples/pge/demo.pir   (props changed)
   branches/rm_cflags/ext/nqp-rx/Rules.mak   (props changed)
   branches/rm_cflags/include/parrot/call.h   (props changed)
   branches/rm_cflags/include/parrot/gc_api.h   (props changed)
   branches/rm_cflags/include/parrot/runcore_api.h   (props changed)
   branches/rm_cflags/include/parrot/runcore_profiling.h   (props changed)
   branches/rm_cflags/include/parrot/runcore_trace.h   (props changed)
   branches/rm_cflags/lib/Parrot/Configure/Step/Test.pm   (props changed)
   branches/rm_cflags/lib/Parrot/H2inc.pm   (props changed)
   branches/rm_cflags/ports/cpan/pause_guide.pod   (props changed)
   branches/rm_cflags/ports/cygwin/parrot-1.0.0-1.cygport   (props changed)
   branches/rm_cflags/ports/debian/libparrot-dev.install.in   (props changed)
   branches/rm_cflags/ports/debian/libparrot.install.in   (props changed)
   branches/rm_cflags/ports/debian/parrot-doc.install.in   (props changed)
   branches/rm_cflags/ports/debian/parrot.install.in   (props changed)
   branches/rm_cflags/ports/fedora/parrot.spec.fedora   (props changed)
   branches/rm_cflags/ports/mandriva/parrot.spec.mandriva   (props changed)
   branches/rm_cflags/ports/suse/parrot.spec.suse   (props changed)
   branches/rm_cflags/runtime/parrot/languages/   (props changed)
   branches/rm_cflags/runtime/parrot/library/Math/Rand.pir   (props changed)
   branches/rm_cflags/runtime/parrot/library/Math/Random/mt19937ar.pir   (props changed)
   branches/rm_cflags/runtime/parrot/library/Rules.mak   (props changed)
   branches/rm_cflags/src/call/ops.c   (props changed)
   branches/rm_cflags/src/call/pcc.c   (props changed)
   branches/rm_cflags/src/gc/alloc_memory.c   (props changed)
   branches/rm_cflags/src/gc/alloc_resources.c   (props changed)
   branches/rm_cflags/src/gc/api.c   (props changed)
   branches/rm_cflags/src/gc/malloc.c   (props changed)
   branches/rm_cflags/src/gc/malloc_trace.c   (props changed)
   branches/rm_cflags/src/gc/mark_sweep.c   (props changed)
   branches/rm_cflags/src/gc/system.c   (props changed)
   branches/rm_cflags/src/interp/inter_cb.c   (props changed)
   branches/rm_cflags/src/interp/inter_create.c   (props changed)
   branches/rm_cflags/src/interp/inter_misc.c   (props changed)
   branches/rm_cflags/src/pmc/pmc.num
   branches/rm_cflags/src/runcore/cores.c   (props changed)
   branches/rm_cflags/src/runcore/main.c   (props changed)
   branches/rm_cflags/src/runcore/profiling.c   (props changed)
   branches/rm_cflags/src/runcore/trace.c   (props changed)
   branches/rm_cflags/t/compilers/tge/NoneGrammar.tg   (props changed)
   branches/rm_cflags/t/library/mt19937ar.t   (props changed)
   branches/rm_cflags/t/library/mt19937ar.txt   (props changed)
   branches/rm_cflags/t/native_pbc/annotations.pbc
   branches/rm_cflags/t/native_pbc/integer_1.pbc
   branches/rm_cflags/t/native_pbc/number_1.pbc
   branches/rm_cflags/t/native_pbc/string_1.pbc
   branches/rm_cflags/t/oo/root_new.t   (props changed)
   branches/rm_cflags/t/pmc/namespace-old.t   (props changed)
   branches/rm_cflags/t/pmc/pmc.t
   branches/rm_cflags/t/src/embed.t   (props changed)
   branches/rm_cflags/t/steps/init/hints/linux-01.t   (props changed)
   branches/rm_cflags/tools/build/h2inc.pl   (props changed)
   branches/rm_cflags/tools/dev/fetch_languages.pl   (props changed)
   branches/rm_cflags/tools/dev/mk_gitignore.pl   (props changed)
   branches/rm_cflags/tools/util/perlcritic-cage.conf   (props changed)

Modified: branches/rm_cflags/PBC_COMPAT
==============================================================================
--- branches/rm_cflags/PBC_COMPAT	Tue Feb 16 21:40:19 2010	(r44052)
+++ branches/rm_cflags/PBC_COMPAT	Tue Feb 16 21:56:13 2010	(r44053)
@@ -27,6 +27,7 @@
 
 # please insert tab separated entries at the top of the list
 
+6.3	2010.02.16	whiteknight	Add OpLib and Opcode PMCs
 6.2	2010.01.31	cotto	serialization-related changes to ParrotInterpreter
 6.1	2010.01.30	whiteknight	remove Array PMC
 6.0	2010.01.19	chromatic	released 2.0.0

Copied: branches/rm_cflags/src/pmc/opcode.pmc (from r44052, trunk/src/pmc/opcode.pmc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/rm_cflags/src/pmc/opcode.pmc	Tue Feb 16 21:56:13 2010	(r44053, copy of r44052, trunk/src/pmc/opcode.pmc)
@@ -0,0 +1,67 @@
+#include "parrot/parrot.h"
+
+pmclass Opcode auto_attrs {
+    ATTR op_info_t *info;
+    ATTR INTVAL op_number;
+    ATTR STRING *full_name_cache;
+
+    VTABLE void init() {
+        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+            "Opcode must be created from OpLib.");
+    }
+
+    VTABLE void mark() {
+        Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+        if (attrs->full_name_cache)
+            Parrot_gc_mark_STRING_alive(INTERP, attrs->full_name_cache);
+    }
+
+    VTABLE void set_pointer(void *i) {
+        Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+        if (attrs->info)
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Opcode has already been initialized");
+        attrs->info = (op_info_t *)i;
+    }
+
+    VTABLE void set_string_native(STRING *name) {
+        char * cstr = Parrot_str_to_cstring(INTERP, name);
+        const INTVAL num = INTERP->op_lib->op_code(cstr, 1);
+        Parrot_str_free_cstring(cstr);
+        if (num == -1)
+            Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+                "Opcode: Opcode %S not found", name);
+        VTABLE_set_integer_native(INTERP, SELF, num);
+    }
+
+    VTABLE INTVAL get_integer() {
+        Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+        if (!attrs->info)
+            return -1;
+        return attrs->op_number;
+    }
+
+    VTABLE void set_integer_native(INTVAL value) {
+        const INTVAL opcount = INTERP->op_lib->op_count;
+        Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+        if (attrs->info)
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+                "Opcode has already been initialized");
+        if (value >= opcount || value < 0)
+            Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+                "Opcode: Opcode index %d out of bounds", value);
+        attrs->info = &(INTERP->op_info_table[value]);
+        attrs->op_number = value;
+    }
+
+    VTABLE STRING* get_string() {
+        Parrot_Opcode_attributes * const attrs = PARROT_OPCODE(SELF);
+        if (attrs->full_name_cache == NULL) {
+            const char * const name = attrs->info->full_name;
+            const INTVAL len = strlen(name);
+            STRING * const newstr = Parrot_str_new(INTERP, name, len);
+            attrs->full_name_cache = newstr;
+        }
+        return attrs->full_name_cache;
+    }
+}

Copied: branches/rm_cflags/src/pmc/oplib.pmc (from r44052, trunk/src/pmc/oplib.pmc)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/rm_cflags/src/pmc/oplib.pmc	Tue Feb 16 21:56:13 2010	(r44053, copy of r44052, trunk/src/pmc/oplib.pmc)
@@ -0,0 +1,54 @@
+#include "parrot/parrot.h"
+
+/* TODO: Since Opcode PMCs are essentially read-only after initialization
+         here, we should cache them. A FixedPMCArray would be okay, an
+         INTVAL->PMC HASH might be better, since it's unlike that we will
+         need to cache even a majority of the ~1300 ops. */
+static PMC *OPLIB_PMC_INSTANCE;
+pmclass OpLib {
+    void class_init() {
+        OPLIB_PMC_INSTANCE = NULL;
+    }
+
+    VTABLE void *get_pointer() {
+        return OPLIB_PMC_INSTANCE;
+    }
+
+    VTABLE void set_pointer(void *ptr) {
+        OPLIB_PMC_INSTANCE = (PMC *)ptr;
+    }
+
+    /* Look up an opnumber given the name of the op. First we look for the
+       specific name, then the more general short name. */
+    VTABLE INTVAL get_integer_keyed_str(STRING *name) {
+        char * cstr = Parrot_str_to_cstring(INTERP, name);
+        INTVAL num = INTERP->op_lib->op_code(cstr, 1);
+        if (num == -1)
+            num = INTERP->op_lib->op_code(cstr, 0);
+        Parrot_str_free_cstring(cstr);
+        return num;
+    }
+
+    VTABLE PMC* get_pmc_keyed_str(STRING *name) {
+        PMC * const op = pmc_new_noinit(INTERP, enum_class_Opcode);
+        VTABLE_set_string_native(INTERP, op, name);
+        PObj_custom_mark_SET(op);
+        return op;
+    }
+
+    VTABLE PMC* get_pmc_keyed(PMC *key) {
+        STRING * const strkey = VTABLE_get_string(INTERP, key);
+        return VTABLE_get_pmc_keyed_str(INTERP, SELF, strkey);
+    }
+
+    VTABLE PMC* get_pmc_keyed_int(INTVAL value) {
+        PMC * const op = pmc_new_noinit(INTERP, enum_class_Opcode);
+        VTABLE_set_integer_native(INTERP, op, value);
+        PObj_custom_mark_SET(op);
+        return op;
+    }
+
+    VTABLE INTVAL get_integer() {
+        return INTERP->op_lib->op_count;
+    }
+}

Modified: branches/rm_cflags/src/pmc/pmc.num
==============================================================================
--- branches/rm_cflags/src/pmc/pmc.num	Tue Feb 16 21:40:19 2010	(r44052)
+++ branches/rm_cflags/src/pmc/pmc.num	Tue Feb 16 21:56:13 2010	(r44053)
@@ -79,3 +79,6 @@
 
 os.pmc    51
 file.pmc    52
+
+oplib.pmc    53
+opcode.pmc    54

Modified: branches/rm_cflags/t/native_pbc/annotations.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: branches/rm_cflags/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: branches/rm_cflags/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: branches/rm_cflags/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Copied: branches/rm_cflags/t/pmc/opcode.t (from r44052, trunk/t/pmc/opcode.t)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/rm_cflags/t/pmc/opcode.t	Tue Feb 16 21:56:13 2010	(r44053, copy of r44052, trunk/t/pmc/opcode.t)
@@ -0,0 +1,29 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/opcode.t - Opcode PMC
+
+=head1 SYNOPSIS
+
+    % prove t/pmc/opcode.t
+
+=cut
+
+.sub main :main
+    .include 'test_more.pir'
+    plan(1)
+    cannot_create_directly()
+.end
+
+.sub cannot_create_directly
+    push_eh cannot_create
+    $P0 = new ['Opcode']
+    ok(0, "shouldn't be able to create new opcode")
+    goto create_end
+  cannot_create:
+    ok(1)
+  create_end:
+.end

Copied: branches/rm_cflags/t/pmc/oplib.t (from r44052, trunk/t/pmc/oplib.t)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/rm_cflags/t/pmc/oplib.t	Tue Feb 16 21:56:13 2010	(r44053, copy of r44052, trunk/t/pmc/oplib.t)
@@ -0,0 +1,30 @@
+#! parrot
+# Copyright (C) 2001-2009, Parrot Foundation.
+# $Id: fixedpmcarray.t 42684 2009-11-21 13:40:19Z jkeenan $
+
+=head1 NAME
+
+t/pmc/oplib.t - OpLib PMC
+
+=head1 SYNOPSIS
+
+    % prove t/pmc/oplib.t
+
+=cut
+
+.sub main :main
+    .include 'test_more.pir'
+    plan(1)
+    get_singleton()
+.end
+
+.sub get_singleton
+    $P0 = new ['OpLib']
+    $I0 = isnull $P0
+    is($I0, 0)
+
+    # TODO: How to test that this is actually a singleton?
+    #$P1 = new ['OpLib']
+    #is($P0, $P1)
+.end
+

Modified: branches/rm_cflags/t/pmc/pmc.t
==============================================================================
--- branches/rm_cflags/t/pmc/pmc.t	Tue Feb 16 21:40:19 2010	(r44052)
+++ branches/rm_cflags/t/pmc/pmc.t	Tue Feb 16 21:56:13 2010	(r44053)
@@ -51,7 +51,7 @@
 my $checkTypes;
 my %types_we_cant_test
     = map { $_ => 1; } (    # These require initializers.
-    qw(default Null Iterator ArrayIterator HashIterator StringIterator OrderedHashIterator Enumerate ParrotObject ParrotThread BigInt LexInfo LexPad Object Handle),
+    qw(default Null Iterator ArrayIterator HashIterator StringIterator OrderedHashIterator Enumerate ParrotObject ParrotThread BigInt LexInfo LexPad Object Handle Opcode),
 
     # Instances of these appear to have other types.
     qw(PMCProxy Class) );


More information about the parrot-commits mailing list