[svn:parrot] r48721 - in trunk: src/ops t/dynoplibs t/op t/src
Paul at osuosl.org
Paul at osuosl.org
Mon Aug 30 01:04:08 UTC 2010
Author: Paul C. Anagnostopoulos
Date: Mon Aug 30 01:04:08 2010
New Revision: 48721
URL: https://trac.parrot.org/parrot/changeset/48721
Log:
find_lex no longer throws exception on undefined name
Modified:
trunk/src/ops/core_ops.c
trunk/src/ops/var.ops
trunk/t/dynoplibs/debug.t
trunk/t/op/lexicals.t
trunk/t/src/extend.t
Modified: trunk/src/ops/core_ops.c
==============================================================================
--- trunk/src/ops/core_ops.c Mon Aug 30 00:03:04 2010 (r48720)
+++ trunk/src/ops/core_ops.c Mon Aug 30 01:04:08 2010 (r48721)
@@ -23778,13 +23778,8 @@
PMC * const result =
PMC_IS_NULL(lex_pad)
- ? NULL
+ ? PMCNULL
: VTABLE_get_pmc_keyed_str(interp, lex_pad, lex_name);
- if (!result) {
- opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_LEX_NOT_FOUND,
- "Lexical '%Ss' not found", lex_name);return (opcode_t *)handler;
- }
PREG(1) = result;
return (opcode_t *)cur_opcode + 3;}
@@ -23798,13 +23793,8 @@
PMC * const result =
PMC_IS_NULL(lex_pad)
- ? NULL
+ ? PMCNULL
: VTABLE_get_pmc_keyed_str(interp, lex_pad, lex_name);
- if (!result) {
- opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_LEX_NOT_FOUND,
- "Lexical '%Ss' not found", lex_name);return (opcode_t *)handler;
- }
PREG(1) = result;
return (opcode_t *)cur_opcode + 3;}
Modified: trunk/src/ops/var.ops
==============================================================================
--- trunk/src/ops/var.ops Mon Aug 30 00:03:04 2010 (r48720)
+++ trunk/src/ops/var.ops Mon Aug 30 01:04:08 2010 (r48721)
@@ -86,10 +86,8 @@
=item B<find_lex>(out PMC, in STR)
-Find the lexical variable named $2 and store it in $1. This
-opcode either throws an exception or returns a Null PMC for the failure case,
-depending on the implementation of the LexPad PMC. Parrot's
-standard LexPad throws an exception for non-existent names.
+Find the lexical variable named $2 and store it in $1. Return a
+Null PMC if the variable is not found.
=cut
@@ -100,14 +98,8 @@
PMC * const result =
PMC_IS_NULL(lex_pad)
- ? NULL
+ ? PMCNULL
: VTABLE_get_pmc_keyed_str(interp, lex_pad, lex_name);
- if (!result) {
- opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, NULL,
- EXCEPTION_LEX_NOT_FOUND,
- "Lexical '%Ss' not found", lex_name);
- goto ADDRESS(handler);
- }
$1 = result;
}
Modified: trunk/t/dynoplibs/debug.t
==============================================================================
--- trunk/t/dynoplibs/debug.t Mon Aug 30 00:03:04 2010 (r48720)
+++ trunk/t/dynoplibs/debug.t Mon Aug 30 01:04:08 2010 (r48721)
@@ -106,7 +106,7 @@
called from Sub 'parrot;Test1;main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
OUTPUT
-pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - fetch of unknown lexical" );
+pir_error_output_like( <<'CODE', <<'OUTPUT', "debug backtrace - division by 0" );
.namespace ["Test2"]
.sub main
print "ok 1\n"
@@ -115,13 +115,14 @@
.end
.sub foo :lex
print "ok 2\n"
- find_lex $P0, "nosuchlex"
+ $I1 = 0
+ div $I2, $I2, 0
print "not ok 3\n"
.end
CODE
/^ok 1
ok 2
-Lexical 'nosuchlex' not found
+Divide by zero
current instr.: 'parrot;Test2;foo' pc (\d+|-1) \(.*?:(\d+|-1)\)
called from Sub 'parrot;Test2;main' pc (\d+|-1) \(.*?:(\d+|-1)\)$/
OUTPUT
Modified: trunk/t/op/lexicals.t
==============================================================================
--- trunk/t/op/lexicals.t Mon Aug 30 00:03:04 2010 (r48720)
+++ trunk/t/op/lexicals.t Mon Aug 30 01:04:08 2010 (r48721)
@@ -840,7 +840,7 @@
/Null PMC access/
OUT
-pir_error_output_like( <<'CODE', <<'OUTPUT', 'get non existing' );
+pir_output_is( <<'CODE', <<'OUTPUT', 'get undefined lexical' );
.sub "main" :main
.lex 'a', $P0
foo()
@@ -852,9 +852,14 @@
.sub bar :outer('foo')
.lex 'c', $P0
$P2 = find_lex 'no_such'
+ if null $P2 goto ok
+ print "Undefined name not NULL\n"
+ end
+ok:
+ print "ok\n"
.end
CODE
-/Lexical 'no_such' not found/
+ok
OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', 'find_name on lexicals' );
Modified: trunk/t/src/extend.t
==============================================================================
--- trunk/t/src/extend.t Mon Aug 30 00:03:04 2010 (r48720)
+++ trunk/t/src/extend.t Mon Aug 30 01:04:08 2010 (r48721)
@@ -541,7 +541,8 @@
.pcc_sub _sub1:
get_params ""
print "in sub1\n"
- find_lex P2, "no_such_var"
+ set I1, 0 # Divide by 0 to force exception.
+ div I2, I1, 0
print "never\n"
returncc
EOF
More information about the parrot-commits
mailing list