Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add Whatever forms of some prefix operators.
  • Loading branch information
pmichaud committed Aug 9, 2009
1 parent 7dd4463 commit f489207
Showing 1 changed file with 44 additions and 24 deletions.
68 changes: 44 additions & 24 deletions build/gen_whatever_pir.pl
Expand Up @@ -9,40 +9,57 @@
infix:** infix:* infix:/ infix:% infix:div infix:mod infix:+ infix:-
infix:== infix:!= infix:< infix:> infix:<= infix:>= infix:<=>
infix:.. infix:^.. infix:..^ infix:^..^
prefix:+ prefix:- prefix:~ prefix:? prefix:! prefix:^
);

for (@ops) {
print qq{
.namespace []
.sub '$_' :multi('Whatever', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'Whatever')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'WhateverCode')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
if (/^infix:/) {
print qq{
.namespace []
.sub '$_' :multi('Whatever', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'Whatever')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
.sub '$_' :multi(_, 'WhateverCode')
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
}
else {
print qq{
.namespace []
.sub '$_' :multi('Whatever')
.param pmc x
.tailcall '!whatever_helper'('$_', x)
.end
.sub '$_' :multi('WhateverCode', _)
.param pmc x
.param pmc y
.tailcall '!whatever_helper'('$_', x, y)
.end
};
}
}

print q{
.namespace []
.sub '!whatever_helper' :anon
.param string opname
.param pmc left
.param pmc right
.param pmc right :optional
.local pmc opfunc
opfunc = find_name opname
.lex '$opfunc', opfunc
Expand All @@ -60,8 +77,11 @@
left = find_lex '$left'
right = find_lex '$right'
left = '!whatever_eval'(left, arg)
if null right goto unary
right = '!whatever_eval'(right, arg)
.tailcall opfunc(left, right)
unary:
.tailcall opfunc(left)
.end
.sub '!whatever_eval' :multi(_)
.param pmc whatever
Expand Down

0 comments on commit f489207

Please sign in to comment.