/** Returns a copy of the current operand. */ public Operand copy() { RegisterOperand newBase = (base != null) ? (RegisterOperand) base.copy() : null; RegisterOperand newIndex = (index != null) ? (RegisterOperand) index.copy() : null; LocationOperand newLoc = (loc != null) ? (LocationOperand) loc.copy() : null; Operand newGuard = (guard != null) ? guard.copy() : null; return new MemoryOperand(newBase, newIndex, scale, disp, size, newLoc, newGuard); }
public MemoryOperand( RegisterOperand base, RegisterOperand index, byte scale, Offset disp, byte size, LocationOperand loc, Operand guard) { this.loc = loc; this.guard = guard; this.base = base; this.index = index; this.scale = scale; this.disp = disp; this.size = size; if (loc != null) loc.instruction = null; if (guard != null) guard.instruction = null; if (base != null) base.instruction = null; if (index != null) index.instruction = null; }
/** * Returns if this operand is the 'same' as another operand. * * @param op other operand */ public boolean similar(Operand op) { if (op instanceof MemoryOperand) { MemoryOperand mop = (MemoryOperand) op; if (base == null) { if (mop.base != null) return false; } else { if (mop.base == null) return false; if (!base.similar(mop.base)) return false; } if (index == null) { if (mop.index != null) return false; } else { if (mop.index == null) return false; if (!index.similar(mop.index)) return false; } return (mop.scale == scale) && (mop.disp.EQ(disp)) && (mop.size == size); } else { return false; } }