gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (from parent 1: 882d424)
raw | patch | inline | side by side (from parent 1: 882d424)
author | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 17 Jul 2018 22:24:13 +0000 (00:24 +0200) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Tue, 17 Jul 2018 22:24:13 +0000 (00:24 +0200) |
change so the constructor gets the stream and inits what is
needed. also removed some parameters and methods that were not needed.
needed. also removed some parameters and methods that were not needed.
src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java | patch | blob | history | |
src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java | patch | blob | history |
diff --git a/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java b/src/com/quemaster/transformations/mjc2wsl/MicroJavaInput.java
int numberOfWords;
private int codesize;
- public MicroJavaInput() {
-
+ public MicroJavaInput(InputStream input) throws Exception {
+ mainIn = input;
+ processHeader();
}
public int get() {
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;
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:
diff --git a/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java b/src/com/quemaster/transformations/mjc2wsl/mjc2wsl.java
package com.quemaster.transformations.mjc2wsl;
/*
- Copyright (C) 2014,2015, 2016 Doni Pracner
+ Copyright (C) 2014,2015, 2016, 2018 Doni Pracner
This file is part of mjc2wsl.
return versionN;
}
- MicroJavaInput mjInput = new MicroJavaInput();
+ private MicroJavaInput mjInput;
private PrintWriter out = null;
}
public void convertStream(InputStream ins) throws Exception{
- mjInput.setStream(ins);
- //process start
- mjInput.processHeader(this);
-
- prl(createStandardStart(mjInput.getNumberOfWords(this)));
- prl("SKIP;\n ACTIONS a" + (14 + mjInput.getMainAdr(this)) + " :");
+ mjInput = new MicroJavaInput(ins);
+
+ prl(createStandardStart(mjInput.getNumberOfWords()));
+ prl("SKIP;\n ACTIONS a" + (14 + mjInput.getMainAdr()) + " :");
// the number of Locals for procedures; need to remember it for exits
int numberOfLocals = 0;