-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some functions to manipulate parrot objects better without descen…
…ding into inline PIR
- Loading branch information
1 parent
95a1beb
commit c58eecd
Showing
2 changed files
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.namespace ["_Matrixy";"builtins"] | ||
|
||
.sub parrot_method | ||
.param int nargout | ||
.param int nargin | ||
.param pmc obj | ||
.param pmc method | ||
.param pmc args :slurpy | ||
|
||
$S0 = typeof method | ||
if $S0 == "String" goto have_string | ||
if $S0 == "CharMatrix2D" goto have_string_array | ||
error("method must be a string") | ||
have_string: | ||
$S0 = method | ||
goto have_method_str | ||
have_string_array: | ||
$S0 = method[0] | ||
have_method_str: | ||
$P1 = new ['PMCMatrix2D'] | ||
($P0 :slurpy) = obj.$S0(args :flat) | ||
if null $P0 goto just_return | ||
$P1.'initialize_from_array'($P0) | ||
just_return: | ||
.return($P1) | ||
.end |
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,27 @@ | ||
.namespace ["_Matrixy";"builtins"] | ||
|
||
.sub parrot_new | ||
.param int nargout | ||
.param int nargin | ||
.param pmc type | ||
.param pmc init :optional | ||
.param int has_init :opt_flag | ||
|
||
$S0 = typeof type | ||
if $S0 == "String" goto have_string | ||
if $S0 == "CharMatrix2D" goto have_string_array | ||
error("type must be a string") | ||
have_string: | ||
$S0 = type | ||
goto have_type_str | ||
have_string_array: | ||
$S0 = type[0] | ||
have_type_str: | ||
if has_init goto use_initializer | ||
$P0 = new [$S0] | ||
.return($P0) | ||
use_initializer: | ||
$P0 = new [$S0], init | ||
.return($P0) | ||
.end | ||
|