Author: allison
Date: Fri Mar 16 23:00:27 2007
New Revision: 17523
Modified:
trunk/compilers/smop/t/class.t
trunk/compilers/smop/t/superclass.t
trunk/runtime/parrot/include/hllmacros.pir
trunk/runtime/parrot/library/Test/More.pir
trunk/t/library/iter.t
trunk/t/op/cmp-nonbranch.t
trunk/t/pmc/multisub.t
trunk/t/pmc/smop_attribute.t
trunk/t/pmc/smop_class.t
trunk/tools/util/crow.pir
Log:
The .IMPORT macro must die! (Part 2) Replacing it with namespace export
functionality.
Modified: trunk/compilers/smop/t/class.t
==============================================================================
--- trunk/compilers/smop/t/class.t (original)
+++ trunk/compilers/smop/t/class.t Fri Mar 16 23:00:27 2007
@@ -1,19 +1,15 @@
#!./parrot
-.macro IMPORT ( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
-
.sub _main :main
load_bytecode 'library/Test/More.pir'
load_bytecode 'compilers/smop/Class.pir'
load_bytecode 'compilers/smop/Attribute.pir'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
- .IMPORT( 'Test::More', 'is', _ )
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is"
+ test_namespace.export_to(curr_namespace, exports)
plan( 12 )
Modified: trunk/compilers/smop/t/superclass.t
==============================================================================
--- trunk/compilers/smop/t/superclass.t (original)
+++ trunk/compilers/smop/t/superclass.t Fri Mar 16 23:00:27 2007
@@ -1,21 +1,15 @@
#!./parrot
-# -*- pir -*- mode please, emacs!
-
-.macro IMPORT ( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
.sub _main :main
load_bytecode 'library/Test/More.pir'
load_bytecode 'compilers/smop/Class.pir'
load_bytecode 'compilers/smop/Attribute.pir'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
- .IMPORT( 'Test::More', 'is', _ )
- .IMPORT( 'Test::More', 'pass', _ )
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is"
+ test_namespace.export_to(curr_namespace, exports)
plan( 12 )
Modified: trunk/runtime/parrot/include/hllmacros.pir
==============================================================================
--- trunk/runtime/parrot/include/hllmacros.pir (original)
+++ trunk/runtime/parrot/include/hllmacros.pir Fri Mar 16 23:00:27 2007
@@ -147,19 +147,6 @@
.endm
-=item C<.IMPORT(.macro IMPORT ( lib, subname, TEMP )>
-
-Imports a C<subname> from the C<lib> namespace into the current namespace.
-C<TEMP> is a temporary pmc used to store the sub.
-
-=cut
-
-.macro IMPORT( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
-
-
=back
=head1 Examples
@@ -231,19 +218,6 @@
print "\n"
})
-=head2 Importing subroutines
-
- .include 'hllmacros.pir'
- .sub 'main' :main
- load_bytecode 'Test/More.pbc'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
-
- plan( 1 )
- ok(1, 'my test works')
- .end
-
=head1 Caveats
Modified: trunk/runtime/parrot/library/Test/More.pir
==============================================================================
--- trunk/runtime/parrot/library/Test/More.pir (original)
+++ trunk/runtime/parrot/library/Test/More.pir Fri Mar 16 23:00:27 2007
@@ -8,19 +8,12 @@
load_bytecode 'library/Test/More.pir'
# get the testing functions
- .local pmc plan
- .local pmc diag
- .local pmc ok
- .local pmc is
- .local pmc is_deeply
- .local pmc like
-
- plan = find_global 'Test::More', 'plan'
- diag = find_global 'Test::More', 'diag'
- ok = find_global 'Test::More', 'ok'
- is = find_global 'Test::More', 'is'
- is_deeply = find_global 'Test::More', 'is_deeply'
- like = find_global 'Test::More', 'like'
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan diag ok is is_deeply like isa_ok"
+
+ test_namespace."export_to"(curr_namespace, exports)
# set a test plan
plan( 12 )
Modified: trunk/t/library/iter.t
==============================================================================
--- trunk/t/library/iter.t (original)
+++ trunk/t/library/iter.t Fri Mar 16 23:00:27 2007
@@ -4,19 +4,6 @@
.const int TESTS = 47
-.macro IMPORT(lib,func)
- _ = find_global .lib, .func
- store_global .func, _
-.endm
-
-.macro TEST_IMPORT()
- .sym pmc _
- .IMPORT('Test::More', 'ok')
- .IMPORT('Test::More', 'is')
- .IMPORT('Test::More', 'diag')
-.endm
-
-
.sub 'main' :main
load_bytecode 'Test/More.pir'
@@ -29,8 +16,12 @@
store_global 'TEST_VERBOSE', $P0
import:
- .local pmc _
- .IMPORT('Test::More', 'plan')
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is diag"
+ test_namespace.export_to(curr_namespace, exports)
+
'plan'( TESTS )
'load'()
@@ -43,7 +34,6 @@
.sub 'load'
- .TEST_IMPORT()
'diag'('test library loading')
T1:
@@ -65,7 +55,6 @@
.sub 'object_init'
- .TEST_IMPORT()
'diag'('test object initialization')
T1:
@@ -101,7 +90,6 @@
.sub 'FixedPMCArray_empty'
- .TEST_IMPORT()
'diag'('test empty FixedPMCArray')
T1:
@@ -146,7 +134,6 @@
.sub 'FixedPMCArray_3elem'
- .TEST_IMPORT()
'diag'('test FixedPMCArray with three elements')
T1:
@@ -239,7 +226,6 @@
.sub 'ResizablePMCArray_empty'
- .TEST_IMPORT()
'diag'('test empty ResizablePMCArray')
T1:
@@ -284,7 +270,6 @@
.sub 'ResizablePMCArray_3elem'
- .TEST_IMPORT()
'diag'('test ResizablePMCArray with three elements')
T1:
Modified: trunk/t/op/cmp-nonbranch.t
==============================================================================
--- trunk/t/op/cmp-nonbranch.t (original)
+++ trunk/t/op/cmp-nonbranch.t Fri Mar 16 23:00:27 2007
@@ -19,12 +19,6 @@
.const int TESTS = 88
-
-.macro IMPORT( lib, subname )
- import_sub = find_global .lib, .subname
- store_global .subname, import_sub
-.endm
-
.macro EXP()
exp_nok:
exp = 0
@@ -53,12 +47,14 @@
.sub 'main' :main
load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'plan' )
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan is"
+ test_namespace.export_to(curr_namespace, exports)
.local string res, exp, desc
-
'plan'(TESTS)
'issame'()
@@ -77,10 +73,6 @@
.sub 'issame'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local int exp, res
.local string desc
.SET_DESC('issame')
@@ -108,10 +100,6 @@
.sub 'isntsame'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local int exp, res
.local string desc
.SET_DESC('isntsame')
@@ -139,10 +127,6 @@
.sub 'istrue'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local int exp, res
.local string desc
.SET_DESC('istrue')
@@ -165,10 +149,6 @@
.sub 'isfalse'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local int exp, res
.local string desc
.SET_DESC('isfalse')
@@ -191,10 +171,6 @@
.sub 'isnull'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local int exp, res
.local string desc
.SET_DESC('isnull')
@@ -226,10 +202,6 @@
.sub 'isgt'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -387,10 +359,6 @@
.sub 'isge'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -548,10 +516,6 @@
.sub 'isle'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -709,10 +673,6 @@
.sub 'islt'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -870,10 +830,6 @@
.sub 'iseq'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -1031,10 +987,6 @@
.sub 'isne'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
@@ -1192,10 +1144,6 @@
.sub 'cmp'
- load_bytecode 'Test/More.pir'
- .local pmc import_sub
- .IMPORT( 'Test::More', 'is' )
-
.local string exp, res
.local string desc
.SET_DESC('cmp')
Modified: trunk/t/pmc/multisub.t
==============================================================================
--- trunk/t/pmc/multisub.t (original)
+++ trunk/t/pmc/multisub.t Fri Mar 16 23:00:27 2007
@@ -2,11 +2,6 @@
# Copyright (C) 2001-2007, The Perl Foundation.
# $Id$
-.macro IMPORT ( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
-
=head1 NAME
t/pmc/multisub.t - Multi Sub PMCs
@@ -25,10 +20,11 @@
.sub main :main
load_bytecode 'library/Test/More.pir'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
- .IMPORT( 'Test::More', 'is', _ )
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is"
+ test_namespace.export_to(curr_namespace, exports)
plan( 6 )
Modified: trunk/t/pmc/smop_attribute.t
==============================================================================
--- trunk/t/pmc/smop_attribute.t (original)
+++ trunk/t/pmc/smop_attribute.t Fri Mar 16 23:00:27 2007
@@ -17,18 +17,15 @@
=cut
-.macro IMPORT ( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
-
.sub _main :main
load_bytecode 'library/Test/More.pir'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
- .IMPORT( 'Test::More', 'is', _ )
+ # import test routines
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is isa_ok"
+ test_namespace.export_to(curr_namespace, exports)
plan( 9 )
Modified: trunk/t/pmc/smop_class.t
==============================================================================
--- trunk/t/pmc/smop_class.t (original)
+++ trunk/t/pmc/smop_class.t Fri Mar 16 23:00:27 2007
@@ -17,18 +17,15 @@
=cut
-.macro IMPORT ( lib, subname, TEMP )
- .TEMP = find_global .lib, .subname
- store_global .subname, .TEMP
-.endm
-
.sub _main :main
load_bytecode 'library/Test/More.pir'
- .local pmc _
- .IMPORT( 'Test::More', 'plan', _ )
- .IMPORT( 'Test::More', 'ok', _ )
- .IMPORT( 'Test::More', 'is', _ )
+ # import test routines
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ "Test::More" ]
+ exports = split " ", "plan ok is isa_ok"
+ test_namespace.export_to(curr_namespace, exports)
plan( 1 )
Modified: trunk/tools/util/crow.pir
==============================================================================
--- trunk/tools/util/crow.pir (original)
+++ trunk/tools/util/crow.pir Fri Mar 16 23:00:27 2007
@@ -20,18 +20,16 @@
=cut
-.include 'hllmacros.pir'
-
-
.sub 'main' :main
.param pmc args
load_bytecode 'Crow.pir' # TODO s/pbc/pir/
- .local pmc _
- .IMPORT( ['Crow'], 'get_args', _ )
- .IMPORT( ['Crow'], 'get_news', _ )
- .IMPORT( ['Crow'], 'process', _ )
+ .local pmc exports, curr_namespace, test_namespace
+ curr_namespace = get_namespace
+ test_namespace = get_namespace [ 'Crow' ]
+ exports = split " ", "get_args get_news process"
+ test_namespace.export_to(curr_namespace, exports)
.local pmc opts
opts = get_args(args)