StackNode.js 705 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import Node from './Node.js';
  2. import OperatorNode from '../math/OperatorNode.js';
  3. class StackNode extends Node {
  4. constructor() {
  5. super();
  6. this.nodes = [];
  7. this.outputNode = null;
  8. this.isStackNode = true;
  9. }
  10. getNodeType( builder ) {
  11. return this.outputNode ? this.outputNode.getNodeType( builder ) : 'void';
  12. }
  13. assign( targetNode, sourceValue ) {
  14. this.nodes.push( new OperatorNode( '=', targetNode, sourceValue ) );
  15. return this;
  16. }
  17. build( builder, ...params ) {
  18. for ( const node of this.nodes ) {
  19. node.build( builder );
  20. }
  21. return this.outputNode ? this.outputNode.build( builder, ...params ) : super.build( builder, ...params );
  22. }
  23. }
  24. export default StackNode;