Examples of ConstantPool


Examples of anvil.codec.ConstantPool


  public void compile(ByteCompiler context, Node child)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    if (_local.isEscaped()) {
      code.aload(_local.getFrameIndex());
      code.iconst(_local.getSlot());
      child.compile(context, GET);
      code.invokevirtual(code.getPool().addMethodRef("anvil/script/StackFrame",
View Full Code Here

Examples of anvil.codec.ConstantPool

 

  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    if (_local.isEscaped()) {
      switch(operation) {
      case GET:
      case CHECK:
        code.aload(_local.getFrameIndex());
        code.iconst(_local.getSlot());
        code.invokevirtual(code.getPool().addMethodRef("anvil/script/StackFrame", "getLocal", "(I)Lanvil/core/Any;"));
        break;

      case GET_REF:
        int refclass = pool.addClass("anvil/core/AnyLocalRef");
        code.anew(refclass);
        code.dup();
        code.aload(_local.getFrameIndex());
        code.iconst(_local.getSlot());
        code.invokespecial(pool.addMethodRef(refclass, "<init>", "(Lanvil/script/StackFrame;I)V"));
        break;

      case GET_BOOLEAN:
        code.aload(_local.getFrameIndex());
        code.iconst(_local.getSlot());
View Full Code Here

Examples of anvil.codec.ConstantPool

  };
 
  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    boolean inClass = (_function.getType() != Type.FUNCTION);
   
    code.aload_first();
    if (inClass) {
      code.self();
    }
   
    int parent = _function.getParent().getTypeRef(pool);
    String name = (inClass ? "m_" : "f_")+_function.getName();
    int field = pool.addFieldRef(parent, name, "Lanvil/script/Function;");
    code.getstatic(field);
   
    int depth = Grammar.countEscapeDepth(_context, _function);
    code.aload(_context.getFrameIndex());
    if (depth >= 0) {
      code.iconst(depth+1);
      code.invokevirtual(pool.addMethodRef("anvil/script/StackFrame", "getEscape",
        "(I)Lanvil/script/StackFrame;"));
    }
   
    int n = childs();
    if (!hasSplices() && n<=4) {
      for(int i=0; i<n; i++) {
        getChild(i).compile(context, GET);
      }
      code.invokevirtual(pool.addMethodRef(context.TYPE_CONTEXT, "exec",
          inClass ? SIGNATURES_SELF[n] : SIGNATURES_NO_SELF[n]));
         
    } else {
      context.compileArgumentList(getChilds(0));
      code.invokevirtual(pool.addMethodRef(context.TYPE_CONTEXT, "exec",
        inClass ? "(Lanvil/core/Any;Lanvil/script/Function;Lanvil/script/StackFrame;[Lanvil/core/Any;)Lanvil/core/Any;" :
                  "(Lanvil/script/Function;Lanvil/script/StackFrame;[Lanvil/core/Any;)Lanvil/core/Any;"));
       
    }   
View Full Code Here

Examples of anvil.codec.ConstantPool


  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    code.aload_first();
    _left.compile(context, GET);
    _right.compile(context, GET);
    code.invokevirtual(pool.addMethodRef(context.TYPE_CONTEXT,
      "pipe", "(Lanvil/core/Any;Lanvil/core/Any;)Lanvil/core/Any;"));
    if (operation == GET_BOOLEAN) {
      context.any2boolean();
    }
  }
View Full Code Here

Examples of anvil.codec.ConstantPool

  public void compile(ByteCompiler context)
  {
    ClassRoom clazz = context.getClassRoom().createClass(getDescriptor(), "i_"+_name);
    clazz.setAccessFlags(context.ACC_PUBLIC);
    ConstantPool pool = clazz.getPool();
    context.pushClass(clazz);
    Field typefield1 = clazz.createField("_class", "Lanvil/script/compiler/CompiledInterfaceType;", Code.ACC_PUBLIC|Code.ACC_STATIC);
    Field typefield2 = clazz.createField("_type", "Lanvil/core/Any;", Code.ACC_PUBLIC|Code.ACC_STATIC);
    clazz.setSuperClassname(context.TYPE_OBJECT);
    clazz.setAccessFlags(Code.ACC_SUPER|Code.ACC_PUBLIC);

    compileMembers(context, _types.size(), _types.elements());

    Field bases = clazz.createField("_bases", "[Ljava/lang/String;", Code.ACC_PUBLIC|Code.ACC_STATIC);
    Code code = clazz.getStatic().getCode();
    context.pushCode(code);

    //code.println("INTERFACE-START:"+getDescriptor());
    code.getstatic(pool.addFieldRef(_parent.getDescriptor(),
      "_members", "[Ljava/lang/Object;"));
    code.pop();

    int n = _bases.length;
    code.iconst(n);
View Full Code Here

Examples of anvil.codec.ConstantPool


  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    final Node child = _child;
    switch(child.typeOf()) {
    case Node.EXPR_VARIABLE:
      {
        child.compile(context, new Node() {
          public void compile(ByteCompiler context, int operation)
          {
            Code code = context.getCode();
            child.compile(context, GET);
            code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "increase", "()Lanvil/core/Any;"));
          }     
        });
      }
      break;
     
    case Node.EXPR_ATTRIBUTE:
      {
        AttributeNode attr = (AttributeNode)child;
        attr.getChild().compile(context, GET);
        code.astring(attr.getAttribute());
        code.aload_first();
        code.invokestatic(pool.addMethodRef(context.TYPE_CONTEXT, "preinc",
          "(Lanvil/core/Any;Ljava/lang/String;Lanvil/script/Context;)Lanvil/core/Any;"));
      }
      break;
   
    case Node.EXPR_REFERENCE:
      {
        ReferenceNode ref = (ReferenceNode)child;
        ref.getLeft().compile(context, GET);
        ref.getRight().compile(context, GET);
        code.aload_first();
        code.invokestatic(pool.addMethodRef(context.TYPE_CONTEXT, "preinc",
          "(Lanvil/core/Any;Lanvil/core/Any;Lanvil/script/Context;)Lanvil/core/Any;"));
      }
      break;

    default:
View Full Code Here

Examples of anvil.codec.ConstantPool


  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    final Node child = _child;
    switch(child.typeOf()) {
    case Node.EXPR_VARIABLE:
      {
        child.compile(context, new Node() {
          public void compile(ByteCompiler context, int operation)
          {
            Code code = context.getCode();
            child.compile(context, GET);
            code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY, "decrease", "()Lanvil/core/Any;"));
          }     
        });
      }
      break;
     
    case Node.EXPR_ATTRIBUTE:
      {
        AttributeNode attr = (AttributeNode)child;
        attr.getChild().compile(context, GET);
        code.astring(attr.getAttribute());
        code.aload_first();
        code.invokestatic(pool.addMethodRef(context.TYPE_CONTEXT, "predec",
          "(Lanvil/core/Any;Ljava/lang/String;Lanvil/script/Context;)Lanvil/core/Any;"));
      }
      break;
   
    case Node.EXPR_REFERENCE:
      {
        ReferenceNode ref = (ReferenceNode)child;
        ref.getLeft().compile(context, GET);
        ref.getRight().compile(context, GET);
        code.aload_first();
        code.invokestatic(pool.addMethodRef(context.TYPE_CONTEXT, "predec",
          "(Lanvil/core/Any;Lanvil/core/Any;Lanvil/script/Context;)Lanvil/core/Any;"));
      }
      break;

    default:
View Full Code Here

Examples of anvil.codec.ConstantPool

    Code code = context.getCode();
    _var.compile(context, new Node() {
      public void compile(ByteCompiler context, int operation)
      {
        Code code_ = context.getCode();
        ConstantPool pool = code_.getPool();
        int clazz = getClassReference(pool);
        code_.anew(clazz);
        code_.dup();
        code_.invokespecial(pool.addMethodRef(clazz, "<init>", "()V"));
      }     
    });
    code.pop();
    _stmt.compile(context);
    _var.compile(context, GET);
View Full Code Here

Examples of anvil.codec.ConstantPool


  protected static void compileMembers(ByteCompiler context, int size, Enumeration types)
  {
    ClassRoom clazz = context.getClassRoom();
    ConstantPool pool = clazz.getPool();
    Field members = clazz.createField("_members", "[Ljava/lang/Object;", Code.ACC_PUBLIC|Code.ACC_STATIC);
    Code code = clazz.getStatic().getCode();
    context.pushCode(code);
    int intclazz = pool.addClass("java/lang/Integer");
    int intclazzctor = pool.addMethodRef(intclazz, "<init>", "(I)V");
    code.iconst(size * 4);
    code.anewarray("java/lang/Object");
    for(int i=0; types.hasMoreElements();) {
      Type type = (Type)types.nextElement();
      switch(type.getType()) {
View Full Code Here

Examples of anvil.codec.ConstantPool

    String name = (in_class ? "m_" : "f_")+_function.getName();
    String signature = in_class ?
      "(Lanvil/core/Any;Lanvil/script/Function;Lanvil/script/StackFrame;)V" :
      "(Lanvil/script/Function;Lanvil/script/StackFrame;)V";
    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    int anyfunction = pool.addClass("anvil/core/runtime/AnyFunction");
    code.anew(anyfunction);
    code.dup();
    int parent = _function.getParent().getTypeRef(pool);
    int field = pool.addFieldRef(parent, name, "Lanvil/script/Function;");
    if (in_class) {
      code.self();
    }
    code.getstatic(field);
    code.aload(_context.getFrameIndex());
    int depth = Grammar.countEscapeDepth(_context, _function);
    if (depth >= 0) {
      code.iconst(depth+1);
      code.invokevirtual(pool.addMethodRef("anvil/script/StackFrame", "getEscape",
        "(I)Lanvil/script/StackFrame;"));
    }
    code.invokespecial(pool.addMethodRef(anyfunction, "<init>", signature));
    if (operation == GET_BOOLEAN) {
      context.any2boolean();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.