def emit(self, tryBody, target, catchBody): arr = ['try {'] delimitedList(';', tryBody, dest=arr) arr.append('} catch(') arr.append(target) arr.append(') {') delimitedList(';', catchBody, dest=arr) arr.append('}') return arr
def emit(self, name, args, body): arr = ['(function '] if name is not None: arr.append(name) arr.append('(') delimitedList(', ', args, dest=arr) arr.append('){') delimitedList(';\n', body, dest=arr) arr.append('})') return arr
def emit(self, test, body, orelse): arr = ['if (', test, ') {'] delimitedList(';', body, dest=arr) arr.append('}') if orelse: arr.append('else {') delimitedList(';', orelse, dest=arr) arr.append('}') return arr
def emit(self, test, body): arr = ['while (', test, ') {'] delimitedList(';', body, dest=arr) arr.append('}') return arr
def emit(self, statements): return delimitedList(';\n', statements, delimAtEnd=True)
def emit(self, func, args): arr = ['(new ', func, '('] delimitedList(', ', args, dest=arr) arr.append('))') return arr
def emit(self, elts): arr = ['['] delimitedList(', ', elts, dest=arr) arr.append(']') return arr
def emit(self, target, source, body): arr = ['for (var ', target, ' in ', source, ') {'] delimitedList(';', body, dest=arr) arr.append('}') return arr
def emit(self, left, test, right, body): arr = ['for (', left, '; ', test, '; ', right, ') {'] delimitedList(';', body, dest=arr) arr.append('}') return arr