instconstraintvisitor.java

来自「JAVA的一些源码 JAVA2 STANDARD EDITION DEVELO」· Java 代码 · 共 1,790 行 · 第 1/5 页

JAVA
1,790
字号
			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDALOAD(DALOAD o){		indexOfInt(o, stack().peek());		if (stack().peek(1) == Type.NULL){			return;		} 		if (! (stack().peek(1) instanceof ArrayType)){			constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'.");		}		Type t = ((ArrayType) (stack().peek(1))).getBasicType();		if (t != Type.DOUBLE){			constraintViolated(o, "Stack next-to-top must be of type double[] but is '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDASTORE(DASTORE o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		indexOfInt(o, stack().peek(1));		if (stack().peek(2) == Type.NULL){			return;		} 		if (! (stack().peek(2) instanceof ArrayType)){			constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'.");		}		Type t = ((ArrayType) (stack().peek(2))).getBasicType();		if (t != Type.DOUBLE){			constraintViolated(o, "Stack next-to-next-to-top must be of type double[] but is '"+stack().peek(2)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDCMPG(DCMPG o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDCMPL(DCMPL o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDCONST(DCONST o){		// There's nothing to be done here.	}		/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDDIV(DDIV o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDLOAD(DLOAD o){		//visitLoadInstruction(LoadInstruction) is called before.				// Nothing else needs to be done here.	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDMUL(DMUL o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDNEG(DNEG o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDREM(DREM o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDRETURN(DRETURN o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDSTORE(DSTORE o){		//visitStoreInstruction(StoreInstruction) is called before.				// Nothing else needs to be done here.	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDSUB(DSUB o){		if (stack().peek() != Type.DOUBLE){			constraintViolated(o, "The value at the stack top is not of type 'double', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.DOUBLE){			constraintViolated(o, "The value at the stack next-to-top is not of type 'double', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP(DUP o){		if (stack().peek().getSize() != 1){			constraintViolated(o, "Won't DUP type on stack top '"+stack().peek()+"' because it must occupy exactly one slot, not '"+stack().peek().getSize()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP_X1(DUP_X1 o){		if (stack().peek().getSize() != 1){			constraintViolated(o, "Type on stack top '"+stack().peek()+"' should occupy exactly one slot, not '"+stack().peek().getSize()+"'.");		}		if (stack().peek(1).getSize() != 1){			constraintViolated(o, "Type on stack next-to-top '"+stack().peek(1)+"' should occupy exactly one slot, not '"+stack().peek(1).getSize()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP_X2(DUP_X2 o){		if (stack().peek().getSize() != 1){			constraintViolated(o, "Stack top type must be of size 1, but is '"+stack().peek()+"' of size '"+stack().peek().getSize()+"'.");		}		if (stack().peek(1).getSize() == 2){			return; // Form 2, okay.		}		else{   //stack().peek(1).getSize == 1.			if (stack().peek(2).getSize() != 1){				constraintViolated(o, "If stack top's size is 1 and stack next-to-top's size is 1, stack next-to-next-to-top's size must also be 1, but is: '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");			}		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP2(DUP2 o){		if (stack().peek().getSize() == 2){			return; // Form 2, okay.		}		else{ //stack().peek().getSize() == 1.			if (stack().peek(1).getSize() != 1){				constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");			}		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP2_X1(DUP2_X1 o){		if (stack().peek().getSize() == 2){			if (stack().peek(1).getSize() != 1){				constraintViolated(o, "If stack top's size is 2, then stack next-to-top's size must be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");			}			else{				return; // Form 2			}		}		else{ // stack top is of size 1			if ( stack().peek(1).getSize() != 1 ){				constraintViolated(o, "If stack top's size is 1, then stack next-to-top's size must also be 1. But it is '"+stack().peek(1)+"' of size '"+stack().peek(1).getSize()+"'.");			}			if ( stack().peek(2).getSize() != 1 ){				constraintViolated(o, "If stack top's size is 1, then stack next-to-next-to-top's size must also be 1. But it is '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");			}		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitDUP2_X2(DUP2_X2 o){		if (stack().peek(0).getSize() == 2){		 	if (stack().peek(1).getSize() == 2){				return; // Form 4			}			else{// stack top size is 2, next-to-top's size is 1				if ( stack().peek(2).getSize() != 1 ){					constraintViolated(o, "If stack top's size is 2 and stack-next-to-top's size is 1, then stack next-to-next-to-top's size must also be 1. But it is '"+stack().peek(2)+"' of size '"+stack().peek(2).getSize()+"'.");				}				else{					return; // Form 2				}			}		}		else{// stack top is of size 1			if (stack().peek(1).getSize() == 1){				if ( stack().peek(2).getSize() == 2 ){					return; // Form 3				}				else{					if ( stack().peek(3).getSize() == 1){						return; // Form 1					}				}			}		}		constraintViolated(o, "The operand sizes on the stack do not match any of the four forms of usage of this instruction.");	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitF2D(F2D o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitF2I(F2I o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitF2L(F2L o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}	}		/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitFADD(FADD o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.FLOAT){			constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitFALOAD(FALOAD o){		indexOfInt(o, stack().peek());		if (stack().peek(1) == Type.NULL){			return;		} 		if (! (stack().peek(1) instanceof ArrayType)){			constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'.");		}		Type t = ((ArrayType) (stack().peek(1))).getBasicType();		if (t != Type.FLOAT){			constraintViolated(o, "Stack next-to-top must be of type float[] but is '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitFASTORE(FASTORE o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}		indexOfInt(o, stack().peek(1));		if (stack().peek(2) == Type.NULL){			return;		} 		if (! (stack().peek(2) instanceof ArrayType)){			constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'.");		}		Type t = ((ArrayType) (stack().peek(2))).getBasicType();		if (t != Type.FLOAT){			constraintViolated(o, "Stack next-to-next-to-top must be of type float[] but is '"+stack().peek(2)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitFCMPG(FCMPG o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}		if (stack().peek(1) != Type.FLOAT){			constraintViolated(o, "The value at the stack next-to-top is not of type 'float', but of type '"+stack().peek(1)+"'.");		}	}	/**	 * Ensures the specific preconditions of the said instruction.	 */	public void visitFCMPL(FCMPL o){		if (stack().peek() != Type.FLOAT){			constraintViolated(o, "The value at the stack top is not of type 'float', but of type '"+stack().peek()+"'.");		}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?