The attached patch is also in preparation for Rx3 (or whatever you want
to call it). It implements a new Handle PMC type. Handles simply
contain pointers. They can't be directly manipulated directly by Parrot
bytecode; C code uses handle->vtable->get_value and ->set_value to
manipulate them. They stringify to "Handle=0xDECAF" (or whatever) and
numify to 912559 (or whatever).
--Brent Dax
[EMAIL PROTECTED]
Configure pumpking for Perl 6
"Nothing important happened today."
--George III of England's diary entry for 4-Jul-1776
--- ..\..\parrot-cvs\parrot\include\parrot\pmc.h Thu Dec 20 01:09:06 2001
+++ include\parrot\pmc.h Wed Jan 2 13:42:06 2002
@@ -19,6 +19,7 @@
enum_class_PerlNum,
enum_class_PerlString,
enum_class_PerlArray,
+ enum_class_Handle,
enum_class_max
};
VAR_SCOPE VTABLE Parrot_base_vtables[enum_class_max];
--- ..\..\parrot-cvs\parrot\classes\makefile.in Mon Dec 17 23:05:00 2001
+++ classes\makefile.in Wed Jan 2 13:29:02 2002
@@ -5,7 +5,7 @@
H_FILES = $(INC)/parrot.h default.h
-O_FILES = default$(O) perlint$(O) perlstring$(O) perlnum$(O) perlarray$(O)
perlundef$(O)
+O_FILES = default$(O) perlint$(O) perlstring$(O) perlnum$(O) perlarray$(O)
+perlundef$(O) handle$(O)
#DO NOT ADD C COMPILER FLAGS HERE
#Add them in Configure.pl--look for the
@@ -21,7 +21,7 @@
.c$(O):
$(CC) $(CFLAGS) ${ld_out}$@ -c $<
-all : default$(O) perlint$(O) perlnum$(O) perlstring$(O) perlarray$(O) perlundef$(O)
+all : default$(O) perlint$(O) perlnum$(O) perlstring$(O) perlarray$(O) perlundef$(O)
+handle$(O)
default.c: default.pmc
$(PERL) pmc2c.pl default.pmc
@@ -29,7 +29,7 @@
default$(O): $(H_FILES)
default.h: default.c
- $(PERL) -ne "next unless /Parrot_default/; s/{/;/;s/^/extern /;print"
default.c > default.h
+ $(PERL) -ne ${PQ}next unless /Parrot_default/; s/{/;/;s/^/extern /;print${PQ}
+default.c > default.h
perlint.c: perlint.pmc
$(PERL) pmc2c.pl perlint.pmc
@@ -56,6 +56,11 @@
perlundef$(O): $(H_FILES)
+handle.c: handle.pmc
+ $(PERL) pmc2c.pl handle.pmc
+
+handle$(O): $(H_FILES)
+
clean:
$(RM_F) *.c *$(O) default.h
--- ..\..\parrot-cvs\parrot\global_setup.c Thu Jan 3 14:18:06 2002
+++ global_setup.c Thu Jan 3 15:19:32 2002
@@ -19,6 +19,7 @@
void Parrot_PerlNum_class_init(void);
void Parrot_PerlString_class_init(void);
void Parrot_PerlArray_class_init(void);
+void Parrot_Handle_class_init(void);
void
init_world(void) {
@@ -29,6 +30,7 @@
Parrot_PerlNum_class_init();
Parrot_PerlString_class_init();
Parrot_PerlArray_class_init();
+ Parrot_Handle_class_init();
}
/*
--- /dev/null Wed Dec 31 16:00:00 1969
+++ classes\handle.pmc Thu Jan 3 15:21:40 2002
@@ -0,0 +1,298 @@
+/* Handle.pmc
+ * Copyright: (When this is determined...it will go here)
+ * CVS Info
+ * $Id$
+ * Overview:
+ * These are the vtable functions for the Handle base class
+ * Data Structure and Algorithms:
+ * History:
+ * Notes: The actual pointer is in cache.struct_val.
+ * References:
+ */
+
+#include "parrot/parrot.h"
+#define ERROR fprintf(stderr, "An illegal operation was performed on a Handle.\n");
+exit(1); return 0;
+
+pmclass Handle {
+ INTVAL type () {
+ }
+
+ STRING* name () {
+ return whoami;
+ }
+
+ void init () {
+ pmc->cache.struct_val=NULL;
+ }
+
+ void clone (PMC* dest) {
+ dest->vtable=pmc->vtable;
+ dest->cache.struct_val=pmc->cache.struct_val;
+ }
+
+ void morph (INTVAL type) {
+ }
+
+ BOOLVAL move_to (void * destination) {
+ }
+
+ INTVAL real_size () {
+ return 0;
+ }
+
+ void destroy () {
+ /* nothing */
+ }
+
+ INTVAL get_integer () {
+ return (INTVAL)pmc->cache.struct_val;
+ }
+
+ INTVAL get_integer_index (INTVAL index) {
+ }
+
+ FLOATVAL get_number () {
+ return (FLOATVAL)(INTVAL)pmc->cache.struct_val;
+ }
+
+ FLOATVAL get_number_index (INTVAL index) {
+ }
+
+ STRING* get_string () {
+ char *target=mem_sys_allocate(64);
+
+ sprintf(target, "Handle=0x%p", pmc->cache.struct_val);
+
+ return string_make(interpreter, target, strlen(target), 0, 0, 0);
+ }
+
+ STRING* get_string_index (INTVAL index) {
+ }
+
+ BOOLVAL get_bool () {
+ return (BOOLVAL)pmc->cache.struct_val;
+ }
+
+ void* get_value () {
+ return pmc->cache.struct_val;
+ }
+
+ BOOLVAL is_same (PMC* pmc2) {
+ return pmc->vtable == pmc2->vtable && pmc->cache.struct_val ==
+pmc2->cache.struct_val;
+ }
+
+ void set_integer (PMC * value) {
+ ERROR;
+ }
+
+ void set_integer_native (INTVAL value) {
+ ERROR;
+ }
+
+ void set_integer_bigint (BIGINT value) {
+ ERROR;
+ }
+
+ void set_integer_same (PMC * value) {
+ ERROR;
+ }
+
+ void set_integer_index (INTVAL value, INTVAL index) {
+ ERROR;
+ }
+
+ void set_number (PMC * value) {
+ ERROR;
+ }
+
+ void set_number_native (FLOATVAL value) {
+ ERROR;
+ }
+
+ void set_number_bigfloat (BIGFLOAT value) {
+ ERROR;
+ }
+
+ void set_number_same (PMC * value) {
+ ERROR;
+ }
+
+ void set_number_index (FLOATVAL value, INTVAL index) {
+ ERROR;
+ }
+
+ void set_string (PMC * value) {
+ ERROR;
+ }
+
+ void set_string_native (STRING * value) {
+ ERROR;
+ }
+
+ void set_string_unicode (STRING * value) {
+ ERROR;
+ }
+
+ void set_string_other (STRING * value) {
+ ERROR;
+ }
+
+ void set_string_same (PMC * value) {
+ ERROR;
+ }
+
+ void set_string_index (STRING* value, INTVAL index) {
+ ERROR;
+ }
+
+ void set_value (void* value) {
+ pmc->cache.struct_val=value;
+ }
+
+ void add (PMC * value, PMC* dest) {
+ }
+
+ void add_int (INTVAL value, PMC* dest) {
+ }
+
+ void add_bigint (BIGINT value, PMC* dest) {
+ }
+
+ void add_float (FLOATVAL value, PMC* dest) {
+ }
+
+ void add_bigfloat (BIGFLOAT value, PMC* dest) {
+ }
+
+ void add_same (PMC * value, PMC* dest) {
+ }
+
+ void subtract (PMC * value, PMC* dest) {
+ }
+
+ void subtract_int (INTVAL value, PMC* dest) {
+ }
+
+ void subtract_bigint (BIGINT value, PMC* dest) {
+ }
+
+ void subtract_float (FLOATVAL value, PMC* dest) {
+ }
+
+ void subtract_bigfloat (BIGFLOAT value, PMC* dest) {
+ }
+
+ void subtract_same (PMC * value, PMC* dest) {
+ }
+
+ void multiply (PMC * value, PMC* dest) {
+ }
+
+ void multiply_int (INTVAL value, PMC* dest) {
+ }
+
+ void multiply_bigint (BIGINT value, PMC* dest) {
+ }
+
+ void multiply_float (FLOATVAL value, PMC* dest) {
+ }
+
+ void multiply_bigfloat (BIGFLOAT value, PMC* dest) {
+ }
+
+ void multiply_same (PMC * value, PMC* dest) {
+ }
+
+ void divide (PMC * value, PMC* dest) {
+ }
+
+ void divide_int (INTVAL value, PMC* dest) {
+ }
+
+ void divide_bigint (BIGINT value, PMC* dest) {
+ }
+
+ void divide_float (FLOATVAL value, PMC* dest) {
+ }
+
+ void divide_bigfloat (BIGFLOAT value, PMC* dest) {
+ }
+
+ void divide_same (PMC * value, PMC* dest) {
+ }
+
+ void modulus (PMC * value, PMC* dest) {
+ }
+
+ void modulus_int (INTVAL value, PMC* dest) {
+ }
+
+ void modulus_bigint (BIGINT value, PMC* dest) {
+ }
+
+ void modulus_float (FLOATVAL value, PMC* dest) {
+ }
+
+ void modulus_bigfloat (BIGFLOAT value, PMC* dest) {
+ }
+
+ void modulus_same (PMC * value, PMC* dest) {
+ }
+
+ void concatenate (PMC * value, PMC* dest) {
+ }
+
+ void concatenate_native (STRING * value, PMC* dest) {
+ }
+
+ void concatenate_unicode (STRING * value, PMC* dest) {
+ }
+
+ void concatenate_other (STRING * value, PMC* dest) {
+ }
+
+ void concatenate_same (PMC * value, PMC* dest) {
+ }
+
+ BOOLVAL is_equal (PMC* value) {
+ }
+
+ void logical_or (PMC* value, PMC* dest) {
+ }
+
+ void logical_and (PMC* value, PMC* dest) {
+ }
+
+ void logical_not (PMC* value) {
+ }
+
+ void match (PMC * value, REGEX* re) {
+ }
+
+ void match_native (STRING * value, REGEX* re) {
+ }
+
+ void match_unicode (STRING * value, REGEX* re) {
+ }
+
+ void match_other (STRING * value, REGEX* re) {
+ }
+
+ void match_same (PMC * value, REGEX* re) {
+ }
+
+ void repeat (PMC * value, PMC* dest) {
+ }
+
+ void repeat_native (STRING * value, PMC* dest) {
+ }
+
+ void repeat_unicode (STRING * value, PMC* dest) {
+ }
+
+ void repeat_other (STRING * value, PMC* dest) {
+ }
+
+ void repeat_same (PMC * value, PMC* dest) {
+ }
+}