mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Marko v3: added builder.containerNode(...)
This commit is contained in:
parent
d1fcc2f983
commit
63b80196ff
@ -43,6 +43,7 @@ var VariableDeclarator = require('./ast/VariableDeclarator');
|
||||
var ThisExpression = require('./ast/ThisExpression');
|
||||
var Expression = require('./ast/Expression');
|
||||
var Scriptlet = require('./ast/Scriptlet');
|
||||
var ContainerNode = require('./ast/ContainerNode');
|
||||
|
||||
var parseExpression = require('./util/parseExpression');
|
||||
var parseJavaScriptArgs = require('./util/parseJavaScriptArgs');
|
||||
@ -133,6 +134,19 @@ class Builder {
|
||||
return new ConditionalExpression({test, consequent, alternate});
|
||||
}
|
||||
|
||||
containerNode(type, generateCode) {
|
||||
if (typeof type === 'function') {
|
||||
generateCode = arguments[0];
|
||||
type = 'ContainerNode';
|
||||
}
|
||||
|
||||
var node = new ContainerNode(type);
|
||||
if (generateCode) {
|
||||
node.setCodeGenerator(generateCode);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
elseStatement(body) {
|
||||
return new Else({body});
|
||||
}
|
||||
|
||||
16
compiler/ast/ContainerNode.js
Normal file
16
compiler/ast/ContainerNode.js
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
var Node = require('./Node');
|
||||
|
||||
class ContainerNode extends Node {
|
||||
constructor(def) {
|
||||
super('ContainerNode');
|
||||
this.body = this.makeContainer(def.body);
|
||||
}
|
||||
|
||||
walk(walker) {
|
||||
this.body = walker.walk(this.body);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ContainerNode;
|
||||
Loading…
x
Reference in New Issue
Block a user