[svn:parrot] r48811 - in trunk: src t/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Mon Sep 6 14:35:49 UTC 2010
Author: NotFound
Date: Mon Sep 6 14:35:49 2010
New Revision: 48811
URL: https://trac.parrot.org/parrot/changeset/48811
Log:
throw an exception when trying to hll_map without an HLL, TT #1771
Modified:
trunk/src/hll.c
trunk/t/pmc/parrotinterpreter.t
Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c Mon Sep 6 12:30:18 2010 (r48810)
+++ trunk/src/hll.c Mon Sep 6 14:35:49 2010 (r48811)
@@ -329,21 +329,26 @@
INTVAL core_type, INTVAL hll_type)
{
ASSERT_ARGS(Parrot_register_HLL_type)
- PMC *entry, *type_hash;
- PMC *hll_info = interp->HLL_info;
- const INTVAL n = VTABLE_elements(interp, hll_info);
- if (hll_id >= n)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_GLOBAL_NOT_FOUND,
- "no such HLL ID (%vd)", hll_id);
-
- entry = VTABLE_get_pmc_keyed_int(interp, hll_info, hll_id);
- PARROT_ASSERT(!PMC_IS_NULL(entry));
-
- type_hash = VTABLE_get_pmc_keyed_int(interp, entry, e_HLL_typemap);
- PARROT_ASSERT(!PMC_IS_NULL(type_hash));
+ if (hll_id == Parrot_get_HLL_id(interp, CONST_STRING(interp, "parrot")))
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Cannot map without an HLL");
+ else {
+ PMC *hll_info = interp->HLL_info;
+ const INTVAL n = VTABLE_elements(interp, hll_info);
+ if (hll_id >= n)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_GLOBAL_NOT_FOUND,
+ "no such HLL ID (%vd)", hll_id);
+ else {
+ PMC *type_hash;
+ PMC *entry = VTABLE_get_pmc_keyed_int(interp, hll_info, hll_id);
+ PARROT_ASSERT(!PMC_IS_NULL(entry));
+ type_hash = VTABLE_get_pmc_keyed_int(interp, entry, e_HLL_typemap);
+ PARROT_ASSERT(!PMC_IS_NULL(type_hash));
- VTABLE_set_integer_keyed_int(interp, type_hash, core_type, hll_type);
+ VTABLE_set_integer_keyed_int(interp, type_hash, core_type, hll_type);
+ }
+ }
}
/*
Modified: trunk/t/pmc/parrotinterpreter.t
==============================================================================
--- trunk/t/pmc/parrotinterpreter.t Mon Sep 6 12:30:18 2010 (r48810)
+++ trunk/t/pmc/parrotinterpreter.t Mon Sep 6 14:35:49 2010 (r48811)
@@ -17,13 +17,15 @@
=cut
+.include 'except_types.pasm'
.sub main :main
.include 'test_more.pir'
- plan(12)
+ plan(13)
test_new() # 1 test
test_hll_map() # 3 tests
+ test_hll_map_invalid() # 1 tests
# Need for testing
.annotate 'foo', 'bar'
@@ -65,6 +67,26 @@
# Switch back to root namespace
.HLL 'parrot'
+.sub test_hll_map_invalid
+ .local pmc eh
+ .local int result
+ $P0 = get_class 'Integer'
+ $P1 = subclass $P0, 'MyInt'
+ $P2 = getinterp
+ eh = new ['ExceptionHandler']
+ set_label eh, catch
+ eh.'handle_types'(.EXCEPTION_INVALID_OPERATION)
+ result = 0
+ push_eh eh
+ $P2.'hll_map'($P0, $P1)
+ goto done
+ catch:
+ finalize eh
+ result = 1
+ done:
+ is(result, 1, 'hll_map outside an HLL throws')
+.end
+
# Test accessors to various Interp fields
.sub 'test_inspect'
.local pmc interp
More information about the parrot-commits
mailing list