gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
MicroJavaInput, constructor, other improvements
[mjc2wsl.git] / src / com / quemaster / transformations / mjc2wsl / MicroJavaInput.java
index 2f8dcce..3dd6157 100644 (file)
@@ -1,7 +1,7 @@
 package com.quemaster.transformations.mjc2wsl;
 
 /*
 package com.quemaster.transformations.mjc2wsl;
 
 /*
- Copyright (C) 2014  Doni Pracner
+ Copyright (C) 2014,2015,2018  Doni Pracner
 
  This file is part of mjc2wsl.
 
 
  This file is part of mjc2wsl.
 
@@ -26,7 +26,7 @@ import java.util.HashMap;
 
 public class MicroJavaInput {
        private HashMap<Integer, String> opMap;
 
 public class MicroJavaInput {
        private HashMap<Integer, String> opMap;
-       public String opCodeFile = "/mj-bytecodes.properties";
+       public String opCodeFile = "mj-bytecodes.properties";
        private InputStream mainIn;
        int counter = -1;
 
        private InputStream mainIn;
        int counter = -1;
 
@@ -35,8 +35,9 @@ public class MicroJavaInput {
        int numberOfWords;
        private int codesize;
 
        int numberOfWords;
        private int codesize;
 
-       public MicroJavaInput() {
-
+       public MicroJavaInput(InputStream input) throws Exception {
+               mainIn = input;
+               processHeader();
        }
 
        public int get() {
        }
 
        public int get() {
@@ -60,19 +61,16 @@ public class MicroJavaInput {
                return (get2() << 16) + (get2() << 16 >>> 16);
        }
 
                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();
                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;
 
        public int getCounter() {
                return counter;
@@ -82,22 +80,14 @@ public class MicroJavaInput {
                return codesize;
        }
 
                return codesize;
        }
 
-       public int getMainAdr(mjc2wsl mjc2wsl) {
+       public int getMainAdr() {
                return mainAdr;
        }
 
                return mainAdr;
        }
 
-       public int getNumberOfWords(mjc2wsl mjc2wsl) {
+       public int getNumberOfWords() {
                return numberOfWords;
        }
 
                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:
        String getRelationFor(int opcode) throws Exception {
                switch (opcode) {
                case mjc2wsl.jeq:
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner