📄 arrayget.java
字号:
package gnu.kawa.reflect;import gnu.bytecode.*;import gnu.mapping.*;import gnu.expr.*;import java.io.*;import java.lang.reflect.Array;public class ArrayGet extends Procedure2 implements Inlineable, Externalizable{ Type element_type; public ArrayGet (Type element_type) { this.element_type = element_type; } public Object apply2 (Object array, Object index) { Object value = Array.get(array, ((Number) index).intValue()); return element_type.coerceToObject(value); } public void compile (ApplyExp exp, Compilation comp, Target target) { Expression[] args = exp.getArgs(); args[0].compile(comp, ArrayType.make(element_type)); args[1].compile(comp, Type.int_type); CodeAttr code = comp.getCode(); code.emitArrayLoad(element_type); target.compileFromStack(comp, element_type); } public gnu.bytecode.Type getReturnType (Expression[] args) { return element_type; } public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(element_type); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { element_type = (Type) in.readObject(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -