Permalink
Browse files

added repeat clause

  • Loading branch information...
1 parent f7a58ef commit f0dc1edc88c3ba6cfc973b3033d2e1a57c568eeb @fabriceleal committed Apr 16, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 compiler.js
View
@@ -38,6 +38,9 @@ var endTime = function (time, expr) {
return leftside > rightside ? leftside : rightside;
}
+ if(expr.tag == 'repeat'){
+ return totalDuration(expr.section) * expr.count;
+ }
// The duration of a seq node is the sum of the durations
return totalDuration(expr.left) + totalDuration(expr.right);
@@ -120,6 +123,15 @@ var compileT = function(expr, time){
dur : expr.dur
});
}
+ if(expr.tag == 'repeat'){
+ for(var i = 0; i < expr.count; i++){
+ var rl = compileT(expr.section, time);
+ time = endTime(expr.section);
+ rl.forEach(function(val, idx, arr){
+ ret.push(val);
+ });
+ }
+ }
if(expr.tag == 'par'){
// Call on left and right with the same starting time
var l = compileT(expr.left, time);

0 comments on commit f0dc1ed

Please sign in to comment.