marko/compiler/ast/SelfInvokingFunction.js
Patrick Steele-Idem c386da875e Fixes #349 - Inline Marko template compilation support
Also changed how JavaScript code is generated
2016-08-19 10:50:28 -06:00

31 lines
842 B
JavaScript

'use strict';
var Node = require('./Node');
class SelfInvokingFunction extends Node {
constructor(def) {
super('SelfInvokingFunction');
this.params = def.params;
this.args = def.args;
this.body = this.makeContainer(def.body);
}
generateCode(codegen) {
var params = this.params || [];
var args = this.args || [];
var body = codegen.generateCode(this.body);
var functionDeclaration = codegen.builder.functionDeclaration(null, params, body);
var functionCall = codegen.builder.functionCall(functionDeclaration, args);
return functionCall;
}
walk(walker) {
this.params = walker.walk(this.params);
this.args = walker.walk(this.args);
this.body = walker.walk(this.body);
}
}
module.exports = SelfInvokingFunction;