On Mon, Oct 01, 2001 at 03:27:49PM +0100, Simon Cozens wrote:
> On Mon, Oct 01, 2001 at 10:23:11AM -0400, Jason Gloudon wrote:
> > What about the current macros for NUM_REG etc ?
> 
> I'd probably rip 'em out too. Stops people accidentally hand hacking the .c file
> instead of the .ops file and then losing all their changes on rebuild. Not
> that I've ever done that trick, of course. :)

This patch removes the preprocessor macros for register access. These are now
substituted in basic_opcodes.ops by process_opfunc. The patch also adds
substitution for NUM_CONST(), STR_CONST(), INT_CONST() for constant access in
ops.

-- 
Jason
Index: basic_opcodes.ops
===================================================================
RCS file: /home/perlcvs/parrot/basic_opcodes.ops,v
retrieving revision 1.27
diff -u -r1.27 basic_opcodes.ops
--- basic_opcodes.ops   2001/09/30 20:25:22     1.27
+++ basic_opcodes.ops   2001/10/02 11:35:36
@@ -191,7 +191,7 @@
 
 /* SET Nx, CONSTANT */
 AUTO_OP set_n_nc {
-  NUM_REG(P1) = PCONST(P2)->number;
+  NUM_REG(P1) = NUM_CONST(P2);
 } 
 
 /* SET Nx, Nx */
