⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classfilewriter.java

📁 javascript语言的解释器源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		} else {			offset = putInt16(0, data, offset); // no attributes		}		if (offset != dataSize) {			// Check getWriteSize is consistent with write!			throw new RuntimeException();		}		return data;	}	static int putInt64(long value, byte[] array, int offset) {		offset = putInt32((int) (value >>> 32), array, offset);		return putInt32((int) value, array, offset);	}	private static void badStack(int value) {		String s;		if (value < 0) {			s = "Stack underflow: " + value;		} else {			s = "Too big stack: " + value;		}		throw new IllegalStateException(s);	}	/*	 * Really weird. Returns an int with # parameters in hi 16 bits, and stack	 * difference removal of parameters from stack and pushing the result (it	 * does not take into account removal of this in case of non-static	 * methods). If Java really supported references we wouldn't have to be this	 * perverted.	 */	private static int sizeOfParameters(String pString) {		int length = pString.length();		int rightParenthesis = pString.lastIndexOf(')');		if (3 <= length /* minimal signature takes at least 3 chars: ()V */				&& pString.charAt(0) == '(' && 1 <= rightParenthesis				&& rightParenthesis + 1 < length) {			boolean ok = true;			int index = 1;			int stackDiff = 0;			int count = 0;			stringLoop: while (index != rightParenthesis) {				switch (pString.charAt(index)) {				default:					ok = false;					break stringLoop;				case 'J':				case 'D':					--stackDiff;					// fall thru				case 'B':				case 'S':				case 'C':				case 'I':				case 'Z':				case 'F':					--stackDiff;					++count;					++index;					continue;				case '[':					++index;					int c = pString.charAt(index);					while (c == '[') {						++index;						c = pString.charAt(index);					}					switch (c) {					default:						ok = false;						break stringLoop;					case 'J':					case 'D':					case 'B':					case 'S':					case 'C':					case 'I':					case 'Z':					case 'F':						--stackDiff;						++count;						++index;						continue;					case 'L':						// fall thru					}					// fall thru				case 'L': {					--stackDiff;					++count;					++index;					int semicolon = pString.indexOf(';', index);					if (!(index + 1 <= semicolon && semicolon < rightParenthesis)) {						ok = false;						break stringLoop;					}					index = semicolon + 1;					continue;				}				}			}			if (ok) {				switch (pString.charAt(rightParenthesis + 1)) {				default:					ok = false;					break;				case 'J':				case 'D':					++stackDiff;					// fall thru				case 'B':				case 'S':				case 'C':				case 'I':				case 'Z':				case 'F':				case 'L':				case '[':					++stackDiff;					// fall thru				case 'V':					break;				}				if (ok) {					return ((count << 16) | (0xFFFF & stackDiff));				}			}		}		throw new IllegalArgumentException("Bad parameter signature: "				+ pString);	}	static int putInt16(int value, byte[] array, int offset) {		array[offset + 0] = (byte) (value >>> 8);		array[offset + 1] = (byte) value;		return offset + 2;	}	static int putInt32(int value, byte[] array, int offset) {		array[offset + 0] = (byte) (value >>> 24);		array[offset + 1] = (byte) (value >>> 16);		array[offset + 2] = (byte) (value >>> 8);		array[offset + 3] = (byte) value;		return offset + 4;	}	/**	 * Number of operands accompanying the opcode.	 */	static int opcodeCount(int opcode) {		switch (opcode) {		case ByteCode.AALOAD:		case ByteCode.AASTORE:		case ByteCode.ACONST_NULL:		case ByteCode.ALOAD_0:		case ByteCode.ALOAD_1:		case ByteCode.ALOAD_2:		case ByteCode.ALOAD_3:		case ByteCode.ARETURN:		case ByteCode.ARRAYLENGTH:		case ByteCode.ASTORE_0:		case ByteCode.ASTORE_1:		case ByteCode.ASTORE_2:		case ByteCode.ASTORE_3:		case ByteCode.ATHROW:		case ByteCode.BALOAD:		case ByteCode.BASTORE:		case ByteCode.BREAKPOINT:		case ByteCode.CALOAD:		case ByteCode.CASTORE:		case ByteCode.D2F:		case ByteCode.D2I:		case ByteCode.D2L:		case ByteCode.DADD:		case ByteCode.DALOAD:		case ByteCode.DASTORE:		case ByteCode.DCMPG:		case ByteCode.DCMPL:		case ByteCode.DCONST_0:		case ByteCode.DCONST_1:		case ByteCode.DDIV:		case ByteCode.DLOAD_0:		case ByteCode.DLOAD_1:		case ByteCode.DLOAD_2:		case ByteCode.DLOAD_3:		case ByteCode.DMUL:		case ByteCode.DNEG:		case ByteCode.DREM:		case ByteCode.DRETURN:		case ByteCode.DSTORE_0:		case ByteCode.DSTORE_1:		case ByteCode.DSTORE_2:		case ByteCode.DSTORE_3:		case ByteCode.DSUB:		case ByteCode.DUP:		case ByteCode.DUP2:		case ByteCode.DUP2_X1:		case ByteCode.DUP2_X2:		case ByteCode.DUP_X1:		case ByteCode.DUP_X2:		case ByteCode.F2D:		case ByteCode.F2I:		case ByteCode.F2L:		case ByteCode.FADD:		case ByteCode.FALOAD:		case ByteCode.FASTORE:		case ByteCode.FCMPG:		case ByteCode.FCMPL:		case ByteCode.FCONST_0:		case ByteCode.FCONST_1:		case ByteCode.FCONST_2:		case ByteCode.FDIV:		case ByteCode.FLOAD_0:		case ByteCode.FLOAD_1:		case ByteCode.FLOAD_2:		case ByteCode.FLOAD_3:		case ByteCode.FMUL:		case ByteCode.FNEG:		case ByteCode.FREM:		case ByteCode.FRETURN:		case ByteCode.FSTORE_0:		case ByteCode.FSTORE_1:		case ByteCode.FSTORE_2:		case ByteCode.FSTORE_3:		case ByteCode.FSUB:		case ByteCode.I2B:		case ByteCode.I2C:		case ByteCode.I2D:		case ByteCode.I2F:		case ByteCode.I2L:		case ByteCode.I2S:		case ByteCode.IADD:		case ByteCode.IALOAD:		case ByteCode.IAND:		case ByteCode.IASTORE:		case ByteCode.ICONST_0:		case ByteCode.ICONST_1:		case ByteCode.ICONST_2:		case ByteCode.ICONST_3:		case ByteCode.ICONST_4:		case ByteCode.ICONST_5:		case ByteCode.ICONST_M1:		case ByteCode.IDIV:		case ByteCode.ILOAD_0:		case ByteCode.ILOAD_1:		case ByteCode.ILOAD_2:		case ByteCode.ILOAD_3:		case ByteCode.IMPDEP1:		case ByteCode.IMPDEP2:		case ByteCode.IMUL:		case ByteCode.INEG:		case ByteCode.IOR:		case ByteCode.IREM:		case ByteCode.IRETURN:		case ByteCode.ISHL:		case ByteCode.ISHR:		case ByteCode.ISTORE_0:		case ByteCode.ISTORE_1:		case ByteCode.ISTORE_2:		case ByteCode.ISTORE_3:		case ByteCode.ISUB:		case ByteCode.IUSHR:		case ByteCode.IXOR:		case ByteCode.L2D:		case ByteCode.L2F:		case ByteCode.L2I:		case ByteCode.LADD:		case ByteCode.LALOAD:		case ByteCode.LAND:		case ByteCode.LASTORE:		case ByteCode.LCMP:		case ByteCode.LCONST_0:		case ByteCode.LCONST_1:		case ByteCode.LDIV:		case ByteCode.LLOAD_0:		case ByteCode.LLOAD_1:		case ByteCode.LLOAD_2:		case ByteCode.LLOAD_3:		case ByteCode.LMUL:		case ByteCode.LNEG:		case ByteCode.LOR:		case ByteCode.LREM:		case ByteCode.LRETURN:		case ByteCode.LSHL:		case ByteCode.LSHR:		case ByteCode.LSTORE_0:		case ByteCode.LSTORE_1:		case ByteCode.LSTORE_2:		case ByteCode.LSTORE_3:		case ByteCode.LSUB:		case ByteCode.LUSHR:		case ByteCode.LXOR:		case ByteCode.MONITORENTER:		case ByteCode.MONITOREXIT:		case ByteCode.NOP:		case ByteCode.POP:		case ByteCode.POP2:		case ByteCode.RETURN:		case ByteCode.SALOAD:		case ByteCode.SASTORE:		case ByteCode.SWAP:		case ByteCode.WIDE:			return 0;		case ByteCode.ALOAD:		case ByteCode.ANEWARRAY:		case ByteCode.ASTORE:		case ByteCode.BIPUSH:		case ByteCode.CHECKCAST:		case ByteCode.DLOAD:		case ByteCode.DSTORE:		case ByteCode.FLOAD:		case ByteCode.FSTORE:		case ByteCode.GETFIELD:		case ByteCode.GETSTATIC:		case ByteCode.GOTO:		case ByteCode.GOTO_W:		case ByteCode.IFEQ:		case ByteCode.IFGE:		case ByteCode.IFGT:		case ByteCode.IFLE:		case ByteCode.IFLT:		case ByteCode.IFNE:		case ByteCode.IFNONNULL:		case ByteCode.IFNULL:		case ByteCode.IF_ACMPEQ:		case ByteCode.IF_ACMPNE:		case ByteCode.IF_ICMPEQ:		case ByteCode.IF_ICMPGE:		case ByteCode.IF_ICMPGT:		case ByteCode.IF_ICMPLE:		case ByteCode.IF_ICMPLT:		case ByteCode.IF_ICMPNE:		case ByteCode.ILOAD:		case ByteCode.INSTANCEOF:		case ByteCode.INVOKEINTERFACE:		case ByteCode.INVOKESPECIAL:		case ByteCode.INVOKESTATIC:		case ByteCode.INVOKEVIRTUAL:		case ByteCode.ISTORE:		case ByteCode.JSR:		case ByteCode.JSR_W:		case ByteCode.LDC:		case ByteCode.LDC2_W:		case ByteCode.LDC_W:		case ByteCode.LLOAD:		case ByteCode.LSTORE:		case ByteCode.NEW:		case ByteCode.NEWARRAY:		case ByteCode.PUTFIELD:		case ByteCode.PUTSTATIC:		case ByteCode.RET:		case ByteCode.SIPUSH:			return 1;		case ByteCode.IINC:		case ByteCode.MULTIANEWARRAY:			return 2;		case ByteCode.LOOKUPSWITCH:		case ByteCode.TABLESWITCH:			return -1;		}		throw new IllegalArgumentException("Bad opcode: " + opcode);	}	/**	 * The effect on the operand stack of a given opcode.	 */	static int stackChange(int opcode) {		// For INVOKE... accounts only for popping this (unless static),		// ignoring parameters and return type		switch (opcode) {		case ByteCode.DASTORE:		case ByteCode.LASTORE:			return -4;		case ByteCode.AASTORE:		case ByteCode.BASTORE:		case ByteCode.CASTORE:		case ByteCode.DCMPG:		case ByteCode.DCMPL:		case ByteCode.FASTORE:		case ByteCode.IASTORE:		case ByteCode.LCMP:		case ByteCode.SASTORE:			return -3;		case ByteCode.DADD:		case ByteCode.DDIV:		case ByteCode.DMUL:		case ByteCode.DREM:		case ByteCode.DRETURN:		case ByteCode.DSTORE:		case ByteCode.DSTORE_0:		case ByteCode.DSTORE_1:		case ByteCode.DSTORE_2:		case ByteCode.DSTORE_3:		case ByteCode.DSUB:		case ByteCode.IF_ACMPEQ:		case ByteCode.IF_ACMPNE:		case ByteCode.IF_ICMPEQ:		case ByteCode.IF_ICMPGE:		case ByteCode.IF_ICMPGT:		case ByteCode.IF_ICMPLE:		case ByteCode.IF_ICMPLT:		case ByteCode.IF_ICMPNE:		case ByteCode.LADD:		case ByteCode.LAND:		case ByteCode.LDIV:		case ByteCode.LMUL:		case ByteCode.LOR:		case ByteCode.LREM:		case ByteCode.LRETURN:		case ByteCode.LSTORE:		case ByteCode.LSTORE_0:		case ByteCode.LSTORE_1:		case ByteCode.LSTORE_2:		case ByteCode.LSTORE_3:		case ByteCode.LSUB:		case ByteCode.LXOR:		case ByteCode.POP2:			return -2;		case ByteCode.AALOAD:		case ByteCode.ARETURN:		case ByteCode.ASTORE:		case ByteCode.ASTORE_0:		case ByteCode.ASTORE_1:		case ByteCode.ASTORE_2:		case ByteCode.ASTORE_3:		case ByteCode.ATHROW:		case ByteCode.BALOAD:		case ByteCode.CALOAD:		case ByteCode.D2F:		case ByteCode.D2I:		case ByteCode.FADD:		case ByteCode.FALOAD:		case ByteCode.FCMPG:		case ByteCode.FCMPL:		case ByteCode.FDIV:		case ByteCode.FMUL:		case ByteCode.FREM:		case ByteCode.FRETURN:		case ByteCode.FSTORE:		case ByteCode.FSTORE_0:		case ByteCode.FSTORE_1:		case ByteCode.FSTORE_2:		case ByteCode.FSTORE_3:		case ByteCode.FSUB:		case ByteCode.GETFIELD:		case ByteCode.IADD:		case ByteCode.IALOAD:		case ByteCode.IAND:		case ByteCode.IDIV:		case ByteCode.IFEQ:		case ByteCode.IFGE:		case ByteCode.IFGT:		case ByteCode.IFLE:		case ByteCode.IFLT:		case ByteCode.IFNE:		case ByteCode.IFNONNULL:		case ByteCode.IFNULL:

⌨️ 快捷键说明

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