cvsuser 03/08/16 09:45:19
Modified: classes scratchpad.pmc
include/parrot sub.h
. sub.c
t/pmc scratchpad.t
Log:
scratchpad_delete
Revision Changes Path
1.12 +19 -1 parrot/classes/scratchpad.pmc
Index: scratchpad.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/scratchpad.pmc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- scratchpad.pmc 24 Jul 2003 01:20:10 -0000 1.11
+++ scratchpad.pmc 16 Aug 2003 16:45:15 -0000 1.12
@@ -1,7 +1,7 @@
/* Scratchpad.pmc
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: scratchpad.pmc,v 1.11 2003/07/24 01:20:10 dan Exp $
+ * $Id: scratchpad.pmc,v 1.12 2003/08/16 16:45:15 leo Exp $
* Overview:
* These are the vtable functions for the Scratchpad base class.
* Data Structure and Algorithms:
@@ -132,5 +132,23 @@
else {
scratchpad_store(INTERP, SELF, name, position, value);
}
+ }
+
+ void delete_keyed(PMC* key) {
+ STRING * name = NULL;
+ INTVAL position;
+ struct Parrot_Lexicals * lex;
+
+ if (key_type(INTERP, key) == KEY_integer_FLAG) {
+ position = key_integer(INTERP, key);
+ /* TODO */
+ }
+ else if (key_type(INTERP, key) == KEY_string_FLAG) {
+ name = key_string(INTERP, key);
+ scratchpad_delete(INTERP, SELF, name);
+ }
+ else {
+ return;
+ }
}
}
1.20 +2 -1 parrot/include/parrot/sub.h
Index: sub.h
===================================================================
RCS file: /cvs/public/parrot/include/parrot/sub.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -r1.19 -r1.20
--- sub.h 15 Aug 2003 11:27:22 -0000 1.19
+++ sub.h 16 Aug 2003 16:45:17 -0000 1.20
@@ -1,7 +1,7 @@
/* subroutine.h
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: sub.h,v 1.19 2003/08/15 11:27:22 leo Exp $
+ * $Id: sub.h,v 1.20 2003/08/16 16:45:17 leo Exp $
* Overview:
* Data Structure and Algorithms:
* Subroutine, coroutine, closure and continuation structures
@@ -62,6 +62,7 @@
STRING * name, INTVAL position);
void lexicals_mark(struct Parrot_Interp * interp, struct Parrot_Lexicals *lex);
+void scratchpad_delete(Parrot_Interp interp, PMC *pad, STRING *name);
#endif /* PARROT_SUB_H_GUARD */
1.33 +9 -1 parrot/sub.c
Index: sub.c
===================================================================
RCS file: /cvs/public/parrot/sub.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- sub.c 15 Aug 2003 11:27:19 -0000 1.32
+++ sub.c 16 Aug 2003 16:45:18 -0000 1.33
@@ -1,7 +1,7 @@
/* sub.c
* Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
* CVS Info
- * $Id: sub.c,v 1.32 2003/08/15 11:27:19 leo Exp $
+ * $Id: sub.c,v 1.33 2003/08/16 16:45:18 leo Exp $
* Overview:
* Sub-routines, co-routines and other fun stuff...
* Data Structure and Algorithms:
@@ -336,6 +336,14 @@
list_mark(interp, lex->values);
}
+void
+scratchpad_delete(Parrot_Interp interp, PMC *pad, STRING *name)
+{
+ INTVAL pos;
+ struct Parrot_Lexicals *lex = scratchpad_find(interp, pad, name, &pos);
+ if (lex)
+ list_assign(interp, lex->names, pos, NULL, enum_type_STRING);
+}
/*
* Local variables:
* c-indentation-style: bsd
1.3 +17 -1 parrot/t/pmc/scratchpad.t
Index: scratchpad.t
===================================================================
RCS file: /cvs/public/parrot/t/pmc/scratchpad.t,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- scratchpad.t 11 Jan 2003 09:48:08 -0000 1.2
+++ scratchpad.t 16 Aug 2003 16:45:19 -0000 1.3
@@ -1,6 +1,6 @@
#! perl -w
-use Parrot::Test tests => 4;
+use Parrot::Test tests => 5;
output_is(<<CODE, <<OUTPUT, "direct set and get on scratchpad pmc");
new_pad P20, 0
@@ -192,5 +192,21 @@
101
OUTPUT
+output_is(<<'CODE', <<OUTPUT, "delete");
+ new_pad 0
+ new P1, .PerlString
+ set P1, "ok 1\n"
+ store_lex -1, "foo", P1
+ find_lex P2, "foo"
+ print P2
+ peek_pad P0
+ delete P0["foo"]
+ find_lex P2, "foo"
+ print P2
+ end
+CODE
+ok 1
+Lexical 'foo' not found
+OUTPUT
1;