Skip to content

Commit

Permalink
move helper functions out of the matrixy.pir driver file and into src…
Browse files Browse the repository at this point in the history
…/internals/*
  • Loading branch information
Whiteknight committed Oct 21, 2009
1 parent 9821908 commit 264840d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
32 changes: 0 additions & 32 deletions matrixy.pir
Expand Up @@ -89,38 +89,6 @@ to the Matrixy compiler.
.include 'src/gen_grammar.pir'
.include 'src/gen_actions.pir'
.namespace []
.sub '!hash'
.param pmc fields :slurpy :named
.return (fields)
.end
.sub '_new_empty_array'
$P0 = new 'ResizablePMCArray'
.return($P0)
.end
# TODO: Move this to somewhere in src/internals/*
.sub '_terminator_has_semicolon'
.param string term
$S0 = substr term, 0, 1
if $S0 == ';' goto has_semicolon
.return(0)
has_semicolon:
.return(1)
.end
.sub '!get_first_array_row'
.param pmc m
$S0 = typeof m
if $S0 == 'ResizablePMCArray' goto have_matrix
.return(m)
have_matrix:
$P0 = m[0]
.return($P0)
.end
=back
=cut
Expand Down
12 changes: 12 additions & 0 deletions src/internals/aggregates.pir
@@ -0,0 +1,12 @@

.namespace []

.sub '!hash'
.param pmc fields :slurpy :named
.return (fields)
.end

.sub '_new_empty_array'
$P0 = new 'ResizablePMCArray'
.return($P0)
.end
17 changes: 17 additions & 0 deletions src/internals/matrix.pir
Expand Up @@ -526,6 +526,23 @@ Can only dispatch over an internal function, not a builtin or a library routine.
# TODO: Implement this.
.end

=item !get_first_array_row

Get the first row from a matrix. If it's not a matrix/vector, just return
the PMC itself
=cut
.sub '!get_first_array_row'
.param pmc m
$S0 = typeof m
if $S0 == 'ResizablePMCArray' goto have_matrix
.return(m)
have_matrix:
$P0 = m[0]
.return($P0)
.end
=back
=cut
Expand Down
10 changes: 10 additions & 0 deletions src/internals/parser.pir
@@ -0,0 +1,10 @@
.namespace []

.sub '_terminator_has_semicolon'
.param string term
$S0 = substr term, 0, 1
if $S0 == ';' goto has_semicolon
.return(0)
has_semicolon:
.return(1)
.end

0 comments on commit 264840d

Please sign in to comment.