Package anvil.codec

Examples of anvil.codec.Source


    ConstantPool pool = getPool();
    int javafield = pool.addFieldRef(TYPE_MODULE, "java$"+slot,
      "Lanvil/core/reflect/Reflection;");
    int contextclass = pool.addClass(TYPE_CONTEXT);
    code.getstatic(javafield);
    Source isnull = code.if_null();
    code.getstatic(javafield);
    Source notnull = code.go_to();
    isnull.bind();
    code.aload_first();
    code.astring(classname);
    code.invokevirtual(pool.addMethodRef(contextclass, "reflect", "(Ljava/lang/String;)Lanvil/core/reflect/Reflection;"));
    code.dup();
    code.putstatic(javafield);
    notnull.bind();
    code.popop();
    return this;
  }
View Full Code Here


      realparams++;
    }

    if (!isstatic) {
      code.aload(l_self);
      Source nonnull = code.if_nonnull();
      code.aload(l_context);
      code.astring(function.toString());
      code.invokevirtual(pool.addMethodRef("anvil/script/Context", "NoInstance",
        "(Ljava/lang/String;)Lanvil/script/ScriptException;"));
      code.athrow();
      nonnull.bind();
    }

    code.aload(l_parameters);
    code.arraylength();
    Switch select = code.select();
View Full Code Here

      return;
    }

    if (!isstatic) {
      code.aload(l_self);
      Source nonnull = code.if_nonnull();
      code.aload(l_context);
      code.astring(function.toString());
      code.invokevirtual(pool.addMethodRef("anvil/script/Context", "NoInstance",
        "(Ljava/lang/String;)Lanvil/script/ScriptException;"));
      code.athrow();
      nonnull.bind();
    }
   
    /*int l_index = 0;
    ExceptionHandler handler = null;
    if (function instanceof NativeJava) {
View Full Code Here

    super.compile(context, GET);
    Code code = context.getCode();
    code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY,
      "compareTo", "(Lanvil/core/Any;)I"));
    if (operation == GET_BOOLEAN) {
      Source isfalse = code.if_eq();
      code.iconst(true);
      Source toend = code.go_to();
      isfalse.bind();
      code.iconst(false);
      toend.bind();
    } else {
      code.invokestatic(code.getPool().addMethodRef(context.TYPE_ANY,
        "create", "(I)Lanvil/core/Any;"));
    }
  }
View Full Code Here

  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    _left.compile(context, GET_BOOLEAN);
    code.dup();
    Source source = code.if_eq();
    code.pop();
    _right.compile(context, GET_BOOLEAN);
    source.bind();
    if (operation != GET_BOOLEAN) {
      context.boolean2any();
    }   
  }
View Full Code Here

      ExceptionHandler handler = code.startExceptionHandler(true);
      _handler = handler;
      Target tostart = code.getTarget();
      if (_start != null) {
        _start.compile(context, Node.GET_BOOLEAN);
        Source istrue = code.if_ne();
        handler.callFinally();
        handler.jumpOut();
        istrue.bind();
      }
      if (_statement != null) {
        _statement.compile(context);
      }
      if (_end != null) {
View Full Code Here

    _left.compile(context, CHECK);
    Code code = context.getCode();
    code.dup();
    code.invokevirtual(code.getPool().addMethodRef(context.TYPE_ANY,
      "toBoolean", "()Z"));
    Source iftrue = code.if_ne();
    code.pop();
    _right.compile(context, GET);
    iftrue.bind();
    if (operation == GET_BOOLEAN) {
      context.any2boolean();
    }
  }
View Full Code Here

    Code code = context.getCode();
    ConstantPool pool = code.getPool();
    DataNode datanode = new DataNode(l_data);
   
    if (_types != null) {
      Source istrue = code.getSource();
      Source isfalse = null;
     
      int n = _types.childs();

      boolean assigned = false;
      for(int i=0; i<n; i++) {
        if (_types.getChild(i).typeOf() != Node.EXPR_TYPE) {
          _assignment.compile(context, datanode);
          code.pop();
          assigned = true;
        }
      }

      for(int i=0; i<n; i++) {
        if (isfalse != null) {
          isfalse.bind();
        }
        Node child = _types.getChild(i);
        if (child.typeOf() == Node.EXPR_TYPE) {
          code.aload(l_data);
          child.compile(context, Node.GET_TYPE);
          code.invokevirtual(pool.addMethodRef(context.TYPE_ANY, "isInstanceOf", "(Lanvil/script/Type;)Z"));
        } else {
          child.compile(context, Node.GET_BOOLEAN);
        }
        isfalse = code.if_eq();
        code.go_to(istrue);
      }
     
      istrue.bind();
     
      if (!assigned) {
        _assignment.compile(context, datanode);
        code.pop();
      }
     
      _statement.compile(context);
      handler.callFinally();
      handler.jumpOut();
     
      isfalse.bind();
     
    } else {
      _assignment.compile(context, datanode);
      code.pop();
      _statement.compile(context);
View Full Code Here

  public void compile(ByteCompiler context, int operation)
  {
    Code code = context.getCode();
    _left.compile(context, GET_BOOLEAN);
    code.dup();
    Source source = code.if_ne();
    code.pop();
    _right.compile(context, GET_BOOLEAN);
    source.bind();
    if (operation != GET_BOOLEAN) {
      context.boolean2any();
    }   
  }
View Full Code Here

    case Expression.IS_DYNAMIC:
      if (_condition.needLineNumbers()) {
        context.location(_condition.getLocation());
      }
      _condition.compile(context, Expression.GET_BOOLEAN);
      Source to_then = code.if_eq();
      _thenStatements.compile(context);
      if (_elseStatements != null) {
        Source to_end = code.go_to();
        to_then.bind();
        _elseStatements.compile(context);
        to_end.bind();
      } else {
        to_then.bind();
      }
      break;
    }
View Full Code Here

TOP

Related Classes of anvil.codec.Source

Copyright © 2018 www.massapicom. 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.