Skip to content

Commit

Permalink
fix [namespace eval foo { proc ...}].
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Aug 18, 2010
1 parent 5d277ca commit 63f2bf6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Partcl/Actions.pm
Expand Up @@ -42,7 +42,7 @@ sub lex_block($past) {
:viviself(
PAST::Op.new(
:pasttype<callmethod>, :name<newpad>,
PAST::Var.new( :name<TclLexPad>, :scope<package> ),
PAST::Var.new( :name<TclLexPad>, :scope<package>, :namespace<> ),
PAST::Op.new(:pirop('find_dynamic_lex Ps'), '%LEXPAD')
)
)
Expand Down
10 changes: 8 additions & 2 deletions src/Partcl/commands/proc.pm
Expand Up @@ -52,8 +52,14 @@ our sub proc(*@args) {
}
$block.name($name);
$block.control('return_pir');
PAST::Compiler.compile($block);
my $thing := pir::get_hll_global__PS($name);

if ! pir::isnull(pir::find_dynamic_lex('@*PARTCL_COMPILER_NAMESPACE')) {
$block.namespace(@*PARTCL_COMPILER_NAMESPACE);
}

## compile() returns an Eval. extract out the first sub, which is our proc.
my $thing := PAST::Compiler.compile($block)[0];

pir::setprop($thing, 'args', @argsInfo);
pir::setprop($thing, 'defaults', %defaults);
pir::setprop($thing, 'body', $body);
Expand Down
2 changes: 1 addition & 1 deletion t/cmd_foreach.t
Expand Up @@ -95,6 +95,6 @@ eval_is {
proc a {} {error ok}
foreach n 1 a
}
} ok {namespace resolution in body} {TODO NQPRX}
} ok {namespace resolution in body}

# vim: filetype=tcl:
4 changes: 2 additions & 2 deletions t/cmd_if.t
Expand Up @@ -131,15 +131,15 @@ eval_is {
proc a {} {error ok}
if {[a]} {}
}
} ok {namespace resolution in cond} {TODO NQPRX}
} ok {namespace resolution in cond}

eval_is {
namespace eval lib {
set val {}
proc a {} {error ok}
if 1 a
}
} ok {namespace resolution in body} {TODO NQPRX}
} ok {namespace resolution in body}

eval_is {if {}} \
{empty expression
Expand Down
8 changes: 2 additions & 6 deletions t/cmd_namespace.t
Expand Up @@ -78,14 +78,12 @@ eval_is {namespace eval foo} \
{wrong # args: should be "namespace eval name arg ?arg...?"} \
{namespace eval: too few args}

if 0 {
namespace eval foo {
proc bar {} {return ok}
namespace eval bar {
proc baz {} {return ok}
}
}
} ;# SKIP for now as namespace eval is a work in progress..

is [namespace exists foo] 1 {namespace eval foo: namespace exists} {TODO NQPRX}
eval_is {foo::bar} ok {namespace eval foo: proc} {TODO NQPRX}
Expand Down Expand Up @@ -124,7 +122,6 @@ is [namespace parent ""] {} {namespace parent: ::}
is [namespace parent foo] :: {namespace parent: ::foo (explicit)} {TODO NQPRX}
is [namespace eval foo {namespace parent}] :: {namespace parent: ::foo (implicit)} {TODO NQPRX}

if 0 {
namespace eval perl6 {
proc passthrough {val} {
return $val
Expand All @@ -133,16 +130,15 @@ namespace eval perl6 {
passthrough 3
}
}
} ;# SKIP for now as namespace eval is a work in progress..

eval_is {perl6::pi} 3 \
{do procs in namespace default to that namespace when looking for commands?} {TODO NQPRX}

if 0 {
if 0 { ## SKIP NQP-RX
namespace eval perl6 {
namespace export pi
}
} ;# SKIP for now as namespace eval is a work in progress..
}
namespace import perl6::pi
eval_is {pi} 3 {simple import test} {TODO NQPRX}

Expand Down

0 comments on commit 63f2bf6

Please sign in to comment.