Examples of WeaselInstructionLoadConstInteger


Examples of weasel.interpreter.bytecode.WeaselInstructionLoadConstInteger

  }

  public WeaselInstructionList compile(WeaselCompiler compiler, WeaselKeyWordCompilerHelper compilerHelper, WeaselGenericClass arrayClass) throws WeaselCompilerException {
    arrayClass = new WeaselGenericClass(arrayClass.getBaseClass().getArrayClass(), arrayClass.getGenerics());
    WeaselInstructionList instructions = new WeaselInstructionList();
    instructions.add(token.line, new WeaselInstructionLoadConstInteger(indexes.size()));
    instructions.add(token.line, new WeaselInstructionNewArray(arrayClass.getBaseClass().getByteName(), 1));
    for(int i=0; i<indexes.size(); i++){
      Object o = indexes.get(i);
      if(o instanceof WeaselArrayInit){
        instructions.addAll(((WeaselArrayInit)o).compile(compiler, compilerHelper, arrayClass));
      }else{
        WeaselCompilerReturn wcr = ((WeaselTree)o).compile(compiler, compilerHelper, null, arrayClass, null, false);
        if(!wcr.getReturnType().canCastTo(arrayClass))
          throw new WeaselCompilerException(token.line, "Can't cast %s to %s", wcr.getReturnType(), arrayClass);
        instructions.addAll(wcr.getInstructions());
      }
      instructions.add(token.line, new WeaselInstructionPush(2));
      instructions.add(token.line, new WeaselInstructionLoadConstInteger(i));
      instructions.add(token.line, new WeaselInstructionWriteIndex(WeaselPrimitive.getPrimitiveID(arrayClass.getBaseClass())));
    }
    return instructions;
  }
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionLoadConstInteger

    }else if(constant instanceof Short){
      returnType = new WeaselGenericClass(compiler.baseTypes.shortClass);
      instructionList.add(line, new WeaselInstructionLoadConstShort((Short)constant));
    }else if(constant instanceof Integer){
      returnType = new WeaselGenericClass(compiler.baseTypes.intClass);
      instructionList.add(line, new WeaselInstructionLoadConstInteger((Integer)constant));
    }else if(constant instanceof Long){
      returnType = new WeaselGenericClass(compiler.baseTypes.longClass);
      instructionList.add(line, new WeaselInstructionLoadConstLong((Long)constant));
    }else if(constant instanceof Float){
      returnType = new WeaselGenericClass(compiler.baseTypes.floatClass);
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionLoadConstInteger

        break;
      case WeaselPrimitive.SHORT:
        instructionList.add(line, new WeaselInstructionLoadConstShort(WeaselPrimitive.getShort(constant)));
        break;
      case WeaselPrimitive.INT:
        instructionList.add(line, new WeaselInstructionLoadConstInteger(WeaselPrimitive.getInteger(constant)));
        break;
      case WeaselPrimitive.LONG:
        instructionList.add(line, new WeaselInstructionLoadConstLong(WeaselPrimitive.getLong(constant)));
        break;
      case WeaselPrimitive.FLOAT:
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.