@@ -232,7 +232,7 @@
 
 /* EQ Nx, CONSTANT, EQ_BRANCH */
 MANUAL_OP eq_nc_ic {
-  if (NUM_REG(P1) == PCONST(P2)->number) {
+  if (NUM_REG(P1) == NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -246,7 +246,7 @@
 
 /* NE Nx, CONSTANT, NE_BRANCH */
 MANUAL_OP ne_nc_ic {
-  if (NUM_REG(P1) != PCONST(P2)->number) {
+  if (NUM_REG(P1) != NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -260,7 +260,7 @@
 
 /* LT Nx, CONSTANT, LT_BRANCH */
 MANUAL_OP lt_nc_ic {
-  if (NUM_REG(P1) < PCONST(P2)->number) {
+  if (NUM_REG(P1) < NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -274,7 +274,7 @@
 
 /* LE Nx, CONSTANT, LE_BRANCH */
 MANUAL_OP le_nc_ic {
-  if (NUM_REG(P1) <= PCONST(P2)->number) {
+  if (NUM_REG(P1) <= NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -288,7 +288,7 @@
 
 /* GT Nx, CONSTANT, GT_BRANCH */
 MANUAL_OP gt_nc_ic {
-  if (NUM_REG(P1) > PCONST(P2)->number) {
+  if (NUM_REG(P1) > NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -302,7 +302,7 @@
 
 /* GE Nx, CONSTANT, GE_BRANCH */
 MANUAL_OP ge_nc_ic {
-  if (NUM_REG(P1) >= PCONST(P2)->number) {
+  if (NUM_REG(P1) >= NUM_CONST(P2)) {
     RETURN(P3);
   }
 }
@@ -326,7 +326,7 @@
  
 /* PRINT nc */
 AUTO_OP print_nc {
-  printf("%f", PCONST(P1)->number);
+  printf("%f", NUM_CONST(P1));
 }
 
 /* INC Nx */
@@ -336,7 +336,7 @@
 
 /* INC Nx, nnn */
 AUTO_OP inc_n_nc {
-  NUM_REG(P1) += PCONST(P2)->number;
+  NUM_REG(P1) += NUM_CONST(P2);
 }
 
 /* DEC Nx */
@@ -346,7 +346,7 @@
 
 /* DEC Nx, nnn */
 AUTO_OP dec_n_nc {
-  NUM_REG(P1) -= PCONST(P2)->number;
+  NUM_REG(P1) -= NUM_CONST(P2);
 }
 
 /* ITON Nx, Iy */
@@ -425,7 +425,7 @@
 
 /* SET Sx, CONSTANT */
 AUTO_OP set_s_sc {
-  STR_REG(P1) = PCONST(P2)->string;
+  STR_REG(P1) = STR_CONST(P2);
 }
 
 /* PRINT Sx */
@@ -436,7 +436,7 @@
 
 /* PRINT sc */
 AUTO_OP print_sc {
-  STRING *s = PCONST(P1)->string;
+  STRING *s = STR_CONST(P1);
   IV l = string_length(s);
   printf("%.*s",(int)l, (char *)s->bufstart);
 }
Index: process_opfunc.pl
===================================================================
RCS file: /home/perlcvs/parrot/process_opfunc.pl,v
retrieving revision 1.19
diff -u -r1.19 process_opfunc.pl
--- process_opfunc.pl   2001/10/01 20:51:52     1.19
+++ process_opfunc.pl   2001/10/02 11:35:36
@@ -119,6 +119,14 @@
     s/RETURN\((.*)\)/return cur_opcode + $1/;
 
     s/\bP(\d+)\b/$param_sub[$1]/g;
+    s/INT_REG\(([^)]+)\)/interpreter->int_reg->registers[$1]/g;
+    s/STR_REG\(([^)]+)\)/interpreter->string_reg->registers[$1]/g;
+    s/PMC_REG\(([^)]+)\)/interpreter->pmc_reg->registers[$1]/g;
+    s/NUM_REG\(([^)]+)\)/interpreter->num_reg->registers[$1]/g;
+
+    s/NUM_CONST\(([^)]+)\)/interpreter->code->const_table->constants[$1]->number/g;
+    s/STR_CONST\(([^)]+)\)/interpreter->code->const_table->constants[$1]->string/g;
+    s/INT_CONST\(([^)]+)\)/interpreter->code->const_table->constants[$1]->string/g;
 
     if (/^}/) {
         print OUTPUT $footer, "\n";
Index: register.c
===================================================================
RCS file: /home/perlcvs/parrot/register.c,v
retrieving revision 1.8
diff -u -r1.8 register.c
--- register.c  2001/09/17 13:44:13     1.8
+++ register.c  2001/10/02 11:35:36
@@ -74,7 +74,7 @@
 Parrot_clear_i(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        INT_REG(i) = 0;
+        interpreter->int_reg->registers[i] = 0;
     }
 }
 
@@ -143,7 +143,7 @@
 Parrot_clear_s(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        STR_REG(i) = NULL;
+        interpreter->string_reg->registers[i] = NULL;
     }
 }
 
@@ -209,7 +209,7 @@
 Parrot_clear_n(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        NUM_REG(i) = 0;
+        interpreter->num_reg->registers[i] = 0;
     }
 }
 
@@ -277,7 +277,7 @@
 Parrot_clear_p(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        PMC_REG(i) = NULL;
+        interpreter->pmc_reg->registers[i] = NULL;
     }
 }
 
Index: include/parrot/register.h
===================================================================
RCS file: /home/perlcvs/parrot/include/parrot/register.h,v
retrieving revision 1.1
diff -u -r1.1 register.h
--- include/parrot/register.h   2001/09/18 01:16:59     1.1
+++ include/parrot/register.h   2001/10/02 11:35:36
@@ -63,12 +63,6 @@
     struct PReg PReg[FRAMES_PER_CHUNK];
 };
 
-/* Accessor macros */
-#define INT_REG(x) interpreter->int_reg->registers[x]
-#define STR_REG(x) interpreter->string_reg->registers[x]
-#define PMC_REG(x) interpreter->pmc_reg->registers[x]
-#define NUM_REG(x) interpreter->num_reg->registers[x]
-
 /* This macro masks off the low bits of a register chunk address,
    since we're guaranteed to be aligned */
 #define CHUNK_BASE(x) (void *)(MASK_CHUNK_LOW_BITS & (IV)x)

Reply via email to