X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=mjc2wsl.git;a=blobdiff_plain;f=src%2Fcom%2Fquemaster%2Ftransformations%2Fmjc2wsl%2FMicroJavaInput.java;h=499659a3c313cae3d16ed5e6453de60d9ff90413;hp=2f8dccee43af3769f18dd91c856415405a01004f;hb=2fa0619f7c0629bb2432877bb9dcef2b27d8cb00;hpb=1d45aa77cbdcb3fc3877854cf8ca5cba81b6288f diff --git a/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java b/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java index 2f8dcce..499659a 100644 --- a/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java +++ b/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java @@ -1,7 +1,7 @@ package com.quemaster.transformations.mjc2wsl; /* - Copyright (C) 2014 Doni Pracner + Copyright (C) 2014,2015,2018 Doni Pracner This file is part of mjc2wsl. @@ -26,7 +26,7 @@ import java.util.HashMap; public class MicroJavaInput { private HashMap opMap; - public String opCodeFile = "/mj-bytecodes.properties"; + public String opCodeFile = "mj-bytecodes.properties"; private InputStream mainIn; int counter = -1; @@ -35,8 +35,9 @@ public class MicroJavaInput { int numberOfWords; private int codesize; - public MicroJavaInput() { - + public MicroJavaInput(InputStream input) throws Exception { + mainIn = input; + processHeader(); } public int get() { @@ -60,19 +61,16 @@ public class MicroJavaInput { return (get2() << 16) + (get2() << 16 >>> 16); } - public void processHeader(mjc2wsl mjc2wsl) throws Exception { + public void processHeader() throws Exception { byte m = (byte) get(); byte j = (byte) get(); if (m != 'M' || j != 'J') throw new Exception("Wrong start of bytecode file"); codesize = get4(); - setNumberOfWords(get4()); - setMainAdr(get4()); + this.numberOfWords = get4(); + this.mainAdr = get4(); } - public void setStream(InputStream ins) { - mainIn = ins; - } public int getCounter() { return counter; @@ -82,42 +80,34 @@ public class MicroJavaInput { return codesize; } - public int getMainAdr(mjc2wsl mjc2wsl) { + public int getMainAdr() { return mainAdr; } - public int getNumberOfWords(mjc2wsl mjc2wsl) { + public int getNumberOfWords() { return numberOfWords; } - void setNumberOfWords(int numberOfWords) { - this.numberOfWords = numberOfWords; - } - - void setMainAdr(int mainAdr) { - this.mainAdr = mainAdr; - } - String getRelationFor(int opcode) throws Exception { switch (opcode) { - case mjc2wsl.jeq: + case Mjc2wsl.jeq: return "="; - case mjc2wsl.jne: + case Mjc2wsl.jne: return "<>"; - case mjc2wsl.jlt: + case Mjc2wsl.jlt: return "<"; - case mjc2wsl.jle: + case Mjc2wsl.jle: return "<="; - case mjc2wsl.jgt: + case Mjc2wsl.jgt: return ">"; - case mjc2wsl.jge: + case Mjc2wsl.jge: return ">="; } throw new Exception("Wrong opcode for a relation"); } boolean isJumpCode(int opcode) { - return (opcode >= mjc2wsl.jmp) && (opcode <= mjc2wsl.jge); + return (opcode >= Mjc2wsl.jmp) && (opcode <= Mjc2wsl.jge); } private HashMap getOpMap() {