Skip to content

Commit

Permalink
PCT: PAST.Compiler - add repeat inline
Browse files Browse the repository at this point in the history
  • Loading branch information
Benabik committed Apr 30, 2012
1 parent b3417fa commit 1202f2c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions compilers/pct/src/PAST/Compiler.winxed
Expand Up @@ -55,6 +55,12 @@ inline is_cclass(int cclass, string str, int pos) return int {
return ret;
}

inline repeat(string str, int times) return string {
string ret;
${ repeat ret, str, times };
return ret;
}

namespace PAST.Compiler {
// TEMPREG_BASE and UNIQUE_BASE identify the base location for
// the temporary register set and unique registers
Expand Down Expand Up @@ -667,10 +673,8 @@ Common code for as_post(PAST::Node) and as_post(PAST::Stmts)
function node_as_post[method](var node, options [slurpy, named]) {
string rtype = options['rtype'];
:(string signature) = node.signature();
if (!signature) {
${ repeat signature, 'v', elements(node.list()) };
signature += rtype;
}
if (!signature)
signature = repeat('v', elements(node.list())) + rtype;
var ops = self.post_children(node, signature:[named('signature')]);
var result = ops[-1];
int i = indexof('0123456789', substr(signature, 0, 1));
Expand Down

0 comments on commit 1202f2c

Please sign in to comment.