This patch is a collection of a few small fixes vaguely related to the
lexical pads. It implements pop_pad(out PMC), banishes Intval in
favor of INTVAL, and adds some newlines to internal_exception calls.
Luke
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/core.ops,v
retrieving revision 1.274
diff -u -r1.274 core.ops
--- core.ops 30 May 2003 01:06:23 -0000 1.274
+++ core.ops 1 Jun 2003 07:05:31 -0000
@@ -3855,7 +3855,7 @@
=item B<pop_pad>(out PMC)
Pop the current lexical scope pad off the stack and store
-it in $1 (XXX JPS: not implemented yet).
+it in $1.
=item B<peek_pad>(out PMC)
@@ -3931,6 +3931,13 @@
op pop_pad() {
stack_pop(interpreter, &interpreter->ctx.pad_stack,
NULL, STACK_ENTRY_PMC);
+ goto NEXT();
+}
+
+op pop_pad(out PMC) {
+ $1 = new_pmc_header(interpreter);
+ stack_pop(interpreter, &interpreter->ctx.pad_stack,
+ &$1, STACK_ENTRY_PMC);
goto NEXT();
}
Index: stacks.c
===================================================================
RCS file: /cvs/public/parrot/stacks.c,v
retrieving revision 1.50
diff -u -r1.50 stacks.c
--- stacks.c 31 Jan 2003 16:41:02 -0000 1.50
+++ stacks.c 1 Jun 2003 07:05:31 -0000
@@ -118,7 +118,7 @@
Returns NULL if |depth| > number of entries in stack
*/
Stack_Entry_t *
-stack_entry(Interp *interpreter, Stack_Chunk_t *stack, Intval depth)
+stack_entry(Interp *interpreter, Stack_Chunk_t *stack, INTVAL depth)
{
Stack_Chunk_t *chunk;
Stack_Entry_t *entry = NULL;
@@ -150,11 +150,11 @@
is bubble down, so that the Nth element becomes the top most element.
*/
void
-rotate_entries(Interp *interpreter, Stack_Chunk_t *stack, Intval num_entries)
+rotate_entries(Interp *interpreter, Stack_Chunk_t *stack, INTVAL num_entries)
{
Stack_Entry_t temp;
- Intval i;
- Intval depth = num_entries - 1;
+ INTVAL i;
+ INTVAL depth = num_entries - 1;
if (num_entries >= -1 && num_entries <= 1) {
return;
@@ -251,10 +251,10 @@
/* Store our thing */
switch (type) {
case STACK_ENTRY_INT:
- entry->entry.int_val = *(Intval *)thing;
+ entry->entry.int_val = *(INTVAL *)thing;
break;
case STACK_ENTRY_FLOAT:
- entry->entry.num_val = *(Floatval *)thing;
+ entry->entry.num_val = *(FLOATVAL *)thing;
break;
case STACK_ENTRY_PMC:
entry->entry.pmc_val = (PMC *)thing;
@@ -342,10 +342,10 @@
/* Snag the value */
switch (type) {
case STACK_ENTRY_INT:
- *(Intval *)where = entry->entry.int_val;
+ *(INTVAL *)where = entry->entry.int_val;
break;
case STACK_ENTRY_FLOAT:
- *(Floatval *)where = entry->entry.num_val;
+ *(FLOATVAL *)where = entry->entry.num_val;
break;
case STACK_ENTRY_PMC:
*(PMC **)where = entry->entry.pmc_val;
Index: sub.c
===================================================================
RCS file: /cvs/public/parrot/sub.c,v
retrieving revision 1.18
diff -u -r1.18 sub.c
--- sub.c 29 Jan 2003 18:34:02 -0000 1.18
+++ sub.c 1 Jun 2003 07:05:31 -0000
@@ -82,7 +82,7 @@
pad->cache.int_val + scope_index : scope_index;
if (scope_index >= pad->cache.int_val || scope_index < 0) {
- internal_exception(-1, "Pad index out of range");
+ internal_exception(-1, "Pad index out of range\n");
return NULL;
}
@@ -211,7 +211,7 @@
if (name) {
/* use name to find lex and position */
lex = scratchpad_find(interp, pad, name, &position);
- if (!lex) internal_exception(-1, "Lexical not found");
+ if (!lex) internal_exception(-1, "Lexical not found\n");
}
else {
/* assume current lexical pad */
@@ -255,7 +255,7 @@
if (name) lex = scratchpad_find(interp, pad, name, &position);
else lex = scratchpad_index(interp, pad, -1);
- if (!lex) internal_exception(-1, "Lexical not found");
+ if (!lex) internal_exception(-1, "Lexical not found\n");
return *(PMC **)list_get(interp, lex->values, position, enum_type_PMC);
}
@@ -271,7 +271,7 @@
}
if (!lex || position < 0 || position >= list_length(interp, lex->values)) {
- internal_exception(-1, "Lexical not found");
+ internal_exception(-1, "Lexical not found\n");
}
return *(PMC **)list_get(interp, lex->values, position, enum_type_PMC);
Index: include/parrot/stacks.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/stacks.h,v
retrieving revision 1.24
diff -u -r1.24 stacks.h
--- include/parrot/stacks.h 26 Jun 2002 00:03:19 -0000 1.24
+++ include/parrot/stacks.h 1 Jun 2003 07:05:31 -0000
@@ -39,8 +39,8 @@
typedef struct Stack_Entry {
union {
- Floatval num_val;
- Intval int_val;
+ FLOATVAL num_val;
+ INTVAL int_val;
PMC *pmc_val;
String *string_val;
void *generic_pointer;
@@ -77,10 +77,10 @@
size_t stack_height(Interp *interpreter, Stack_Chunk_t *stack_base);
Stack_Entry_t * stack_entry(Interp *intepreter, Stack_Chunk_t *stack_base,
- Intval stack_depth);
+ INTVAL stack_depth);
void rotate_entries(Interp *interpreter, Stack_Chunk_t *stack_base,
- Intval num_entries);
+ INTVAL num_entries);
void stack_push(Interp *interpreter, Stack_Chunk_t **stack_base,
void *thing, Stack_entry_type type,
Index: t/op/lexicals.t
===================================================================
RCS file: /cvs/public/parrot/t/op/lexicals.t,v
retrieving revision 1.4
diff -u -r1.4 lexicals.t
--- t/op/lexicals.t 15 Nov 2002 23:44:08 -0000 1.4
+++ t/op/lexicals.t 1 Jun 2003 07:05:31 -0000
@@ -194,11 +194,17 @@
print P20
print "\\n"
- pop_pad
+ pop_pad P7
find_lex P20, "a"
print P20
print "\\n"
+ push_pad P7
+ find_lex P20, "a"
+ print P20
+ print "\\n"
+ pop_pad
+
peek_pad P22
pop_pad
find_lex P20, "a"
@@ -215,6 +221,7 @@
7
46
7
+46
12
7
OUTPUT