Examples of WeaselInstructionJump


Examples of weasel.interpreter.bytecode.WeaselInstructionJump

      throw new WeaselCompilerException(token.line, "Can't write any value to Condition");
    }
    WeaselInstructionList instructions;
    WeaselCompilerReturn wcr = condition.compile(compiler, compilerHelper, null, new WeaselGenericClass(compiler.baseTypes.booleanClass), null, false);
    instructions = wcr.getInstructions(compiler, compiler.baseTypes.booleanClass);
    WeaselInstructionJump j1;
    WeaselInstructionJump j2;
    instructions.add(token.line, j1 = new WeaselInstructionIf());
    wcr = tree1.compile(compiler, compilerHelper, null, expect, elementParent, isVariable);
    WeaselGenericClass wc = wcr.getReturnType();
    instructions.addAll(wcr.getInstructions());
    wcr = tree2.compile(compiler, compilerHelper, null, expect, elementParent, isVariable);
    if(wc.getBaseClass()==compiler.baseTypes.voidClass || wcr.getReturnType().getBaseClass()==compiler.baseTypes.voidClass){
      throw new WeaselCompilerException(token.line, "Can't return void");
    }
    WeaselGenericClass wc2 = wcr.getReturnType();
    wc = WeaselTree.autoCast(compiler, wc, wc2, token.line, instructions, false);
    instructions.add(token.line, j2 = new WeaselInstructionJump());
    j1.setTarget(j2);
    instructions.addAll(wcr.getInstructions());
    wc2 = WeaselTree.autoCast(compiler, wc2, wc, token.line, instructions, true);
    j2.setTarget(instructions.getLast());
    return new WeaselCompilerReturnInstructionList(instructions, WeaselGenericClass.getSmallestSame(wc, wc2));
  }
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

      wcr = tree3.compile(compiler, compilerHelpher, null, new WeaselGenericClass(compiler.baseTypes.voidClass), null, false);
      instructions = wcr.getInstructions();
      if(wcr.getReturnType().getBaseClass()!=compiler.baseTypes.voidClass)
        instructions.add(t.line, new WeaselInstructionPop());
    }
    WeaselInstruction ifJump = new WeaselInstructionJump(startJump);
    instructions.add(token.line, ifJump);
    ifI.setTarget(ifJump);
    WeaselBlockInfo wbi = compilerHelpher.closeBlock();
    int pops = wbi.varsToPop();
    if(pops==1){
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

        throw new WeaselCompilerException(t.line, "Negatives and 0 are not permitted");
      t = iterator.next();
    }
    WeaselInstructionList instructionList = new WeaselInstructionList();
    compilerHelpher.addClosingsAndFrees(s, instructionList, true);
    WeaselInstructionJump breakJump;
    instructionList.add(token.line, breakJump = new WeaselInstructionJump());
    compilerHelpher.addBreak(s, breakJump);
    expect(t, WeaselTokenType.SEMICOLON);
    return null;
  }
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

        throw new WeaselCompilerException(t.line, "Negatives and 0 are not permitted");
      t = iterator.next();
    }
    WeaselInstructionList instructionList = new WeaselInstructionList();
    compilerHelpher.addClosingsAndFrees(s, instructionList, false);
    WeaselInstructionJump continueJump;
    instructionList.add(token.line, continueJump = new WeaselInstructionJump());
    compilerHelpher.addContinue(s, continueJump);
    expect(t, WeaselTokenType.SEMICOLON);
    return null;
  }
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

      }
    }else{
      iterator.previous();
      instructions.addAll(WeaselTree.parseAndCompile(compiler, compilerHelpher, iterator));
    }
    WeaselInstruction ifJump = new WeaselInstructionJump(continueJump);
    instructions.add(token.line, ifJump);
    ifI.setTarget(ifJump);
    WeaselBlockInfo wbi = compilerHelpher.closeBlock();
    int pops = wbi.varsToPop();
    if(pops==1){
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

    }
    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();
    int pops = wbi.varsToPop();
    if(pops==1){
View Full Code Here

Examples of weasel.interpreter.bytecode.WeaselInstructionJump

    if(tree==null)
      throw new WeaselCompilerException(token.line, "Condition need to be a boolean value");
    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);
      instructions.addAll(compileBlock(compiler, compilerHelpher, iterator));
      j2.setTarget(instructions.getLast());
    }else{
      iterator.previous();
      j1.setTarget(instructions.getLast());
    }
    return new WeaselCompilerReturnInstructionList(instructions, new WeaselGenericClass(compiler.baseTypes.voidClass));
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.