Package weasel.compiler

Examples of weasel.compiler.WeaselInstructionList.addAll()


    instructions.add(token.line, startJump);
    if(t.tokenType==WeaselTokenType.OPENBLOCK){
      t = iterator.next();
      while(t.tokenType!=WeaselTokenType.CLOSEBLOCK){
        iterator.previous();
        instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
        t = iterator.next();
      }
    }else{
      iterator.previous();
      instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
View Full Code Here


        instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
        t = iterator.next();
      }
    }else{
      iterator.previous();
      instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
    }
    t = iterator.next();
    if(t.tokenType!=WeaselTokenType.KEYWORD || t.param!=WeaselKeyWord.WHILE){
      throw new WeaselCompilerException(t.line, "expect while but got %s", t);
    }
View Full Code Here

    if(tree1==null){
      throw new WeaselCompilerException(t.line, "Expect boolean value in while");
    }
    WeaselCompilerReturn wcr;
    wcr = tree1.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
    instructions.addAll(wcr.getInstructions());
    WeaselTree.autoCast(compiler, wcr.getReturnType(), new WeaselGenericClass(compiler.baseTypes.booleanClass), t.line, instructions, true);
    WeaselInstruction ifJump = new WeaselInstructionJump(startJump);
    instructions.add(t.line, new WeaselInstructionIf(ifJump));
    instructions.add(t.line, ifJump);
    WeaselBlockInfo wbi = compilerHelpher.closeBlock();
View Full Code Here

    WeaselCompilerReturn wcr = tree.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
    WeaselInstructionList instructions = wcr.getInstructions();
    WeaselTree.autoCast(compiler, wcr.getReturnType(), new WeaselGenericClass(compiler.baseTypes.booleanClass), token.line, instructions, true);
    WeaselInstructionJump j1;
    instructions.add(token.line, j1 = new WeaselInstructionIf());
    instructions.addAll(compileBlock(compiler, compilerHelpher, iterator));
    WeaselToken t = iterator.next();
    if(t.tokenType==WeaselTokenType.KEYWORD && t.param == WeaselKeyWord.ELSE){
      WeaselInstructionJump j2;
      instructions.add(t.line, j2 = new WeaselInstructionJump());
      j1.setTarget(j2);
View Full Code Here

    WeaselToken t = iterator.next();
    if(t.tokenType==WeaselTokenType.KEYWORD && t.param == WeaselKeyWord.ELSE){
      WeaselInstructionJump j2;
      instructions.add(t.line, j2 = new WeaselInstructionJump());
      j1.setTarget(j2);
      instructions.addAll(compileBlock(compiler, compilerHelpher, iterator));
      j2.setTarget(instructions.getLast());
    }else{
      iterator.previous();
      j1.setTarget(instructions.getLast());
    }
View Full Code Here

    if(token.tokenType==WeaselTokenType.OPENBLOCK){
      instructions = new WeaselInstructionList();
      token = iterator.next();
      while(token.tokenType!=WeaselTokenType.CLOSEBLOCK){
        iterator.previous();
        instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
        token = iterator.next();
      }
    }else{
      iterator.previous();
      instructions =  WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator);
View Full Code Here

      instructions.addAll(wcr.getInstructions());
      wgc = wcr.getReturnType();
      wcr = level.get(i+1).compile(compiler, compilerHelper, null, expect, null, false);
      ret = wcr.getReturnType();
      wgc = WeaselTree.autoCast(compiler, wgc, ret, operator.line, instructions, false);
      instructions.addAll(wcr.getInstructions());
      ret = WeaselTree.autoCast(compiler, ret, wgc, operator.line, instructions, true);
      ret = WeaselGenericClass.getSmallestSame(wgc, ret);
      int primitiveID = WeaselPrimitive.getPrimitiveID(ret.getBaseClass());
      if(oper==WeaselOperator.LOGICAL_OR||oper==WeaselOperator.LOGICAL_AND){
        if(primitiveID!=WeaselPrimitive.BOOLEAN){
View Full Code Here

      }else if(oper==WeaselOperator.REMAINDER){
        instructions.add(operator.line, new WeaselInstructionMod(primitiveID));
      }
    }else if(oper==WeaselOperator.RSHIFT || oper==WeaselOperator.LSHIFT){
      wcr = compileInfixOperator(compiler, compilerHelper, null, expect, null, false, i-1);
      instructions.addAll(wcr.getInstructions());
      ret = wcr.getReturnType();
      wcr = level.get(i+1).compile(compiler, compilerHelper, null, expect, null, false);
      wgc = wcr.getReturnType();
      instructions.addAll(wcr.getInstructions());
      WeaselTree.autoCast(compiler, wgc, new WeaselGenericClass(compiler.baseTypes.intClass), operator.line, instructions, true);
View Full Code Here

      wcr = compileInfixOperator(compiler, compilerHelper, null, expect, null, false, i-1);
      instructions.addAll(wcr.getInstructions());
      ret = wcr.getReturnType();
      wcr = level.get(i+1).compile(compiler, compilerHelper, null, expect, null, false);
      wgc = wcr.getReturnType();
      instructions.addAll(wcr.getInstructions());
      WeaselTree.autoCast(compiler, wgc, new WeaselGenericClass(compiler.baseTypes.intClass), operator.line, instructions, true);
      int primitiveID = WeaselPrimitive.getPrimitiveID(ret.getBaseClass());
      if(oper==WeaselOperator.RSHIFT||oper==WeaselOperator.LSHIFT){
        if(primitiveID!=WeaselPrimitive.CHAR && primitiveID!=WeaselPrimitive.BYTE && primitiveID!=WeaselPrimitive.SHORT
            && primitiveID!=WeaselPrimitive.INT && primitiveID!=WeaselPrimitive.LONG){
View Full Code Here

        instructions.add(operator.line, new WeaselInstructionLShift(primitiveID));
      }
    }else if(oper==WeaselOperator.VERY_SAME || oper==WeaselOperator.NOT_VERY_SAME
           || oper==WeaselOperator.EQUAL || oper==WeaselOperator.NOT_EQUAL){
      wcr = compileInfixOperator(compiler, compilerHelper, null, expect, null, false, i-1);
      instructions.addAll(wcr.getInstructions());
      wgc = wcr.getReturnType();
      wcr = level.get(i+1).compile(compiler, compilerHelper, null, expect, null, false);
      ret = wcr.getReturnType();
      if(wgc.getBaseClass().isPrimitive()||ret.getBaseClass().isPrimitive())
        wgc = WeaselTree.autoCast(compiler, wgc, ret, operator.line, instructions, false);
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.