marko/compiler/ast/SelfInvokingFunction.js
2015-12-28 21:55:29 -07:00

27 lines
729 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 = this.body;
codegen.write('(');
var functionDeclaration = codegen.builder.functionDeclaration(null, params, body);
var functionCall = codegen.builder.functionCall(functionDeclaration, args);
codegen.generateCode(functionCall);
codegen.write(')');
}
}
module.exports = SelfInvokingFunction;