12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import Node from '../core/Node.js';
- class OperatorNode extends Node {
- constructor( op, a, b ) {
- super();
- this.op = op;
- this.a = a;
- this.b = b;
- }
- getType( builder ) {
- const typeA = this.a.getType( builder );
- const typeB = this.b.getType( builder );
- // use the greater length vector
- if ( builder.getTypeLength( typeB ) > builder.getTypeLength( typeA ) ) {
- return typeB;
- }
- return typeA;
- }
- generate( builder, output ) {
- const type = this.getType( builder );
- const a = this.a.build( builder, type );
- const b = this.b.build( builder, type );
- return builder.format( `( ${a} ${this.op} ${b} )`, type, output );
- }
- }
- export default OperatorNode;
|