arraylength.java

来自「A framework written in Java for implemen」· Java 代码 · 共 47 行

JAVA
47
字号
package gnu.kawa.reflect;import gnu.bytecode.*;import gnu.mapping.*;import gnu.expr.*;import java.io.*;public class ArrayLength   extends Procedure1  implements Inlineable, Externalizable{  Type element_type;  public ArrayLength (Type element_type)  {    this.element_type = element_type;  }  public Object apply1 (Object array)  {    return gnu.math.IntNum.make(java.lang.reflect.Array.getLength(array));  }  public void compile (ApplyExp exp, Compilation comp, Target target)  {    exp.getArgs()[0].compile(comp, ArrayType.make(element_type));    CodeAttr code = comp.getCode();    code.emitArrayLength();    target.compileFromStack(comp, gnu.kawa.lispexpr.LangPrimType.intType);  }  public gnu.bytecode.Type getReturnType (Expression[] args)  {    return gnu.kawa.lispexpr.LangPrimType.intType;  }  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 + =
减小字号Ctrl + -
显示快捷键?