forked from pmichaud/pmtcl
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move "invoke" to a helper class, refer to it as a WVal
- Loading branch information
Showing
4 changed files
with
33 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Internals { | ||
|
||
## wrapper method for invoking tcl builtins - deals with unknown | ||
## handling and namespace desugaring | ||
|
||
method invoke($command, *@args) { | ||
|
||
## Get our caller's namespace, do the lookup from there. | ||
my $ns := Q:PIR { | ||
$P1 = getinterp | ||
%r = $P1['sub'; 1] | ||
}.get_namespace(); | ||
my &command := $ns{$command}; | ||
|
||
## if that didn't work, check in the root ns. | ||
if pir::typeof__SP(&command) eq "Undef" { | ||
$ns := pir::get_hll_namespace__P(); | ||
&command := $ns{$command}; | ||
} | ||
|
||
if pir::typeof__SP(&command) eq "Undef" { | ||
error("invalid command name \"$command\""); | ||
} | ||
|
||
&command(|@args); | ||
} | ||
} | ||
# vim: expandtab shiftwidth=4 ft=perl6: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
use src::Internals; | ||
|
||
class Partcl::Actions is HLL::Actions { | ||
|
||
method TOP($/) { make $<TOP_eval>.ast; } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters