You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
435 B
33 lines
435 B
2 years ago
|
import TempNode from './TempNode.js';
|
||
|
|
||
|
class ExpressionNode extends TempNode {
|
||
|
|
||
|
constructor( snipped = '', nodeType = 'void' ) {
|
||
|
|
||
|
super( nodeType );
|
||
|
|
||
|
this.snipped = snipped;
|
||
|
|
||
|
}
|
||
|
|
||
|
generate( builder ) {
|
||
|
|
||
|
const type = this.getNodeType( builder );
|
||
|
const snipped = this.snipped;
|
||
|
|
||
|
if ( type === 'void' ) {
|
||
|
|
||
|
builder.addFlowCode( snipped );
|
||
|
|
||
|
} else {
|
||
|
|
||
|
return `( ${ snipped } )`;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
export default ExpressionNode;
|