All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.compiler.ir.instructions.TwoOperandInstr Maven / Gradle / Ivy

There is a newer version: 9.4.7.0
Show newest version
package org.jruby.compiler.ir.instructions;

import java.util.Map;

import org.jruby.compiler.ir.Operation;
import org.jruby.compiler.ir.operands.Operand;
import org.jruby.compiler.ir.operands.Variable;

// This is of the form:
//   v = OP(arg1, arg2, attribute_array); Ex: v = ADD(v1, v2)
public abstract class TwoOperandInstr extends Instr {
    Operand operand1;
    Operand operand2;

    public TwoOperandInstr(Operation op, Variable destination, Operand a1, Operand a2) {
        super(op, destination);
        operand1 = a1;
        operand2 = a2;
    }

    @Override
    public String toString() {
        return super.toString() + "(" + operand1 + ", " + operand2 + ")";
    }

    public Operand[] getOperands() {
        return new Operand[]{operand1, operand2};
    }

    public Operand getOperand1() {
        return operand1;
    }
    
    public Operand getOperand2() {
        return operand2;
    }

    public void simplifyOperands(Map valueMap) {
        operand1 = operand1.getSimplifiedOperand(valueMap);
        operand2 = operand2.getSimplifiedOperand(valueMap);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy