diff --git a/README.md b/README.md index 963c39f..66aba82 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,12 @@ Try *redesigining* this README! *Submit* an [issue](https://github.com/JumperBot/Unsafe-4-Bit/issues/new/choose) or *code* it yourself! +--- + +> Want to help in another way? + +***Star*** the repository! + --- diff --git a/README.ufbb b/README.ufbb deleted file mode 100644 index ada44b7..0000000 --- a/README.ufbb +++ /dev/null @@ -1,44 +0,0 @@ -
- -# UFB - -`/UFB/*.class` | `UFB.jar` is the interpreter | compiler merged as one. - -Only one file ending in `.ufbb` | `ufb` will be interpreted | compiled. - -A file will not be compiled | interpreted if there are errors. - -
- ---- - -## Usage - -```shell -java -jar UFB.jar [ -flags ] [ file ] -``` - ---- - -## Flags - -- "-p" -> Performance measurement flag -> ms -- "-n" -> Accurately use the "-p" flag -> ns -- "-m" -> Time all commands being run -- "-v" -> Display semantic version tag -- "-h" -> Display help links and sources -- "-c" -> Compile file - ---- - -## Example - -```shell -java UFB -pnv -java UFB -p -java UFB -m -java UFB -nvp -java UFB -pnhv -java UFB -mn -java UFB -c ../test/UFB/Main.ufb -``` \ No newline at end of file diff --git a/build/README.md b/build/README.md index ada44b7..4dad4b8 100644 --- a/build/README.md +++ b/build/README.md @@ -27,7 +27,13 @@ java -jar UFB.jar [ -flags ] [ file ] - "-m" -> Time all commands being run - "-v" -> Display semantic version tag - "-h" -> Display help links and sources -- "-c" -> Compile file +- "-c" -> Compile one of the provided files +- "-l" -> Display license notice (GPL v3) + +--- + +(WARNING: NOT RECOMMENDED!): +- "-b" -> Activate backwards compatibility --- diff --git a/build/UFB.jar b/build/UFB.jar index cca64fc..c2f7a3e 100644 Binary files a/build/UFB.jar and b/build/UFB.jar differ diff --git a/build/UFB/Optimizer$1.class b/build/UFB/Optimizer$1.class index 5730876..caca535 100644 Binary files a/build/UFB/Optimizer$1.class and b/build/UFB/Optimizer$1.class differ diff --git a/build/UFB/Optimizer.class b/build/UFB/Optimizer.class index f1b8c1c..a1ee0b4 100644 Binary files a/build/UFB/Optimizer.class and b/build/UFB/Optimizer.class differ diff --git a/build/UFB/Runner.class b/build/UFB/Runner.class index c926de4..b4bd570 100644 Binary files a/build/UFB/Runner.class and b/build/UFB/Runner.class differ diff --git a/build/UFB/UFB.class b/build/UFB/UFB.class index bc252fa..bcaa50e 100644 Binary files a/build/UFB/UFB.class and b/build/UFB/UFB.class differ diff --git a/build/UFB/UFBC$1.class b/build/UFB/UFBC$1.class index 8593d13..2d5b7e4 100644 Binary files a/build/UFB/UFBC$1.class and b/build/UFB/UFBC$1.class differ diff --git a/build/UFB/UFBC.class b/build/UFB/UFBC.class index e84af8e..a0e512b 100644 Binary files a/build/UFB/UFBC.class and b/build/UFB/UFBC.class differ diff --git a/build/build.sh b/build/build.sh index 1023862..634b8c1 100644 --- a/build/build.sh +++ b/build/build.sh @@ -3,4 +3,7 @@ cd UFB javac -verbose ../../src/UFB/*.java -d . echo jar --create --file=../UFB.jar --verbose --main-class=UFB *.class -cd .. \ No newline at end of file +cd .. + +# Copy build/README.md to src/README.md +cp README.md ../src/README.md \ No newline at end of file diff --git a/src/UFB/Optimizer.java b/src/UFB/Optimizer.java new file mode 100644 index 0000000..8a08f1f --- /dev/null +++ b/src/UFB/Optimizer.java @@ -0,0 +1,394 @@ +/** + * + * Unsafe Four Bit is a compiled-interpreted, dynamically-typed programming language. + * Copyright (C) 2022 JumperBot_ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * +**/ + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; + +import java.util.HashMap; + +class Optimizer{ + final char[] mem=new char[256]; + final int[] memInd=new int[256]; + final boolean[] aKnownNonNum=new boolean[256]; + final BufferedInputStream buffer; + final int size; + final int[] lines; + int furthestLine=-1; + final StringBuilder printProxy=new StringBuilder(); + final StringBuilder newCommands=new StringBuilder(); + public Optimizer(final String file)throws Exception{ + mem[0]=' '; + aKnownNonNum[0]=true; + for(int i=0;i<26;i++){ + final int ind=i+1; + aKnownNonNum[ind]=true; + mem[ind]=(char)(ind+64); + } + for(int i=0;i<10;i++)mem[i+27]=String.valueOf(i).charAt(0); + mem[37]='\n'; + for(int i=37;i<256;i++)aKnownNonNum[i]=true; + final File f=new File(file); + buffer=new BufferedInputStream(new FileInputStream(f)); + buffer.mark(Integer.MAX_VALUE); + size=(int)f.length(); + lines=new int[size]; + try{ + run(); + buffer.close(); + final String newFileName=file.substring(0, file.lastIndexOf("."))+".optimized.ufb"; + final File newGenCode=new File(newFileName); + try(final FileWriter writer=new FileWriter(newGenCode)){ + writer.write(newCommands.append("\nnvar 38").toString().trim().replaceAll("\n{2,}", "\n")); + } + UFBC.compile(newFileName, false); + newGenCode.delete(); + new File(file).delete(); + final File newCompiledFile=new File(newFileName+"b"); + newCompiledFile.renameTo(new File(file)); + }catch(final Exception e){ + buffer.close(); + if(!e.toString().contains("Code cannot be optimized"))throw new RuntimeException(e); + else System.out.println("Code cannot be optimized, but compilation is a success!"); + } + } + private void addToCommands(){ + final String converted=convertToMemory( + printProxy.toString() // i == -255, - == -254, . == -253 + ).replace("-255", "\nwvar 38 27\ndiv 38 27\nprint 38\nprint 255") + .replace("-254", "\nwvar 38 27\nsub 38 28\ntrim 38 1\nprint 38\nprint 255") + .replace("-253", "\nwvar 38 28\ndiv 38 29\nprint 39\nprint 255") + .replace("\n ", "\n"); + printProxy.setLength(0); + if(!converted.startsWith("\n"))newCommands.append("print "); + newCommands.append(converted).append("\n"); + } + private void run()throws Exception{ + final long start=System.currentTimeMillis(); + for(;byteInd5000){ + System.out.println("Optimizer: \"Timeout!\""); + throw new Exception("Code cannot be optimized, but compilation is a success!"); + } + if(furthestLine>-1&&lines[furthestLine] memMap=new HashMap<>(){{ + put(' ', 0); + put('A', 1); + put('B', 2); + put('C', 3); + put('D', 4); + put('E', 5); + put('F', 6); + put('G', 7); + put('H', 8); + put('I', 9); + put('J', 10); + put('K', 11); + put('L', 12); + put('M', 13); + put('N', 14); + put('O', 15); + put('P', 16); + put('Q', 17); + put('R', 18); + put('S', 19); + put('T', 20); + put('U', 21); + put('V', 22); + put('W', 23); + put('X', 24); + put('Y', 25); + put('Z', 26); + put('0', 27); + put('1', 28); + put('2', 29); + put('3', 30); + put('4', 31); + put('5', 32); + put('6', 33); + put('7', 34); + put('8', 35); + put('9', 36); + put('\n', 37); + put('\u0000', 38); + //hack-characters + put('i', -255); + put('-', -254); + put('.', -253); + }}; + private String convertToMemory(final String in){ + final StringBuilder output=new StringBuilder(); + for(final char c:in.toCharArray())output.append(memMap.get(c)).append(" "); + return output.toString().trim(); + } + int byteInd=0; + final byte[] byteArr=new byte[1]; + private int next(final int len){ + try{ + if(len==8){ + byteInd++; + for(long skipped=buffer.skip(byteInd-1);skipped255){ + System.arraycopy(temp, 0, mem, curInd, 255-curInd+1); + memInd[ind]=255; + return; + } + System.arraycopy(temp, 0, mem, curInd, temp.length); + curInd+=temp.length; + }else{ + final char[] tempty=rvar(ind); + if(curInd+tempty.length-1>255){ + System.arraycopy(tempty, 0, mem, curInd, 255-curInd+1); + memInd[ind]=255; + return; + } + System.arraycopy(tempty, 0, mem, curInd, tempty.length); + curInd+=tempty.length; + } + } + memInd[memIndex]=curInd-1; + return; + } + nvar(memIndex); + final int memEndPoint=memIndex+chars.length-1; + if(memEndPoint>255){ + System.arraycopy(chars, 0, mem, memIndex, 255-memIndex+1); + memInd[memIndex]=255; + return; + } + System.arraycopy(chars, 0, mem, memIndex, chars.length); + memInd[memIndex]=memEndPoint; + } + + private void nvar(final int ind){ + if(memInd[ind]==0)return; + final char[] temp=new char[memInd[ind]-ind+1]; // To Avoid For-Loops. + System.arraycopy(temp, 0, mem, ind, temp.length); + memInd[ind]=0; + } + + private void trim(){ + final int ind=next(8); + final int max=next(8); + if(max==0){ + nvar(ind); + return; + } + if(max>memInd[ind]-ind)return; + final char[] temp=rvar(ind); + nvar(ind); + System.arraycopy(temp, 0, mem, ind, max); + memInd[ind]=ind+max-1; + } + + private int findPeriod(final char[] arr){ + final int half=arr.length/2; + for(int i=0;i9){ + aKnownNonNum[ind]=true; + return new String(arr).hashCode(); + } + result[0]+=num; + result[0]*=10; + final int i2=decimalInd+1+i; + final int num2=arr[i2]-48; + if(num2<0||num2>9){ + aKnownNonNum[ind]=true; + return new String(arr).hashCode(); + } + result[1]+=num2; + result[1]/=10; + } + return (result[0]/10)+result[1]; + }else{ // BeCoz Long#parseLong() is slow and try-catch is expensive. + double result=0; + for(final char c:arr){ + final int num=c-48; + if(num<0||num>9){ + aKnownNonNum[ind]=true; + return new String(arr).hashCode(); + } + result+=num; + result*=10; + } + return result/10; + } + } + private void math(final int op){ + final int ind1=next(8); + final int ind2=next(8); + final char[] str2=rvar(ind2); + if(str2.length==0)return; // The earlier the call, the better. + final char[] str1=rvar(ind1); + if(str1.length<1&&str2.length>0){ + write(0, ind1, false, str2); + return; + } + try{ + final double num1=toNum(str1, ind1); + final double num2=toNum(str2, ind2); + final double result=(op==0)?num1+num2:(op==1)?num1-num2: + (op==2)?num1*num2:(op==3)?num1/num2: + (op==4)?num1%num2:(int) (num1/num2); + if(result!=result){ // Refer to Double#isNan(double v) + nvar(ind1); + mem[ind1]='i'; + memInd[ind1]=ind1; + return; + } + if(result%1==0) write(0, ind1, false, Long.toString((long)result).toCharArray()); + else write(0, ind1, false, Double.toString(result).toCharArray()); + }catch(final Exception e){ + nvar(ind1); + mem[ind1]='i'; + memInd[ind1]=ind1; + } + } + + final HashMap jumpBackFrequency=new HashMap(); + private boolean jump(final int op){ // Returns true if optimization should stop. + final int ind1=next(8); + final int ind2=next(8); + final char[] arg1=rvar(ind1); + final char[] arg2=rvar(ind2); + final int com=next(16); + if( + (op==0&&toNum(arg1, ind1)>toNum(arg2, ind2))|| + (op==1&&toNum(arg1, ind1)size){ + byteInd=size; + return; + } + for(;furthestLine++1){ + if(curByte<9)byteInd+=2; + else if(curByte>9){ + if(curByte<14)byteInd+=4; + else if(curByte==15)byteInd++; + else byteInd+=next(8)+1; + } + }else if(curByte==1)byteInd++; + else byteInd+=next(8)+1; + } + } + + private void print(){ + final int argCount=next(8); + for(int i=0;i100)addToCommands(); + } + } +} diff --git a/src/UFB/Runner.java b/src/UFB/Runner.java index dcb3484..8dba730 100644 --- a/src/UFB/Runner.java +++ b/src/UFB/Runner.java @@ -108,7 +108,7 @@ private void run()throws Exception{ runCommand(com); final long end=(!nanoseconds)?System.currentTimeMillis():System.nanoTime(); System.out.printf( - "\nCommand Index: %d Took %d%s To Run.\n", + "\n\u001B[93mCommand Index: %d Took %d%s To Run.\u001B[0m\n", com, end-start, (!nanoseconds)?"ms":"ns" ); } @@ -127,7 +127,7 @@ private void run()throws Exception{ for(int i=0;i<32;i++){ for(int ratio=0;ratio<8;ratio++){ final int ind=i+(ratio*32); - if(memInd[ind]!=0)System.out.printf("Memory Leak At Index: %d\n", ind); + if(memInd[ind]!=0)System.out.printf("\u001B[91mMemory Leak At Index: %d\u001B[0m\n", ind); } } } @@ -160,13 +160,13 @@ private void runCommand(final int com)throws Exception{ default: if(backwardsCompat){ System.out.printf( - "\nCommand Index: %d Is Not Recognized By The Interpreter...\n%s\n", + "\n\u001B[93mCommand Index: %d Is Not Recognized By The Interpreter...\n%s\u001B[0m\n", com, "Skipping Instead Since '-b' Flag Is Toggled..." ); break; } System.out.printf( - "\nCommand Index: %d Is Not Recognized By The Interpreter...\n%s\n", + "\n\u001B[91mCommand Index: %d Is Not Recognized By The Interpreter...\n%s\u001B[0m\n", com, "Terminating..." ); throw new Exception("Unsupported Command Lol"); @@ -275,26 +275,25 @@ private double toNum(final char[] arr, final int ind){ if(aKnownNonNum[ind])return new String(arr).hashCode(); final int decimalInd=findPeriod(arr); if(decimalInd!=-1){ - double result=0; + final double[] result=new double[2]; for(int i=0;i9){ aKnownNonNum[ind]=true; return new String(arr).hashCode(); } - result+=num; - result*=10; - } - for(int i=decimalInd+1;i9){ + result[0]+=num; + result[0]*=10; + final int i2=decimalInd+1+i; + final int num2=arr[i2]-48; + if(num2<0||num2>9){ aKnownNonNum[ind]=true; return new String(arr).hashCode(); } - result+=num; - result/=10; + result[1]+=num2; + result[1]/=10; } - return result; + return (result[0]/10)+result[1]; }else{ // BeCoz Long#parseLong() is slow and try-catch is expensive. double result=0; for(final char c:arr){ diff --git a/src/UFB/UFB.java b/src/UFB/UFB.java index 2afcf03..5cf808b 100644 --- a/src/UFB/UFB.java +++ b/src/UFB/UFB.java @@ -27,7 +27,7 @@ class UFB{ * MINOR CHANGES should give new commands/major features. * PATCH CHANGES should give new flags/performance-boosts/bug-fixes/etc. **/ - final static String version_tag="v1.2.1"; + final static String version_tag="v1.3.0"; //----------------------------------------------------------------------// public static void main(final String[]a)throws Exception{ final FlagManager flagManager=new FlagManager(a); diff --git a/src/UFB/UFBC.java b/src/UFB/UFBC.java index 3c5640d..ae63877 100644 --- a/src/UFB/UFBC.java +++ b/src/UFB/UFBC.java @@ -18,13 +18,10 @@ * **/ -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; -import java.io.FileWriter; import java.util.Arrays; import java.util.ArrayList; @@ -143,28 +140,20 @@ public static void compile(final String fileName, final boolean recompile)throws } } final String ANSI_RESET="\u001B[0m"; - final String ANSI_BRIGHT_YELLOW="\u001B[93m"; + if(warnings.length()!=0) + System.out.print( + String.format("%s%s%s%s", + ANSI_RESET, "\u001B[93m", warnings.toString(), ANSI_RESET + ) + ); if(errors.length()!=0){ - final String ANSI_BRIGHT_RED="\u001B[91m"; System.out.print( String.format("%s%s%s%s", - ANSI_RESET, ANSI_BRIGHT_RED, errors.toString(), ANSI_RESET + ANSI_RESET, "\u001B[91m", errors.toString(), ANSI_RESET ) ); - if(warnings.length()!=0) - System.out.print( - String.format("%s%s%s%s", - ANSI_RESET, ANSI_BRIGHT_YELLOW, warnings.toString(), ANSI_RESET - ) - ); return; } - if(warnings.length()!=0&&errors.length()==0) - System.out.print( - String.format("%s%s%s%s", - ANSI_RESET, ANSI_BRIGHT_YELLOW, warnings.toString(), ANSI_RESET - ) - ); final String outName=fileName.substring(0, fileName.lastIndexOf("."))+".ufbb"; try{ final File outFile=new File(outName); @@ -274,367 +263,3 @@ private static int getBin(final String com){ return binaryMap.get(com.trim()); } } - -class Optimizer{ - final char[] mem=new char[256]; - final int[] memInd=new int[256]; - final boolean[] aKnownNonNum=new boolean[256]; - final BufferedInputStream buffer; - final int size; - final int[] lines; - int furthestLine=-1; - final StringBuilder printProxy=new StringBuilder(); - final StringBuilder newCommands=new StringBuilder(); - public Optimizer(final String file)throws Exception{ - mem[0]=' '; - aKnownNonNum[0]=true; - for(int i=0;i<26;i++){ - final int ind=i+1; - aKnownNonNum[ind]=true; - mem[ind]=(char)(ind+64); - } - for(int i=0;i<10;i++)mem[i+27]=String.valueOf(i).charAt(0); - mem[37]='\n'; - for(int i=37;i<256;i++)aKnownNonNum[i]=true; - final File f=new File(file); - buffer=new BufferedInputStream(new FileInputStream(f)); - buffer.mark(Integer.MAX_VALUE); - size=(int)f.length(); - lines=new int[size]; - try{ - run(); - buffer.close(); - final String newFileName=file.substring(0, file.lastIndexOf("."))+".optimized.ufb"; - try(final FileWriter writer=new FileWriter(new File(newFileName))){ - writer.write(newCommands.toString().trim().replaceAll("\n{2,}", "\n")); - } - UFBC.compile(newFileName, false); - }catch(final Exception e){ - buffer.close(); - if(!e.toString().contains("Code cannot be optimized"))throw new RuntimeException(e); - else System.out.println("Code cannot be optimized, but compilation is a success!"); - } - } - private void addToCommands(){ - final String converted=convertToMemory( - printProxy.toString() // i == -255, - == -254, . == -253 - ).replace("-255", "\nwvar 38 27\ndiv 38 27\nprint 38\nprint 255") - .replace("-254", "\nwvar 38 27\nsub 38 28\ntrim 38 1\nprint 38\nprint 255") - .replace("-253", "\nwvar 38 28\ndiv 38 29\nprint 39\nprint 255") - .replace("\n ", "\n")+"\nnvar 38"; - printProxy.setLength(0); - if(!converted.startsWith("\n"))newCommands.append("print "); - newCommands.append(converted).append("\n"); - } - private void run()throws Exception{ - final long start=System.currentTimeMillis(); - for(;byteInd5000){ - System.out.println("Optimizer: \"Timeout!\""); - throw new Exception("Code cannot be optimized, but compilation is a success!"); - } - if(furthestLine>-1&&lines[furthestLine] memMap=new HashMap<>(){{ - put(' ', 0); - put('A', 1); - put('B', 2); - put('C', 3); - put('D', 4); - put('E', 5); - put('F', 6); - put('G', 7); - put('H', 8); - put('I', 9); - put('J', 10); - put('K', 11); - put('L', 12); - put('M', 13); - put('N', 14); - put('O', 15); - put('P', 16); - put('Q', 17); - put('R', 18); - put('S', 19); - put('T', 20); - put('U', 21); - put('V', 22); - put('W', 23); - put('X', 24); - put('Y', 25); - put('Z', 26); - put('0', 27); - put('1', 28); - put('2', 29); - put('3', 30); - put('4', 31); - put('5', 32); - put('6', 33); - put('7', 34); - put('8', 35); - put('9', 36); - put('\n', 37); - put('\u0000', 38); - //hack-characters - put('i', -255); - put('-', -254); - put('.', -253); - }}; - private String convertToMemory(final String in){ - final StringBuilder output=new StringBuilder(); - for(final char c:in.toCharArray())output.append(memMap.get(c)).append(" "); - return output.toString().trim(); - } - int byteInd=0; - final byte[] byteArr=new byte[1]; - private int next(final int len){ - try{ - if(len==8){ - byteInd++; - for(long skipped=buffer.skip(byteInd-1);skipped255){ - System.arraycopy(temp, 0, mem, curInd, 255-curInd+1); - memInd[ind]=255; - return; - } - System.arraycopy(temp, 0, mem, curInd, temp.length); - curInd+=temp.length; - }else{ - final char[] tempty=rvar(ind); - if(curInd+tempty.length-1>255){ - System.arraycopy(tempty, 0, mem, curInd, 255-curInd+1); - memInd[ind]=255; - return; - } - System.arraycopy(tempty, 0, mem, curInd, tempty.length); - curInd+=tempty.length; - } - } - memInd[memIndex]=curInd-1; - return; - } - nvar(memIndex); - final int memEndPoint=memIndex+chars.length-1; - if(memEndPoint>255){ - System.arraycopy(chars, 0, mem, memIndex, 255-memIndex+1); - memInd[memIndex]=255; - return; - } - System.arraycopy(chars, 0, mem, memIndex, chars.length); - memInd[memIndex]=memEndPoint; - } - - private void nvar(final int ind){ - if(memInd[ind]==0)return; - final char[] temp=new char[memInd[ind]-ind+1]; // To Avoid For-Loops. - System.arraycopy(temp, 0, mem, ind, temp.length); - memInd[ind]=0; - } - - private void trim(){ - final int ind=next(8); - final int max=next(8); - if(max==0){ - nvar(ind); - return; - } - if(max>memInd[ind]-ind)return; - final char[] temp=rvar(ind); - nvar(ind); - System.arraycopy(temp, 0, mem, ind, max); - memInd[ind]=ind+max-1; - } - - private int findPeriod(final char[] arr){ - final int half=arr.length/2; - for(int i=0;i9){ - aKnownNonNum[ind]=true; - return new String(arr).hashCode(); - } - result+=num; - result*=10; - } - for(int i=decimalInd+1;i9){ - aKnownNonNum[ind]=true; - return new String(arr).hashCode(); - } - result+=num; - result/=10; - } - return result; - }else{ // BeCoz Long#parseLong() is slow and try-catch is expensive. - double result=0; - for(final char c:arr){ - final int num=c-48; - if(num<0||num>9){ - aKnownNonNum[ind]=true; - return new String(arr).hashCode(); - } - result+=num; - result*=10; - } - return result/10; - } - } - private void math(final int op){ - final int ind1=next(8); - final int ind2=next(8); - final char[] str2=rvar(ind2); - if(str2.length==0)return; // The earlier the call, the better. - final char[] str1=rvar(ind1); - if(str1.length<1&&str2.length>0){ - write(0, ind1, false, str2); - return; - } - try{ - final double num1=toNum(str1, ind1); - final double num2=toNum(str2, ind2); - final double result=(op==0)?num1+num2:(op==1)?num1-num2: - (op==2)?num1*num2:(op==3)?num1/num2: - (op==4)?num1%num2:(int) (num1/num2); - if(result!=result){ // Refer to Double#isNan(double v) - nvar(ind1); - mem[ind1]='i'; - memInd[ind1]=ind1; - return; - } - if(result%1==0) write(0, ind1, false, Long.toString((long)result).toCharArray()); - else write(0, ind1, false, Double.toString(result).toCharArray()); - }catch(final Exception e){ - nvar(ind1); - mem[ind1]='i'; - memInd[ind1]=ind1; - } - } - - final HashMap jumpBackFrequency=new HashMap(); - private boolean jump(final int op){ // Returns true if optimization should stop. - final int ind1=next(8); - final int ind2=next(8); - final char[] arg1=rvar(ind1); - final char[] arg2=rvar(ind2); - final int com=next(16); - if( - (op==0&&toNum(arg1, ind1)>toNum(arg2, ind2))|| - (op==1&&toNum(arg1, ind1)size){ - byteInd=size; - return; - } - for(;furthestLine++1){ - if(curByte<9)byteInd+=2; - else if(curByte>9){ - if(curByte<14)byteInd+=4; - else if(curByte==15)byteInd++; - else byteInd+=next(8)+1; - } - }else if(curByte==1)byteInd++; - else byteInd+=next(8)+1; - } - } - - private void print(){ - final int argCount=next(8); - for(int i=0;i100)addToCommands(); - } - } -} diff --git a/test/Java/Main.class b/test/Java/Main.class deleted file mode 100644 index 122a7fa..0000000 Binary files a/test/Java/Main.class and /dev/null differ diff --git a/test/Java/Main.java b/test/Java/Main.java deleted file mode 100644 index 0e68d51..0000000 --- a/test/Java/Main.java +++ /dev/null @@ -1,8 +0,0 @@ -class Main{ - public static void main(final String[]a){ - final long start=System.currentTimeMillis(); - System.out.println("Hello World!"); - System.out.print(System.currentTimeMillis()-start); - System.out.println("ms"); - } -} diff --git a/test/UFB/Hello.optimized.ufb b/test/UFB/Hello.optimized.ufb deleted file mode 100644 index 63d65c0..0000000 --- a/test/UFB/Hello.optimized.ufb +++ /dev/null @@ -1 +0,0 @@ -print 8 5 12 12 15 0 23 15 18 12 4 28 37 \ No newline at end of file diff --git a/test/UFB/Hello.optimized.ufbb b/test/UFB/Hello.optimized.ufbb deleted file mode 100644 index 0b87ded..0000000 Binary files a/test/UFB/Hello.optimized.ufbb and /dev/null differ diff --git a/test/UFB/Hello.ufbb b/test/UFB/Hello.ufbb index 0b87ded..484abd7 100644 Binary files a/test/UFB/Hello.ufbb and b/test/UFB/Hello.ufbb differ diff --git a/test/UFB/Main.optimized.ufb b/test/UFB/Main.optimized.ufb deleted file mode 100644 index eda366e..0000000 --- a/test/UFB/Main.optimized.ufb +++ /dev/null @@ -1,25 +0,0 @@ -print 8 5 12 12 15 0 23 15 18 12 4 28 28 28 37 8 5 12 12 15 37 31 29 32 31 34 29 29 35 33 31 37 27 37 27 37 -wvar 38 27 -div 38 27 -print 38 -print 255 37 27 37 27 37 14 21 13 2 5 18 0 27 37 14 21 13 2 5 18 0 28 37 14 21 13 2 5 18 0 29 37 14 21 13 2 5 18 0 30 37 14 21 13 2 5 18 0 31 37 14 21 13 2 5 18 0 32 37 14 21 13 2 5 -nvar 38 -print 18 0 33 37 14 21 13 2 5 18 0 34 37 14 21 13 2 5 18 0 35 37 14 21 13 2 5 18 0 36 37 7 15 15 4 2 25 5 28 37 -wvar 38 27 -div 38 27 -print 38 -print 255 -wvar 38 27 -sub 38 28 -trim 38 1 -print 38 -print 255 -wvar 38 28 -div 38 29 -print 39 -print 255 37 27 -wvar 38 28 -div 38 29 -print 39 -print 255 32 37 28 37 -nvar 38 \ No newline at end of file diff --git a/test/UFB/Main.optimized.ufbb b/test/UFB/Main.optimized.ufbb deleted file mode 100644 index 5441f70..0000000 Binary files a/test/UFB/Main.optimized.ufbb and /dev/null differ diff --git a/test/UFB/Main.ufbb b/test/UFB/Main.ufbb index 49164f6..f05049c 100644 Binary files a/test/UFB/Main.ufbb and b/test/UFB/Main.ufbb differ diff --git a/test/UFB/OptimizeMe.optimized.ufb b/test/UFB/OptimizeMe.optimized.ufb deleted file mode 100644 index 3c1157a..0000000 --- a/test/UFB/OptimizeMe.optimized.ufb +++ /dev/null @@ -1 +0,0 @@ -print 8 5 12 12 15 23 15 18 12 4 28 37 16 18 15 7 18 1 13 13 5 4 0 20 15 0 23 15 18 11 37 1 14 4 0 14 15 20 0 20 15 0 6 5 5 12 37 37 9 0 7 15 20 0 12 19 19 28 4 0 12 15 12 37 \ No newline at end of file diff --git a/test/UFB/OptimizeMe.optimized.ufbb b/test/UFB/OptimizeMe.optimized.ufbb deleted file mode 100644 index f84bc9b..0000000 Binary files a/test/UFB/OptimizeMe.optimized.ufbb and /dev/null differ diff --git a/test/UFB/OptimizeMe.ufbb b/test/UFB/OptimizeMe.ufbb index 877442c..2546c1f 100644 Binary files a/test/UFB/OptimizeMe.ufbb and b/test/UFB/OptimizeMe.ufbb differ