diff --git a/trunk/src/com/jpexs/asdec/Configuration.java b/trunk/src/com/jpexs/asdec/Configuration.java index 103814799..debe0bbe4 100644 --- a/trunk/src/com/jpexs/asdec/Configuration.java +++ b/trunk/src/com/jpexs/asdec/Configuration.java @@ -23,105 +23,100 @@ import java.util.HashMap; import java.util.List; public class Configuration { - private static final String CONFIG_NAME="asdec.cfg"; - private static final String REPLACEMENTS_NAME="replacements.ini"; - private static HashMap config = new HashMap(); - + + private static final String CONFIG_NAME = "asdec.cfg"; + private static final String REPLACEMENTS_NAME = "replacements.ini"; + private static HashMap config = new HashMap(); + public static String getASDecHome() { - String dir = ".";//System.getProperty("user.home"); - if (!dir.endsWith(File.separator)) dir += File.separator; - dir += "config" + File.separator; - return dir; + String dir = ".";//System.getProperty("user.home"); + if (!dir.endsWith(File.separator)) { + dir += File.separator; + } + dir += "config" + File.separator; + return dir; } - + private static String getReplacementsFile() { - return getASDecHome() + REPLACEMENTS_NAME; + return getASDecHome() + REPLACEMENTS_NAME; } - + private static String getConfigFile() { - return getASDecHome() + CONFIG_NAME; + return getASDecHome() + CONFIG_NAME; } - /** - * List of replacements - */ - public static java.util.List replacements = new ArrayList(); - + * List of replacements + */ + public static java.util.List replacements = new ArrayList(); + /** - * Saves replacements to file for future use - */ - private static void saveReplacements() { - try { - if(replacements.isEmpty()){ - File rf=new File(getReplacementsFile()); - if(rf.exists()) rf.delete(); - }else{ - File f = new File(getASDecHome()); - if (!f.exists()) f.mkdir(); - PrintWriter pw = new PrintWriter(new FileWriter(getReplacementsFile())); - for (Replacement r : replacements) { - pw.println(r.urlPattern); - pw.println(r.targetFile); - } - pw.close(); + * Saves replacements to file for future use + */ + private static void saveReplacements() { + try { + if (replacements.isEmpty()) { + File rf = new File(getReplacementsFile()); + if (rf.exists()) { + rf.delete(); } - } catch (IOException e) { - - } - } - - /** - * Load replacements from file - */ - private static void loadReplacements() { - replacements = new ArrayList(); - try { - BufferedReader br = new BufferedReader(new FileReader(getReplacementsFile())); - String s = ""; - while ((s = br.readLine()) != null) { - Replacement r = new Replacement(s, br.readLine()); - replacements.add(r); + } else { + File f = new File(getASDecHome()); + if (!f.exists()) { + f.mkdir(); } - br.close(); - } catch (IOException e) { + PrintWriter pw = new PrintWriter(new FileWriter(getReplacementsFile())); + for (Replacement r : replacements) { + pw.println(r.urlPattern); + pw.println(r.targetFile); + } + pw.close(); + } + } catch (IOException e) { + } + } - } - } - - public static Object getConfig(String cfg) - { - return getConfig(cfg,null); - } - - - public static Object getConfig(String cfg, Object defaultValue) - { - if(!config.containsKey(cfg)) - { - return defaultValue; - } - return config.get(cfg); - } - - public static Object setConfig(String cfg,Object value) - { - return config.put(cfg,value); - } - - public static void load() - { - ObjectInputStream ois=null; - try { - ois=new ObjectInputStream(new FileInputStream(getConfigFile())); - config=(HashMap)ois.readObject(); + /** + * Load replacements from file + */ + private static void loadReplacements() { + replacements = new ArrayList(); + try { + BufferedReader br = new BufferedReader(new FileReader(getReplacementsFile())); + String s = ""; + while ((s = br.readLine()) != null) { + Replacement r = new Replacement(s, br.readLine()); + replacements.add(r); + } + br.close(); + } catch (IOException e) { + } + } + + public static Object getConfig(String cfg) { + return getConfig(cfg, null); + } + + public static Object getConfig(String cfg, Object defaultValue) { + if (!config.containsKey(cfg)) { + return defaultValue; + } + return config.get(cfg); + } + + public static Object setConfig(String cfg, Object value) { + return config.put(cfg, value); + } + + public static void load() { + ObjectInputStream ois = null; + try { + ois = new ObjectInputStream(new FileInputStream(getConfigFile())); + config = (HashMap) ois.readObject(); } catch (FileNotFoundException ex) { - } catch (ClassNotFoundException cnf) { - - }catch (IOException ex) { - + } catch (IOException ex) { } finally { - if(ois!=null){ + if (ois != null) { try { ois.close(); } catch (IOException ex1) { @@ -129,21 +124,18 @@ public class Configuration { } } } - loadReplacements(); - } - - public static void save() - { - ObjectOutputStream oos=null; + loadReplacements(); + } + + public static void save() { + ObjectOutputStream oos = null; try { - oos=new ObjectOutputStream(new FileOutputStream(getConfigFile())); - oos.writeObject(config); + oos = new ObjectOutputStream(new FileOutputStream(getConfigFile())); + oos.writeObject(config); } catch (FileNotFoundException ex) { - } catch (IOException ex) { - } finally { - if(oos!=null){ + if (oos != null) { try { oos.close(); } catch (IOException ex1) { @@ -151,12 +143,10 @@ public class Configuration { } } } - saveReplacements(); - } + saveReplacements(); + } public static List getReplacements() { return replacements; } - - } diff --git a/trunk/src/com/jpexs/asdec/Main.java b/trunk/src/com/jpexs/asdec/Main.java index ab59b4221..172578281 100644 --- a/trunk/src/com/jpexs/asdec/Main.java +++ b/trunk/src/com/jpexs/asdec/Main.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec; import com.jpexs.asdec.abc.NotSameException; @@ -42,7 +41,6 @@ import javax.swing.JOptionPane; import javax.swing.SwingWorker; import javax.swing.filechooser.FileFilter; - /** * Main executable class * @@ -50,565 +48,585 @@ import javax.swing.filechooser.FileFilter; */ public class Main { - public static com.jpexs.asdec.abc.gui.MainFrame abcMainFrame; - public static com.jpexs.asdec.action.gui.MainFrame actionMainFrame; - public static ProxyFrame proxyFrame; - public static String file; - public static String maskURL; - public static SWF swf; - public static final String version = "1.0.0"; - public static String applicationName = "JP ActionScript Decompiler v." + version; - public static String shortApplicationName = "ASDec v."+version; - public static LoadingDialog loadingDialog; - public static ModeFrame modeFrame; - private static boolean working = false; - private static TrayIcon trayIcon; - private static MenuItem stopMenuItem; - private static boolean commandLineMode=false; - - public static boolean isCommandLineMode(){ - return commandLineMode; - } - - public static boolean DEBUG_COPY = false; - /** Debug mode = throwing an error when comparing original file and recompiled */ - public static boolean DEBUG_MODE = false; - /** Turn off reading unsafe tags (tags which can cause problems with recompiling)*/ - public static boolean DISABLE_DANGEROUS = false; - /** Turn off resolving constants in ActionScript 2 */ - public static final boolean RESOLVE_CONSTANTS = true; - /** Turn off decompiling if needed */ - public static final boolean DO_DECOMPILE=true; - /** Find latest constant pool in the code */ - public static final boolean LATEST_CONSTANTPOOL_HACK=false; - /** Dump tags to stdout */ - public static boolean dump_tags = false; - - /** Limit of code subs (for obfuscated code) */ - public static final int SUBLIMITER=500; + public static com.jpexs.asdec.abc.gui.MainFrame abcMainFrame; + public static com.jpexs.asdec.action.gui.MainFrame actionMainFrame; + public static ProxyFrame proxyFrame; + public static String file; + public static String maskURL; + public static SWF swf; + public static final String version = "1.0.0"; + public static String applicationName = "JP ActionScript Decompiler v." + version; + public static String shortApplicationName = "ASDec v." + version; + public static LoadingDialog loadingDialog; + public static ModeFrame modeFrame; + private static boolean working = false; + private static TrayIcon trayIcon; + private static MenuItem stopMenuItem; + private static boolean commandLineMode = false; - //using parameter names in decompiling may cause problems because oficial programs like Flash CS 5.5 inserts wrong parameter names indices - public static final boolean PARAM_NAMES_ENABLE=false; + public static boolean isCommandLineMode() { + return commandLineMode; + } + public static boolean DEBUG_COPY = false; + /** + * Debug mode = throwing an error when comparing original file and recompiled + */ + public static boolean DEBUG_MODE = false; + /** + * Turn off reading unsafe tags (tags which can cause problems with recompiling) + */ + public static boolean DISABLE_DANGEROUS = false; + /** + * Turn off resolving constants in ActionScript 2 + */ + public static final boolean RESOLVE_CONSTANTS = true; + /** + * Turn off decompiling if needed + */ + public static final boolean DO_DECOMPILE = true; + /** + * Find latest constant pool in the code + */ + public static final boolean LATEST_CONSTANTPOOL_HACK = false; + /** + * Dump tags to stdout + */ + public static boolean dump_tags = false; + /** + * Limit of code subs (for obfuscated code) + */ + public static final int SUBLIMITER = 500; + //using parameter names in decompiling may cause problems because oficial programs like Flash CS 5.5 inserts wrong parameter names indices + public static final boolean PARAM_NAMES_ENABLE = false; - public static String getFileTitle() { - if (maskURL != null) return maskURL; - return file; - } + public static String getFileTitle() { + if (maskURL != null) { + return maskURL; + } + return file; + } - - - public static void setSubLimiter(boolean value) - { - if(value){ - AVM2Code.toSourceLimit=Main.SUBLIMITER; - }else{ - AVM2Code.toSourceLimit=-1; - } - } + public static void setSubLimiter(boolean value) { + if (value) { + AVM2Code.toSourceLimit = Main.SUBLIMITER; + } else { + AVM2Code.toSourceLimit = -1; + } + } - public static boolean isWorking() { - return working; - } + public static boolean isWorking() { + return working; + } - public static void showProxy() { - if (proxyFrame == null) proxyFrame = new ProxyFrame(); - proxyFrame.setVisible(true); - proxyFrame.setState(Frame.NORMAL); - } + public static void showProxy() { + if (proxyFrame == null) { + proxyFrame = new ProxyFrame(); + } + proxyFrame.setVisible(true); + proxyFrame.setState(Frame.NORMAL); + } - public static void startWork(String name) { - working = true; - if(abcMainFrame!=null) - abcMainFrame.setStatus(name); - if(actionMainFrame!=null) - actionMainFrame.setStatus(name); - if(Main.isCommandLineMode()){ - System.out.println(name); - } - } + public static void startWork(String name) { + working = true; + if (abcMainFrame != null) { + abcMainFrame.setStatus(name); + } + if (actionMainFrame != null) { + actionMainFrame.setStatus(name); + } + if (Main.isCommandLineMode()) { + System.out.println(name); + } + } - public static void stopWork() { - working = false; - if(abcMainFrame!=null) - abcMainFrame.setStatus(""); - if(actionMainFrame!=null) - actionMainFrame.setStatus(""); - } + public static void stopWork() { + working = false; + if (abcMainFrame != null) { + abcMainFrame.setStatus(""); + } + if (actionMainFrame != null) { + actionMainFrame.setStatus(""); + } + } - public static SWF parseSWF(String file) throws Exception { - FileInputStream fis = new FileInputStream(file); - InputStream bis = new BufferedInputStream(fis); - SWF locswf = new SWF(bis); - return locswf; - } + public static SWF parseSWF(String file) throws Exception { + FileInputStream fis = new FileInputStream(file); + InputStream bis = new BufferedInputStream(fis); + SWF locswf = new SWF(bis); + return locswf; + } + public static void saveFile(String outfile) throws IOException { + file = outfile; + swf.saveTo(new FileOutputStream(outfile)); + } - public static void saveFile(String outfile) throws IOException { - file = outfile; - swf.saveTo(new FileOutputStream(outfile)); - } - - - public static boolean exportSWF(String inFile,String outdir,boolean isPcode) throws Exception { - SWF swf = parseSWF(inFile); - boolean asFound=false; - for (Tag t : swf.tags) { - if (t instanceof DoABCTag){ - ((DoABCTag)t).abc.export(outdir,isPcode); - asFound=true; + public static boolean exportSWF(String inFile, String outdir, boolean isPcode) throws Exception { + SWF swf = parseSWF(inFile); + boolean asFound = false; + for (Tag t : swf.tags) { + if (t instanceof DoABCTag) { + ((DoABCTag) t).abc.export(outdir, isPcode); + asFound = true; } - } - return asFound; - } - - private static class OpenFileWorker extends SwingWorker { - @Override - protected Object doInBackground() throws Exception { + } + return asFound; + } + + private static class OpenFileWorker extends SwingWorker { + + @Override + protected Object doInBackground() throws Exception { + try { + swf = parseSWF(Main.file); + FileInputStream fis = new FileInputStream(file); + DEBUG_COPY = true; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { - swf = parseSWF(Main.file); - FileInputStream fis = new FileInputStream(file); - DEBUG_COPY = true; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - swf.saveTo(baos); - } catch (NotSameException nse) { - if (DEBUG_MODE) { - nse.printStackTrace(); - System.exit(0); - } - JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY."); - } - DEBUG_COPY = false; - //DEBUG_COPY=true; - } catch (Exception ex) { - if(DEBUG_MODE) - { - ex.printStackTrace(); - } - JOptionPane.showMessageDialog(null, "Cannot load SWF file."); - loadingDialog.setVisible(false); - return false; + swf.saveTo(baos); + } catch (NotSameException nse) { + if (DEBUG_MODE) { + nse.printStackTrace(); + System.exit(0); + } + JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY."); } - List listAbc = new ArrayList(); - for (Tag t : swf.tags) { - if (t instanceof DoABCTag) listAbc.add(t); - } - - - if (false) { - JOptionPane.showMessageDialog(null, "This SWF file does not contain any ActionScript parts"); - loadingDialog.setVisible(false); - if (!openFileDialog()) { - System.exit(0); - } - } else { - if (listAbc.size() > 0) { - List listAbc2 = new ArrayList(); - for (Tag tag : listAbc) { - listAbc2.add((DoABCTag) tag); - } - abcMainFrame = new com.jpexs.asdec.abc.gui.MainFrame(listAbc2); - abcMainFrame.display(); - } else { - actionMainFrame = new com.jpexs.asdec.action.gui.MainFrame(swf.tags); - actionMainFrame.display(); - } + DEBUG_COPY = false; + //DEBUG_COPY=true; + } catch (Exception ex) { + if (DEBUG_MODE) { + ex.printStackTrace(); } + JOptionPane.showMessageDialog(null, "Cannot load SWF file."); loadingDialog.setVisible(false); - return true; - } - } - - public static boolean openFile(String swfFile) { - if (abcMainFrame != null) - abcMainFrame.setVisible(false); - if (actionMainFrame != null) - actionMainFrame.setVisible(false); - Main.file = swfFile; - if(Main.loadingDialog == null) - { - Main.loadingDialog=new LoadingDialog(); - } - Main.loadingDialog.setVisible(true); - (new OpenFileWorker()).execute(); - return true; - } - - - public static boolean saveFileDialog() { - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File((String)Configuration.getConfig("lastSaveDir","."))); - JFrame f=new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showSaveDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - try { - Main.saveFile(file.getAbsolutePath()); - Configuration.setConfig("lastSaveDir", file.getParentFile().getAbsolutePath()); - maskURL = null; - return true; - } catch (IOException ex) { - JOptionPane.showMessageDialog(null, "Cannot write to the file"); - } - } - return false; - } - - public static boolean openFileDialog() { - maskURL = null; - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File((String)Configuration.getConfig("lastOpenDir","."))); - fc.setFileFilter(new FileFilter() { - - @Override - public boolean accept(File f) { - return (f.getName().endsWith(".swf")) || (f.isDirectory()); - } - - @Override - public String getDescription() { - return "SWF files (*.swf)"; - } - - }); - JFrame f=new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showOpenDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - Configuration.setConfig("lastOpenDir", fc.getSelectedFile().getParentFile().getAbsolutePath()); - File selfile = fc.getSelectedFile(); - Main.openFile(selfile.getAbsolutePath()); - return true; - } else { return false; - } - } - - - public static void showModeFrame() { - if (modeFrame == null) modeFrame = new ModeFrame(); - modeFrame.setVisible(true); - } - - - /** - * Script for updating license header in java files :-) - * @param dir Star directory (e.g. "src/") - */ - public static void updateLicenseInDir(File dir){ - int defaultStartYear=2010; - int defaultFinalYear=2011; - String defaultAuthor="JPEXS"; - String defaultYearStr=""+defaultStartYear; - if(defaultFinalYear!=defaultStartYear){ - defaultYearStr+="-"+defaultFinalYear; - } - String license="/*\r\n * Copyright (C) {year} {author}\r\n * \r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n * \r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU General Public License\r\n * along with this program. If not, see .\r\n */\r\n"; - - File files[]=dir.listFiles(); - for(File f:files){ - if(f.isDirectory()){ - updateLicenseInDir(f); - }else{ - if(f.getName().endsWith(".java")){ - ByteArrayOutputStream baos=new ByteArrayOutputStream(); - PrintWriter pw=null; - try { - pw = new PrintWriter(new OutputStreamWriter(baos, "utf8")); - } catch (UnsupportedEncodingException ex) { - - } - try { - BufferedReader br=new BufferedReader(new FileReader(f)); - String s=""; - boolean packageFound=false; - String author=defaultAuthor; - String yearStr=defaultYearStr; - while((s=br.readLine())!=null){ - if(!packageFound){ - if(s.trim().startsWith("package")){ - packageFound=true; - pw.println(license.replace("{year}", yearStr).replace("{author}", author)); - }else{ - Matcher mAuthor=Pattern.compile("^.*Copyright \\(C\\) ([0-9]+)(-[0-9]+)? (.*)$").matcher(s); - if(mAuthor.matches()){ - author=mAuthor.group(3).trim(); - int startYear=Integer.parseInt(mAuthor.group(1).trim()); - if(startYear==defaultFinalYear){ - yearStr=""+startYear; - }else{ - yearStr=""+startYear+"-"+defaultFinalYear; - } - if(!author.equals(defaultAuthor)){ - System.out.println("Detected nodefault author:"+author+" in "+f.getAbsolutePath()); - } - } - } - } - if(packageFound){ - pw.println(s); - } - } - br.close(); - pw.close(); - } catch (IOException ex) { - - } - - FileOutputStream fos; - try { - fos = new FileOutputStream(f); - fos.write(baos.toByteArray()); - fos.close(); - } catch (IOException ex) { - - } - } + } + List listAbc = new ArrayList(); + for (Tag t : swf.tags) { + if (t instanceof DoABCTag) { + listAbc.add(t); } - } + } - } - - public static void badArguments(){ - System.err.println("Error: Bad Commandline Arguments!"); - printCmdLineUsage(); - System.exit(1); - } - public static void printHeader(){ - System.out.println(applicationName); - for(int i=0;i 0) { + List listAbc2 = new ArrayList(); + for (Tag tag : listAbc) { + listAbc2.add((DoABCTag) tag); } - String exportFormat=args[1]; - if(!exportFormat.toLowerCase().equals("as")){ - if(!exportFormat.toLowerCase().equals("pcode")){ - System.err.println("Invalid export format:"+exportFormat); - badArguments(); - } - } - File outDir=new File(args[2]); - File inFile=new File(args[3]); - if(!inFile.exists()){ - System.err.println("Input SWF file does not exist!"); - badArguments(); - } - commandLineMode=true; - boolean exportOK=true; - try{ - printHeader(); - exportOK=exportSWF(inFile.getAbsolutePath(),outDir.getAbsolutePath(),exportFormat.equals("pcode")); - }catch(Exception ex){ - exportOK=false; - System.err.print("FAIL: Exporting Failed on Exception - "); - System.err.println(ex.getLocalizedMessage()); - System.exit(1); - } - if(exportOK){ - System.out.println("OK"); - System.exit(0); - }else{ - System.err.println("FAIL: No ActionScript version 3 found in the input file."); - System.exit(1); - } - } else if (args[0].equals("-compress")) { - if(args.length<3){ - badArguments(); - } - - if(SWF.fws2cws(new FileInputStream(args[1]), new FileOutputStream(args[2]))){ - System.out.println("OK"); - }else{ - System.err.println("FAIL");; - } - } else if (args[0].equals("-decompress")) { - if(args.length<3){ - badArguments(); - } - - if(SWF.cws2fws(new FileInputStream(args[1]), new FileOutputStream(args[2]))){ - System.out.println("OK"); - System.exit(0); - }else{ - System.err.println("FAIL"); - System.exit(1); - } - } else if (args[0].equals("-dumpSWF")) { - if(args.length<2){ - badArguments(); + abcMainFrame = new com.jpexs.asdec.abc.gui.MainFrame(listAbc2); + abcMainFrame.display(); + } else { + actionMainFrame = new com.jpexs.asdec.action.gui.MainFrame(swf.tags); + actionMainFrame.display(); + } + } + loadingDialog.setVisible(false); + return true; + } + } + + public static boolean openFile(String swfFile) { + if (abcMainFrame != null) { + abcMainFrame.setVisible(false); + } + if (actionMainFrame != null) { + actionMainFrame.setVisible(false); + } + Main.file = swfFile; + if (Main.loadingDialog == null) { + Main.loadingDialog = new LoadingDialog(); + } + Main.loadingDialog.setVisible(true); + (new OpenFileWorker()).execute(); + return true; + } + + public static boolean saveFileDialog() { + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastSaveDir", "."))); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showSaveDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + try { + Main.saveFile(file.getAbsolutePath()); + Configuration.setConfig("lastSaveDir", file.getParentFile().getAbsolutePath()); + maskURL = null; + return true; + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Cannot write to the file"); + } + } + return false; + } + + public static boolean openFileDialog() { + maskURL = null; + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); + fc.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + return (f.getName().endsWith(".swf")) || (f.isDirectory()); + } + + @Override + public String getDescription() { + return "SWF files (*.swf)"; + } + }); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showOpenDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + Configuration.setConfig("lastOpenDir", fc.getSelectedFile().getParentFile().getAbsolutePath()); + File selfile = fc.getSelectedFile(); + Main.openFile(selfile.getAbsolutePath()); + return true; + } else { + return false; + } + } + + public static void showModeFrame() { + if (modeFrame == null) { + modeFrame = new ModeFrame(); + } + modeFrame.setVisible(true); + } + + /** + * Script for updating license header in java files :-) + * + * @param dir Star directory (e.g. "src/") + */ + public static void updateLicenseInDir(File dir) { + int defaultStartYear = 2010; + int defaultFinalYear = 2011; + String defaultAuthor = "JPEXS"; + String defaultYearStr = "" + defaultStartYear; + if (defaultFinalYear != defaultStartYear) { + defaultYearStr += "-" + defaultFinalYear; + } + String license = "/*\r\n * Copyright (C) {year} {author}\r\n * \r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n * \r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU General Public License\r\n * along with this program. If not, see .\r\n */\r\n"; + + File files[] = dir.listFiles(); + for (File f : files) { + if (f.isDirectory()) { + updateLicenseInDir(f); + } else { + if (f.getName().endsWith(".java")) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = null; + try { + pw = new PrintWriter(new OutputStreamWriter(baos, "utf8")); + } catch (UnsupportedEncodingException ex) { } try { - dump_tags=true; - parseSWF(args[1]); - } catch (Exception ex) { - System.err.println("Dump failed due to Exception - "+ex.getLocalizedMessage()); - System.exit(1); + BufferedReader br = new BufferedReader(new FileReader(f)); + String s = ""; + boolean packageFound = false; + String author = defaultAuthor; + String yearStr = defaultYearStr; + while ((s = br.readLine()) != null) { + if (!packageFound) { + if (s.trim().startsWith("package")) { + packageFound = true; + pw.println(license.replace("{year}", yearStr).replace("{author}", author)); + } else { + Matcher mAuthor = Pattern.compile("^.*Copyright \\(C\\) ([0-9]+)(-[0-9]+)? (.*)$").matcher(s); + if (mAuthor.matches()) { + author = mAuthor.group(3).trim(); + int startYear = Integer.parseInt(mAuthor.group(1).trim()); + if (startYear == defaultFinalYear) { + yearStr = "" + startYear; + } else { + yearStr = "" + startYear + "-" + defaultFinalYear; + } + if (!author.equals(defaultAuthor)) { + System.out.println("Detected nodefault author:" + author + " in " + f.getAbsolutePath()); + } + } + } + } + if (packageFound) { + pw.println(s); + } + } + br.close(); + pw.close(); + } catch (IOException ex) { + } + + FileOutputStream fos; + try { + fos = new FileOutputStream(f); + fos.write(baos.toByteArray()); + fos.close(); + } catch (IOException ex) { } - System.exit(0); - }else if (args[0].equals("-help")||args[0].equals("--help")||args[0].equals("/?")){ - printHeader(); - printCmdLineUsage(); - System.exit(0); } - else if(args.length==1){ - openFile(args[0]); - }else{ + } + } + + } + + public static void badArguments() { + System.err.println("Error: Bad Commandline Arguments!"); + printCmdLineUsage(); + System.exit(1); + } + + public static void printHeader() { + System.out.println(applicationName); + for (int i = 0; i < applicationName.length(); i++) { + System.out.print("-"); + } + System.out.println(); + } + + public static void printCmdLineUsage() { + System.out.println("Commandline arguments:"); + System.out.println(" 1) -help | --help | /?"); + System.out.println(" ...shows commandline arguments (this help)"); + System.out.println(" 2) infile"); + System.out.println(" ...opens SWF file with the decompiler GUI"); + System.out.println(" 3) -proxy (-PXXX)"); + System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. "); + System.out.println(" 4) -export (as|pcode) outdirectory infile"); + System.out.println(" ...export infile actionscript to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument)"); + System.out.println(" 5) -dumpSWF infile"); + System.out.println(" ...dumps list of SWF tags to console"); + System.out.println(" 6) -compress infile outfile"); + System.out.println(" ...Compress SWF infile and save it to outfile"); + System.out.println(" 7) -decompress infile outfile"); + System.out.println(" ...Decompress infile and save it to outfile"); + System.out.println(); + System.out.println("Examples:"); + System.out.println("java -jar ASDec.jar myfile.swf"); + System.out.println("java -jar ASDec.jar -proxy"); + System.out.println("java -jar ASDec.jar -proxy -P1234"); + System.out.println("java -jar ASDec.jar -export as \"C:\\decompiled\\\" myfile.swf"); + System.out.println("java -jar ASDec.jar -export pcode \"C:\\decompiled\\\" myfile.swf"); + System.out.println("java -jar ASDec.jar -dumpSWF myfile.swf"); + System.out.println("java -jar ASDec.jar -compress myfile.swf myfiledec.swf"); + System.out.println("java -jar ASDec.jar -deccompress myfiledec.swf myfile.swf"); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws IOException { + View.setWinLookAndFeel(); + Configuration.load(); + if (args.length < 1) { + showModeFrame(); + } else { + if (args[0].equals("-proxy")) { + int port = 55555; + for (int i = 0; i < args.length; i++) { + if (args[i].startsWith("-P")) { + try { + port = Integer.parseInt(args[i].substring(2)); + } catch (NumberFormatException nex) { + System.err.println("Bad port number"); + } + } + } + if (proxyFrame == null) { + proxyFrame = new ProxyFrame(); + } + proxyFrame.setPort(port); + addTrayIcon(); + switchProxy(); + } else if (args[0].equals("-export")) { + if (args.length < 4) { badArguments(); } - } - } - - - public static String tempFile(String url) { - File f = new File(Configuration.getASDecHome() + "saved" + File.separator); - if (!f.exists()) f.mkdirs(); - return Configuration.getASDecHome() + "saved" + File.separator + "asdec_" + Integer.toHexString(url.hashCode()) + ".tmp"; - - } - - public static void removeTrayIcon() { - if (SystemTray.isSupported()) { - SystemTray tray = SystemTray.getSystemTray(); - if (trayIcon != null) { - tray.remove(trayIcon); - trayIcon = null; + String exportFormat = args[1]; + if (!exportFormat.toLowerCase().equals("as")) { + if (!exportFormat.toLowerCase().equals("pcode")) { + System.err.println("Invalid export format:" + exportFormat); + badArguments(); + } } - } - } - - public static void switchProxy() { - proxyFrame.switchState(); - if (stopMenuItem != null) { - if (proxyFrame.isRunning()) { - stopMenuItem.setLabel("Stop proxy"); - } else { - stopMenuItem.setLabel("Start proxy"); + File outDir = new File(args[2]); + File inFile = new File(args[3]); + if (!inFile.exists()) { + System.err.println("Input SWF file does not exist!"); + badArguments(); } - } - } - - public static void addTrayIcon() { - if (trayIcon != null) return; - if (SystemTray.isSupported()) { - SystemTray tray = SystemTray.getSystemTray(); - trayIcon = new TrayIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"), "JP ASDec Proxy"); - trayIcon.setImageAutoSize(true); - PopupMenu trayPopup = new PopupMenu(); - - - ActionListener trayListener = new ActionListener() { - /** - * Invoked when an action occurs. - */ - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("EXIT")) Main.exit(); - if (e.getActionCommand().equals("SHOW")) Main.showProxy(); - if (e.getActionCommand().equals("SWITCH")) Main.switchProxy(); - } - }; - - - MenuItem showMenuItem = new MenuItem("Show proxy"); - showMenuItem.setActionCommand("SHOW"); - showMenuItem.addActionListener(trayListener); - trayPopup.add(showMenuItem); - stopMenuItem = new MenuItem("Start proxy"); - stopMenuItem.setActionCommand("SWITCH"); - stopMenuItem.addActionListener(trayListener); - trayPopup.add(stopMenuItem); - trayPopup.addSeparator(); - MenuItem exitMenuItem = new MenuItem("Exit"); - exitMenuItem.setActionCommand("EXIT"); - exitMenuItem.addActionListener(trayListener); - trayPopup.add(exitMenuItem); - - trayIcon.setPopupMenu(trayPopup); - trayIcon.addMouseListener(new MouseAdapter() { - /** - * {@inheritDoc} - */ - @Override - public void mouseClicked(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - Main.showProxy(); - } - } - }); + commandLineMode = true; + boolean exportOK = true; try { - tray.add(trayIcon); - } catch (AWTException ex) { - + printHeader(); + exportOK = exportSWF(inFile.getAbsolutePath(), outDir.getAbsolutePath(), exportFormat.equals("pcode")); + } catch (Exception ex) { + exportOK = false; + System.err.print("FAIL: Exporting Failed on Exception - "); + System.err.println(ex.getLocalizedMessage()); + System.exit(1); + } + if (exportOK) { + System.out.println("OK"); + System.exit(0); + } else { + System.err.println("FAIL: No ActionScript version 3 found in the input file."); + System.exit(1); + } + } else if (args[0].equals("-compress")) { + if (args.length < 3) { + badArguments(); } - } - } - public static void exit() { - Configuration.save(); - System.exit(0); - } + if (SWF.fws2cws(new FileInputStream(args[1]), new FileOutputStream(args[2]))) { + System.out.println("OK"); + } else { + System.err.println("FAIL");; + } + } else if (args[0].equals("-decompress")) { + if (args.length < 3) { + badArguments(); + } - public static void about() - { - (new AboutDialog()).setVisible(true); - } + if (SWF.cws2fws(new FileInputStream(args[1]), new FileOutputStream(args[2]))) { + System.out.println("OK"); + System.exit(0); + } else { + System.err.println("FAIL"); + System.exit(1); + } + } else if (args[0].equals("-dumpSWF")) { + if (args.length < 2) { + badArguments(); + } + try { + dump_tags = true; + parseSWF(args[1]); + } catch (Exception ex) { + System.err.println("Dump failed due to Exception - " + ex.getLocalizedMessage()); + System.exit(1); + } + System.exit(0); + } else if (args[0].equals("-help") || args[0].equals("--help") || args[0].equals("/?")) { + printHeader(); + printCmdLineUsage(); + System.exit(0); + } else if (args.length == 1) { + openFile(args[0]); + } else { + badArguments(); + } + } + } + + public static String tempFile(String url) { + File f = new File(Configuration.getASDecHome() + "saved" + File.separator); + if (!f.exists()) { + f.mkdirs(); + } + return Configuration.getASDecHome() + "saved" + File.separator + "asdec_" + Integer.toHexString(url.hashCode()) + ".tmp"; + + } + + public static void removeTrayIcon() { + if (SystemTray.isSupported()) { + SystemTray tray = SystemTray.getSystemTray(); + if (trayIcon != null) { + tray.remove(trayIcon); + trayIcon = null; + } + } + } + + public static void switchProxy() { + proxyFrame.switchState(); + if (stopMenuItem != null) { + if (proxyFrame.isRunning()) { + stopMenuItem.setLabel("Stop proxy"); + } else { + stopMenuItem.setLabel("Start proxy"); + } + } + } + + public static void addTrayIcon() { + if (trayIcon != null) { + return; + } + if (SystemTray.isSupported()) { + SystemTray tray = SystemTray.getSystemTray(); + trayIcon = new TrayIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"), "JP ASDec Proxy"); + trayIcon.setImageAutoSize(true); + PopupMenu trayPopup = new PopupMenu(); + + + ActionListener trayListener = new ActionListener() { + /** + * Invoked when an action occurs. + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("EXIT")) { + Main.exit(); + } + if (e.getActionCommand().equals("SHOW")) { + Main.showProxy(); + } + if (e.getActionCommand().equals("SWITCH")) { + Main.switchProxy(); + } + } + }; + + + MenuItem showMenuItem = new MenuItem("Show proxy"); + showMenuItem.setActionCommand("SHOW"); + showMenuItem.addActionListener(trayListener); + trayPopup.add(showMenuItem); + stopMenuItem = new MenuItem("Start proxy"); + stopMenuItem.setActionCommand("SWITCH"); + stopMenuItem.addActionListener(trayListener); + trayPopup.add(stopMenuItem); + trayPopup.addSeparator(); + MenuItem exitMenuItem = new MenuItem("Exit"); + exitMenuItem.setActionCommand("EXIT"); + exitMenuItem.addActionListener(trayListener); + trayPopup.add(exitMenuItem); + + trayIcon.setPopupMenu(trayPopup); + trayIcon.addMouseListener(new MouseAdapter() { + /** + * {@inheritDoc} + */ + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1) { + Main.showProxy(); + } + } + }); + try { + tray.add(trayIcon); + } catch (AWTException ex) { + } + } + } + + public static void exit() { + Configuration.save(); + System.exit(0); + } + + public static void about() { + (new AboutDialog()).setVisible(true); + } } diff --git a/trunk/src/com/jpexs/asdec/SWF.java b/trunk/src/com/jpexs/asdec/SWF.java index 03578b18a..89cde239e 100644 --- a/trunk/src/com/jpexs/asdec/SWF.java +++ b/trunk/src/com/jpexs/asdec/SWF.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec; import SevenZip.Compression.LZMA.Encoder; @@ -33,252 +32,249 @@ import java.util.zip.InflaterInputStream; */ public class SWF { - /** - * Tags inside of file - */ - public List tags = new ArrayList(); - /** - * Rectangle for the display - */ - public RECT displayRect; - /** - * Movie frame rate - */ - public int frameRate; - /** - * Number of frames in movie - */ - public int frameCount; - /** - * Version of SWF - */ - public int version; - /** - * Size of the file - */ - public long fileSize; + /** + * Tags inside of file + */ + public List tags = new ArrayList(); + /** + * Rectangle for the display + */ + public RECT displayRect; + /** + * Movie frame rate + */ + public int frameRate; + /** + * Number of frames in movie + */ + public int frameCount; + /** + * Version of SWF + */ + public int version; + /** + * Size of the file + */ + public long fileSize; + /** + * Use compression + */ + public boolean compressed = false; + /** + * Use LZMA compression + */ + public boolean lzma = false; + /** + * Compressed size of the file (LZMA) + */ + public long compressedSize; + /** + * LZMA Properties + */ + public byte lzmaProperties[]; - /** - * Use compression - */ - public boolean compressed = false; - - /** - * Use LZMA compression - */ - public boolean lzma = false; - - /** - * Compressed size of the file (LZMA) - */ - public long compressedSize; - - /** - * LZMA Properties - */ - public byte lzmaProperties[]; - - + /** + * Gets all tags with specified id + * + * @param tagId Identificator of tag type + * @return List of tags + */ + public List getTagData(int tagId) { + List ret = new ArrayList(); + for (Tag tag : tags) { + if (tag.getId() == tagId) { + ret.add(tag); + } + } + return ret; + } - /** - * Gets all tags with specified id - * - * @param tagId Identificator of tag type - * @return List of tags - */ - public List getTagData(int tagId) { - List ret = new ArrayList(); - for (Tag tag : tags) { - if (tag.getId() == tagId) { - ret.add(tag); - } - } - return ret; - } + /** + * Saves this SWF into new file + * + * @param os OutputStream to save SWF in + * @throws IOException + */ + public void saveTo(OutputStream os) throws IOException { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + sos.writeRECT(displayRect); + sos.writeUI8(0); + sos.writeUI8(frameRate); + sos.writeUI16(frameCount); - /** - * Saves this SWF into new file - * - * @param os OutputStream to save SWF in - * @throws IOException - */ - public void saveTo(OutputStream os) throws IOException { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - sos.writeRECT(displayRect); - sos.writeUI8(0); - sos.writeUI8(frameRate); - sos.writeUI16(frameCount); + sos.writeTags(tags); + sos.writeUI16(0); + sos.close(); + if (compressed && lzma) { + os.write('Z'); + } else if (compressed) { + os.write('C'); + } else { + os.write('F'); + } + os.write('W'); + os.write('S'); + os.write(version); + byte data[] = baos.toByteArray(); + sos = new SWFOutputStream(os, version); + sos.writeUI32(data.length + 8); - sos.writeTags(tags); - sos.writeUI16(0); - sos.close(); - if (compressed && lzma) { - os.write('Z'); - }else if(compressed){ - os.write('C'); + if (compressed) { + if (lzma) { + Encoder enc = new Encoder(); + int val = lzmaProperties[0] & 0xFF; + int lc = val % 9; + int remainder = val / 9; + int lp = remainder % 5; + int pb = remainder / 5; + int dictionarySize = 0; + for (int i = 0; i < 4; i++) { + dictionarySize += ((int) (lzmaProperties[1 + i]) & 0xFF) << (i * 8); + } + enc.SetDictionarySize(dictionarySize); + enc.SetLcLpPb(lc, lp, pb); + baos = new ByteArrayOutputStream(); + enc.SetEndMarkerMode(true); + enc.Code(new ByteArrayInputStream(data), baos, -1, -1, null); + data = baos.toByteArray(); + byte udata[] = new byte[4]; + udata[0] = (byte) (data.length & 0xFF); + udata[1] = (byte) ((data.length >> 8) & 0xFF); + udata[2] = (byte) ((data.length >> 16) & 0xFF); + udata[3] = (byte) ((data.length >> 24) & 0xFF); + os.write(udata); + os.write(lzmaProperties); } else { - os.write('F'); + os = new DeflaterOutputStream(os); } - os.write('W'); - os.write('S'); - os.write(version); - byte data[] = baos.toByteArray(); - sos = new SWFOutputStream(os, version); - sos.writeUI32(data.length + 8); + } + os.write(data); + } finally { + if (os != null) { + os.close(); + } + } - if (compressed) { - if(lzma){ - Encoder enc=new Encoder(); - int val = lzmaProperties[0] & 0xFF; - int lc = val % 9; - int remainder = val / 9; - int lp = remainder % 5; - int pb = remainder / 5; - int dictionarySize = 0; - for (int i = 0; i < 4; i++) - dictionarySize += ((int)(lzmaProperties[1 + i]) & 0xFF) << (i * 8); - enc.SetDictionarySize(dictionarySize); - enc.SetLcLpPb(lc, lp, pb); - baos = new ByteArrayOutputStream(); - enc.SetEndMarkerMode(true); - enc.Code(new ByteArrayInputStream(data), baos, -1, -1, null); - data = baos.toByteArray(); - byte udata[]=new byte[4]; - udata[0]=(byte)(data.length&0xFF); - udata[1]=(byte)((data.length>>8) & 0xFF); - udata[2]=(byte)((data.length>>16) & 0xFF); - udata[3]=(byte)((data.length>>24) & 0xFF); - os.write(udata); - os.write(lzmaProperties); - }else{ - os = new DeflaterOutputStream(os); - } - } - os.write(data); - } - finally { - if (os != null) - os.close(); - } + } - } + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @throws IOException + */ + public SWF(InputStream is) throws IOException { + byte hdr[] = new byte[3]; + is.read(hdr); + String shdr = new String(hdr); + if ((!shdr.equals("FWS")) && (!shdr.equals("CWS")) && (!shdr.equals("ZWS"))) { + throw new IOException("Invalid SWF file"); + } + version = is.read(); + SWFInputStream sis = new SWFInputStream(is, version, 4); + fileSize = sis.readUI32(); - /** - * Construct SWF from stream - * - * @param is Stream to read SWF from - * @throws IOException - */ - public SWF(InputStream is) throws IOException { - byte hdr[] = new byte[3]; - is.read(hdr); - String shdr = new String(hdr); - if ((!shdr.equals("FWS")) && (!shdr.equals("CWS")) && (!shdr.equals("ZWS"))) { - throw new IOException("Invalid SWF file"); - } - version = is.read(); - SWFInputStream sis = new SWFInputStream(is, version, 4); - fileSize = sis.readUI32(); + if (hdr[0] == 'C') { + sis = new SWFInputStream(new InflaterInputStream(is), version, 8); + compressed = true; + } - if (hdr[0] == 'C') { - sis = new SWFInputStream(new InflaterInputStream(is), version, 8); - compressed = true; - } - - if (hdr[0] == 'Z') { - ByteArrayOutputStream baos=new ByteArrayOutputStream(); - long outSize = sis.readUI32(); - int propertiesSize = 5; - lzmaProperties = new byte[propertiesSize]; - if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) - throw new IOException("LZMA:input .lzma file is too short"); - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); - if (!decoder.SetDecoderProperties(lzmaProperties)) - throw new IOException("LZMA:Incorrect stream properties"); - - if (!decoder.Code(sis, baos, fileSize-8)) - throw new IOException("LZMA:Error in data stream"); - sis = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), version, 8); - compressed = true; - lzma = true; - } - - + if (hdr[0] == 'Z') { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long outSize = sis.readUI32(); + int propertiesSize = 5; + lzmaProperties = new byte[propertiesSize]; + if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { + throw new IOException("LZMA:input .lzma file is too short"); + } + SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); + if (!decoder.SetDecoderProperties(lzmaProperties)) { + throw new IOException("LZMA:Incorrect stream properties"); + } + + if (!decoder.Code(sis, baos, fileSize - 8)) { + throw new IOException("LZMA:Error in data stream"); + } + sis = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), version, 8); + compressed = true; + lzma = true; + } - displayRect = sis.readRECT(); - // FIXED8 (16 bit fixed point) frameRate - int tmpFirstByetOfFrameRate = sis.readUI8(); - frameRate = sis.readUI8(); - frameCount = sis.readUI16(); - tags = sis.readTagList(0); - } - /** - * Compress SWF file - * - * @param fis Input stream - * @param fos Output stream - */ - public static boolean fws2cws(InputStream fis, OutputStream fos) { - try { - byte swfHead[] = new byte[8]; - fis.read(swfHead); + displayRect = sis.readRECT(); + // FIXED8 (16 bit fixed point) frameRate + int tmpFirstByetOfFrameRate = sis.readUI8(); + frameRate = sis.readUI8(); + frameCount = sis.readUI16(); + tags = sis.readTagList(0); + } - if(swfHead[0]!= 'F'){ - fis.close(); - return false; - } - swfHead[0] = 'C'; - fos.write(swfHead); - fos = new DeflaterOutputStream(fos); - int i = 0; - while ((i = fis.read()) != -1) { - fos.write(i); - } + /** + * Compress SWF file + * + * @param fis Input stream + * @param fos Output stream + */ + public static boolean fws2cws(InputStream fis, OutputStream fos) { + try { + byte swfHead[] = new byte[8]; + fis.read(swfHead); + if (swfHead[0] != 'F') { fis.close(); - fos.close(); - } catch (FileNotFoundException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } + return false; + } + swfHead[0] = 'C'; + fos.write(swfHead); + fos = new DeflaterOutputStream(fos); + int i = 0; + while ((i = fis.read()) != -1) { + fos.write(i); + } - /** - * Decompress SWF file - * - * @param fis Input stream - * @param fos Output stream - */ - public static boolean cws2fws(InputStream fis, OutputStream fos) { - try { - byte swfHead[] = new byte[8]; - fis.read(swfHead); - InflaterInputStream iis = new InflaterInputStream(fis); - if(swfHead[0]!= 'C'){ - fis.close(); - return false; - } - swfHead[0] = 'F'; - fos.write(swfHead); - int i = 0; - while ((i = iis.read()) != -1) { - fos.write(i); - } + fis.close(); + fos.close(); + } catch (FileNotFoundException ex) { + return false; + } catch (IOException ex) { + return false; + } + return true; + } + /** + * Decompress SWF file + * + * @param fis Input stream + * @param fos Output stream + */ + public static boolean cws2fws(InputStream fis, OutputStream fos) { + try { + byte swfHead[] = new byte[8]; + fis.read(swfHead); + InflaterInputStream iis = new InflaterInputStream(fis); + if (swfHead[0] != 'C') { fis.close(); - fos.close(); - } catch (FileNotFoundException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } + return false; + } + swfHead[0] = 'F'; + fos.write(swfHead); + int i = 0; + while ((i = iis.read()) != -1) { + fos.write(i); + } + + fis.close(); + fos.close(); + } catch (FileNotFoundException ex) { + return false; + } catch (IOException ex) { + return false; + } + return true; + } } diff --git a/trunk/src/com/jpexs/asdec/SWFInputStream.java b/trunk/src/com/jpexs/asdec/SWFInputStream.java index 8c0e61217..1563a32a8 100644 --- a/trunk/src/com/jpexs/asdec/SWFInputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFInputStream.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec; import com.jpexs.asdec.action.Action; @@ -41,1257 +40,1273 @@ import java.util.Stack; * @author JPEXS */ public class SWFInputStream extends InputStream { - private InputStream is; - private Stack margedPos = new Stack(); - private long pos; - private int version; - /** - * Constructor - * - * @param is Existing inputstream - * @param version Version of SWF to read - */ - public SWFInputStream(InputStream is, int version, long startingPos) { - this.version = version; - this.is = is; - pos = startingPos; - } + private InputStream is; + private Stack margedPos = new Stack(); + private long pos; + private int version; - /** - * Constructor - * - * @param is Existing inputstream - * @param version Version of SWF to read - */ - public SWFInputStream(InputStream is, int version) { - this(is, version, 0L); - } + /** + * Constructor + * + * @param is Existing inputstream + * @param version Version of SWF to read + */ + public SWFInputStream(InputStream is, int version, long startingPos) { + this.version = version; + this.is = is; + pos = startingPos; + } - /** - * Gets position in bytes in the stream - * - * @return Number of bytes - */ - public long getPos() { - return pos; - } + /** + * Constructor + * + * @param is Existing inputstream + * @param version Version of SWF to read + */ + public SWFInputStream(InputStream is, int version) { + this(is, version, 0L); + } - /** - * Reads one byte from the stream - * - * @return byte or -1 on error - * @throws IOException - */ - @Override - public int read() throws IOException { - pos++; - bitPos = 0; - return is.read(); - } + /** + * Gets position in bytes in the stream + * + * @return Number of bytes + */ + public long getPos() { + return pos; + } - @Override - public int read(byte[] b, int off, int len) throws IOException { - int bytesRead = super.read(b, off, len); - bitPos = 0; - pos += bytesRead; - return bytesRead; - } + /** + * Reads one byte from the stream + * + * @return byte or -1 on error + * @throws IOException + */ + @Override + public int read() throws IOException { + pos++; + bitPos = 0; + return is.read(); + } - private void alignByte() { - bitPos = 0; - } + @Override + public int read(byte[] b, int off, int len) throws IOException { + int bytesRead = super.read(b, off, len); + bitPos = 0; + pos += bytesRead; + return bytesRead; + } - private int readNoBitReset() throws IOException { - pos++; - return is.read(); - } + private void alignByte() { + bitPos = 0; + } - /** - * Reads one UI8 (Unsigned 8bit integer) value from the stream - * - * @return UI8 value or -1 on error - * @throws IOException - */ - public int readUI8() throws IOException { - return read(); - } + private int readNoBitReset() throws IOException { + pos++; + return is.read(); + } - /** - * Reads one string value from the stream - * - * @return String value - * @throws IOException - */ - public String readString() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int r = 0; - while (true) { - r = read(); - if (r <= 0) return new String(baos.toByteArray(), "utf8"); - baos.write(r); - } - } + /** + * Reads one UI8 (Unsigned 8bit integer) value from the stream + * + * @return UI8 value or -1 on error + * @throws IOException + */ + public int readUI8() throws IOException { + return read(); + } - /** - * Reads one UI32 (Unsigned 32bit integer) value from the stream - * - * @return UI32 value - * @throws IOException - */ - public long readUI32() throws IOException { - return (read() + (read() << 8) + (read() << 16) + (read() << 24)) & 0xffffffff; - } + /** + * Reads one string value from the stream + * + * @return String value + * @throws IOException + */ + public String readString() throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int r = 0; + while (true) { + r = read(); + if (r <= 0) { + return new String(baos.toByteArray(), "utf8"); + } + baos.write(r); + } + } - /** - * Reads one UI16 (Unsigned 16bit integer) value from the stream - * - * @return UI16 value - * @throws IOException - */ - public int readUI16() throws IOException { - return read() + (read() << 8); - } + /** + * Reads one UI32 (Unsigned 32bit integer) value from the stream + * + * @return UI32 value + * @throws IOException + */ + public long readUI32() throws IOException { + return (read() + (read() << 8) + (read() << 16) + (read() << 24)) & 0xffffffff; + } - /** - * Reads one SI32 (Signed 32bit integer) value from the stream - * - * @return SI32 value - * @throws IOException - */ - public long readSI32() throws IOException { - long uval = read() + (read() << 8) + (read() << 16) + (read() << 24); - if (uval >= 0x80000000) { - return -(((~uval) & 0xffffffff) + 1); - } else { - return uval; - } - } + /** + * Reads one UI16 (Unsigned 16bit integer) value from the stream + * + * @return UI16 value + * @throws IOException + */ + public int readUI16() throws IOException { + return read() + (read() << 8); + } - /** - * Reads one SI16 (Signed 16bit integer) value from the stream - * - * @return SI16 value - * @throws IOException - */ - public int readSI16() throws IOException { - int uval = read() + (read() << 8); - if (uval >= 0x8000) { - return -(((~uval) & 0xffff) + 1); - } else { - return uval; - } - } + /** + * Reads one SI32 (Signed 32bit integer) value from the stream + * + * @return SI32 value + * @throws IOException + */ + public long readSI32() throws IOException { + long uval = read() + (read() << 8) + (read() << 16) + (read() << 24); + if (uval >= 0x80000000) { + return -(((~uval) & 0xffffffff) + 1); + } else { + return uval; + } + } - /** - * Reads one SI8 (Signed 8bit integer) value from the stream - * - * @return SI8 value - * @throws IOException - */ - public int readSI8() throws IOException { - int uval = read(); - if (uval >= 0x80) { - return -(((~uval) & 0xff) + 1); - } else { - return uval; - } - } + /** + * Reads one SI16 (Signed 16bit integer) value from the stream + * + * @return SI16 value + * @throws IOException + */ + public int readSI16() throws IOException { + int uval = read() + (read() << 8); + if (uval >= 0x8000) { + return -(((~uval) & 0xffff) + 1); + } else { + return uval; + } + } - /** - * Reads one FIXED (Fixed point 16.16) value from the stream - * - * @return FIXED value - * @throws IOException - */ - public double readFIXED() throws IOException { - int afterPoint = readUI16(); - int beforePoint = readUI16(); - return ((double) ((beforePoint << 16) + afterPoint)) / 65536; - } + /** + * Reads one SI8 (Signed 8bit integer) value from the stream + * + * @return SI8 value + * @throws IOException + */ + public int readSI8() throws IOException { + int uval = read(); + if (uval >= 0x80) { + return -(((~uval) & 0xff) + 1); + } else { + return uval; + } + } - /** - * Reads one FIXED8 (Fixed point 8.8) value from the stream - * - * @return FIXED8 value - * @throws IOException - */ - public float readFIXED8() throws IOException { - int afterPoint = read(); - int beforePoint = read(); - return beforePoint + (((float) afterPoint) / 256); - } + /** + * Reads one FIXED (Fixed point 16.16) value from the stream + * + * @return FIXED value + * @throws IOException + */ + public double readFIXED() throws IOException { + int afterPoint = readUI16(); + int beforePoint = readUI16(); + return ((double) ((beforePoint << 16) + afterPoint)) / 65536; + } - private long readLong() throws IOException { - byte readBuffer[] = readBytes(8); - return (((long) readBuffer[3] << 56) + - ((long) (readBuffer[2] & 255) << 48) + - ((long) (readBuffer[1] & 255) << 40) + - ((long) (readBuffer[0] & 255) << 32) + - ((long) (readBuffer[7] & 255) << 24) + - ((readBuffer[6] & 255) << 16) + - ((readBuffer[5] & 255) << 8) + - ((readBuffer[4] & 255) << 0)); - } + /** + * Reads one FIXED8 (Fixed point 8.8) value from the stream + * + * @return FIXED8 value + * @throws IOException + */ + public float readFIXED8() throws IOException { + int afterPoint = read(); + int beforePoint = read(); + return beforePoint + (((float) afterPoint) / 256); + } - /** - * Reads one DOUBLE (double precision floating point value) value from the stream - * - * @return DOUBLE value - * @throws IOException - */ - public double readDOUBLE() throws IOException { - long el = readLong(); - double ret = Double.longBitsToDouble(el); - return ret; - } + private long readLong() throws IOException { + byte readBuffer[] = readBytes(8); + return (((long) readBuffer[3] << 56) + + ((long) (readBuffer[2] & 255) << 48) + + ((long) (readBuffer[1] & 255) << 40) + + ((long) (readBuffer[0] & 255) << 32) + + ((long) (readBuffer[7] & 255) << 24) + + ((readBuffer[6] & 255) << 16) + + ((readBuffer[5] & 255) << 8) + + ((readBuffer[4] & 255) << 0)); + } - /** - * Reads one FLOAT (single precision floating point value) value from the stream - * - * @return FLOAT value - * @throws IOException - */ - public float readFLOAT() throws IOException { - int val = (int) readUI32(); - float ret = Float.intBitsToFloat(val); - /*int sign = val >> 31; - int mantisa = val & 0x3FFFFF; - int exp = (val >> 22) & 0xFF; - float ret =(sign == 1 ? -1 : 1) * (float) Math.pow(2, exp)* (1+((mantisa)/ (float)(1<<23)));*/ - return ret; - } + /** + * Reads one DOUBLE (double precision floating point value) value from the + * stream + * + * @return DOUBLE value + * @throws IOException + */ + public double readDOUBLE() throws IOException { + long el = readLong(); + double ret = Double.longBitsToDouble(el); + return ret; + } - /** - * Reads one FLOAT16 (16bit floating point value) value from the stream - * - * @return FLOAT16 value - * @throws IOException - */ - public float readFLOAT16() throws IOException { - int val = readUI16(); - int sign = val >> 15; - int mantisa = val & 0x3FF; - int exp = (val >> 10) & 0x1F; - float ret = (sign == 1 ? -1 : 1) * (float) Math.pow(2, exp) * (1 + ((mantisa) / (float) (1 << 10))); - return ret; - } + /** + * Reads one FLOAT (single precision floating point value) value from the + * stream + * + * @return FLOAT value + * @throws IOException + */ + public float readFLOAT() throws IOException { + int val = (int) readUI32(); + float ret = Float.intBitsToFloat(val); + /*int sign = val >> 31; + int mantisa = val & 0x3FFFFF; + int exp = (val >> 22) & 0xFF; + float ret =(sign == 1 ? -1 : 1) * (float) Math.pow(2, exp)* (1+((mantisa)/ (float)(1<<23)));*/ + return ret; + } + /** + * Reads one FLOAT16 (16bit floating point value) value from the stream + * + * @return FLOAT16 value + * @throws IOException + */ + public float readFLOAT16() throws IOException { + int val = readUI16(); + int sign = val >> 15; + int mantisa = val & 0x3FF; + int exp = (val >> 10) & 0x1F; + float ret = (sign == 1 ? -1 : 1) * (float) Math.pow(2, exp) * (1 + ((mantisa) / (float) (1 << 10))); + return ret; + } - /** - * Reads bytes from the stream - * - * @param count Number of bytes to read - * @return Array of read bytes - * @throws IOException - */ - public byte[] readBytes(long count) throws IOException { - if(count<=0) return new byte[0]; - byte ret[] = new byte[(int) count]; - for (int i = 0; i < count; i++) { - ret[i] = (byte) read(); - } - return ret; - } + /** + * Reads bytes from the stream + * + * @param count Number of bytes to read + * @return Array of read bytes + * @throws IOException + */ + public byte[] readBytes(long count) throws IOException { + if (count <= 0) { + return new byte[0]; + } + byte ret[] = new byte[(int) count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } + /** + * Reads one EncodedU32 (Encoded unsigned 32bit value) value from the stream + * + * @return U32 value + * @throws IOException + */ + public long readEncodedU32() throws IOException { + int result = read(); + if ((result & 0x00000080) == 0) { + return result; + } + result = (result & 0x0000007f) | (read()) << 7; + if ((result & 0x00004000) == 0) { + return result; + } + result = (result & 0x00003fff) | (read()) << 14; + if ((result & 0x00200000) == 0) { + return result; + } + result = (result & 0x001fffff) | (read()) << 21; + if ((result & 0x10000000) == 0) { + return result; + } + result = (result & 0x0fffffff) | (read()) << 28; + return result; + } + private int bitPos = 0; + private int tempByte = 0; - /** - * Reads one EncodedU32 (Encoded unsigned 32bit value) value from the stream - * - * @return U32 value - * @throws IOException - */ - public long readEncodedU32() throws IOException { - int result = read(); - if ((result & 0x00000080) == 0) { - return result; - } - result = (result & 0x0000007f) | (read()) << 7; - if ((result & 0x00004000) == 0) { - return result; - } - result = (result & 0x00003fff) | (read()) << 14; - if ((result & 0x00200000) == 0) { - return result; - } - result = (result & 0x001fffff) | (read()) << 21; - if ((result & 0x10000000) == 0) { - return result; - } - result = (result & 0x0fffffff) | (read()) << 28; - return result; - } - - private int bitPos = 0; - private int tempByte = 0; - - /** - * Reads UB[nBits] (Unsigned-bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Unsigned value - * @throws IOException - */ - public long readUB(int nBits) throws IOException { - if (nBits == 0) return 0; - long ret = 0; - if (bitPos == 0) { - tempByte = readNoBitReset(); - } - for (int bit = 0; bit < nBits; bit++) { - int nb = (tempByte >> (7 - bitPos)) & 1; - ret = ret + (nb << (nBits - 1 - bit)); - bitPos++; - if (bitPos == 8) { - bitPos = 0; - if (bit != nBits - 1) { - tempByte = readNoBitReset(); - } + /** + * Reads UB[nBits] (Unsigned-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Unsigned value + * @throws IOException + */ + public long readUB(int nBits) throws IOException { + if (nBits == 0) { + return 0; + } + long ret = 0; + if (bitPos == 0) { + tempByte = readNoBitReset(); + } + for (int bit = 0; bit < nBits; bit++) { + int nb = (tempByte >> (7 - bitPos)) & 1; + ret = ret + (nb << (nBits - 1 - bit)); + bitPos++; + if (bitPos == 8) { + bitPos = 0; + if (bit != nBits - 1) { + tempByte = readNoBitReset(); } - } - return ret; - } + } + } + return ret; + } - /** - * Reads SB[nBits] (Signed-bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Signed value - * @throws IOException - */ - public long readSB(int nBits) throws IOException { - int uval = (int)readUB(nBits); + /** + * Reads SB[nBits] (Signed-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Signed value + * @throws IOException + */ + public long readSB(int nBits) throws IOException { + int uval = (int) readUB(nBits); - int shift = 32-nBits; - // sign extension - uval = (uval << shift) >> shift; - return uval; - } + int shift = 32 - nBits; + // sign extension + uval = (uval << shift) >> shift; + return uval; + } + /** + * Reads FB[nBits] (Signed fixed-point bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Fixed-point value + * @throws IOException + */ + public double readFB(int nBits) throws IOException { - /** - * Reads FB[nBits] (Signed fixed-point bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Fixed-point value - * @throws IOException - */ - public double readFB(int nBits) throws IOException { + double val = readSB(nBits); + double ret = val / (1 << 16); + return ret; + } - double val = readSB(nBits); - double ret = val / (1 << 16); - return ret; - } + /** + * Reads one RECT value from the stream + * + * @return RECT value + * @throws IOException + */ + public RECT readRECT() throws IOException { + RECT ret = new RECT(); + int NBits = (int) readUB(5); + ret.Xmin = (int) readSB(NBits); + ret.Xmax = (int) readSB(NBits); + ret.Ymin = (int) readSB(NBits); + ret.Ymax = (int) readSB(NBits); + return ret; + } - /** - * Reads one RECT value from the stream - * - * @return RECT value - * @throws IOException - */ - public RECT readRECT() throws IOException { - RECT ret = new RECT(); - int NBits = (int) readUB(5); - ret.Xmin = (int) readSB(NBits); - ret.Xmax = (int) readSB(NBits); - ret.Ymin = (int) readSB(NBits); - ret.Ymax = (int) readSB(NBits); - return ret; - } + /** + * Reads list of actions from the stream. Reading ends with ActionEndFlag(=0) + * or end of the stream. + * + * @return List of actions + * @throws IOException + */ + public List readActionList() throws IOException { + List ret = new ArrayList(); + Action a; + while ((a = readAction()) != null) { + ret.add(a); + } + return ret; + } - /** - * Reads list of actions from the stream. Reading ends with ActionEndFlag(=0) or end of the stream. - * - * @return List of actions - * @throws IOException - */ - public List readActionList() throws IOException { - List ret = new ArrayList(); - Action a; - while ((a = readAction()) != null) { - ret.add(a); - } - return ret; - } - - private static void dumpTag(PrintStream out, int version, Tag tag, int level) { - StringBuilder sb = new StringBuilder(); - sb.append(Helper.formatHex((int)tag.getPos(), 8)); - sb.append(": "); - sb.append(Helper.indent(level, "")); - sb.append(Helper.format(tag.toString(), 25 - 2*level)); - sb.append(" tagId="); - sb.append(Helper.formatInt(tag.getId(), 3)); - sb.append(" len="); - sb.append(Helper.formatInt((int)tag.getOrigDataLength(), 8)); - sb.append(" "); - sb.append(Helper.bytesToHexString(64, tag.getData(version), 0)); - out.println(sb.toString()); + private static void dumpTag(PrintStream out, int version, Tag tag, int level) { + StringBuilder sb = new StringBuilder(); + sb.append(Helper.formatHex((int) tag.getPos(), 8)); + sb.append(": "); + sb.append(Helper.indent(level, "")); + sb.append(Helper.format(tag.toString(), 25 - 2 * level)); + sb.append(" tagId="); + sb.append(Helper.formatInt(tag.getId(), 3)); + sb.append(" len="); + sb.append(Helper.formatInt((int) tag.getOrigDataLength(), 8)); + sb.append(" "); + sb.append(Helper.bytesToHexString(64, tag.getData(version), 0)); + out.println(sb.toString()); // out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0)); - if (tag.hasSubTags()) { - for (Tag subTag: tag.getSubTags()) { - dumpTag(out, version, subTag, level + 1); - } - } - } + if (tag.hasSubTags()) { + for (Tag subTag : tag.getSubTags()) { + dumpTag(out, version, subTag, level + 1); + } + } + } - /** - * Reads list of tags from the stream. Reading ends with End tag(=0) or end of the stream. - * - * @return List of tags - * @throws IOException - */ - public List readTagList(int level) throws IOException { - List tags = new ArrayList(); - Tag tag; - while (true) { - long pos = getPos(); - tag = readTag(level, pos); - if (tag == null) { - break; - } - tags.add(tag); - if (Main.dump_tags && level == 0) { - dumpTag(System.out, version, tag, level); - } - } - return tags; - } + /** + * Reads list of tags from the stream. Reading ends with End tag(=0) or end + * of the stream. + * + * @return List of tags + * @throws IOException + */ + public List readTagList(int level) throws IOException { + List tags = new ArrayList(); + Tag tag; + while (true) { + long pos = getPos(); + tag = readTag(level, pos); + if (tag == null) { + break; + } + tags.add(tag); + if (Main.dump_tags && level == 0) { + dumpTag(System.out, version, tag, level); + } + } + return tags; + } - /** - * Reads one Tag from the stream - * - * @return Tag or null when End tag - * @throws IOException - */ - public Tag readTag(int level, long pos) throws IOException { - int tagIDTagLength = readUI16(); - int tagID = (tagIDTagLength) >> 6; - if (tagID == 0) { + /** + * Reads one Tag from the stream + * + * @return Tag or null when End tag + * @throws IOException + */ + public Tag readTag(int level, long pos) throws IOException { + int tagIDTagLength = readUI16(); + int tagID = (tagIDTagLength) >> 6; + if (tagID == 0) { + return null; + } + long tagLength = (tagIDTagLength & 0x003F); + boolean readLong = false; + if (tagLength == 0x3f) { + tagLength = readSI32(); + readLong = true; + } + byte data[] = readBytes((int) tagLength); + Tag ret; + switch (tagID) { + case 82: + ret = new DoABCTag(data, version, pos); + break; + case 12: + ret = new DoActionTag(data, version, pos); + break; + case 59: + ret = new DoInitActionTag(data, version, pos); + break; + case 39: + ret = new DefineSpriteTag(data, version, level, pos); + break; + case 1: + ret = new ShowFrameTag(pos); + break; + case 26: + ret = new PlaceObject2Tag(data, version, pos); + break; + case 56: + ret = new ExportAssetsTag(data, version, pos); + break; + case 70: + ret = new PlaceObject3Tag(data, version, pos); + break; + case 7: + ret = new DefineButtonTag(data, version, pos); + break; + case 34: + ret = new DefineButton2Tag(data, version, pos); + break; + case 69: + ret = new FileAttributes(data, version, pos); + break; + case 77: + ret = new Metadata(data, pos); + break; + case 65: + ret = new ScriptLimits(data, version, pos); + break; + case 9: + ret = new SetBackgroundColor(data, pos); + break; + case 41: + ret = new ProductInfo(data, version, pos); + break; + case 43: + ret = new FrameLabel(data, version, pos); + break; + case 36: + ret = new DefineBitsLossless2(data, version, pos); + break; + case 76: + ret = new SymbolClass(data, version, pos); + break; + case 32: + ret = new DefineShape3(data, version, pos); + break; + case 28: + ret = new RemoveObject2(data, version, pos); + break; + case 78: + ret = new DefineScalingGrid(data, version, pos); + break; + case 2: + ret = new DefineShape(data, version, pos); + break; + case 22: + ret = new DefineShape2(data, version, pos); + break; + case 83: + ret = new DefineShape4(data, version, pos); + break; + case 20: + ret = new DefineBitsLossless(data, version, pos); + break; + case 35: + ret = new DefineBitsJPEG3(data, version, pos); + break; + case 87: + ret = new DefineBinaryData(data, version, pos); + break; + case 8: + ret = new JPEGTables(data, pos); + break; + case 6: + ret = new DefineBits(data, version, pos); + break; + case 21: + ret = new DefineBitsJPEG2(data, version, pos); + break; + case 75: + ret = new DefineFont3(data, version, pos); + break; + case 73: + ret = new DefineFontAlignZones(data, version, pos); + break; + case 88: + ret = new DefineFontName(data, version, pos); + break; + case 91: + ret = new DefineFont4(data, version, pos); + break; + default: + ret = new Tag(tagID, data, pos); + } + ret.forceWriteAsLong = readLong; + return ret; + } + + /** + * Reads one Action from the stream + * + * @return Action or null when ActionEndFlag or end of the stream + * @throws IOException + */ + public Action readAction() throws IOException { + { + int actionCode = readUI8(); + if (actionCode == 0) { return null; - } - long tagLength = (tagIDTagLength & 0x003F); - boolean readLong = false; - if (tagLength == 0x3f) { - tagLength = readSI32(); - readLong = true; - } - byte data[] = readBytes((int) tagLength); - Tag ret; - switch (tagID) { - case 82: - ret = new DoABCTag(data, version, pos); - break; - case 12: - ret = new DoActionTag(data, version, pos); - break; - case 59: - ret = new DoInitActionTag(data, version, pos); - break; - case 39: - ret = new DefineSpriteTag(data, version, level, pos); - break; - case 1: - ret = new ShowFrameTag(pos); - break; - case 26: - ret = new PlaceObject2Tag(data, version, pos); - break; - case 56: - ret = new ExportAssetsTag(data, version, pos); - break; - case 70: - ret = new PlaceObject3Tag(data, version, pos); - break; - case 7: - ret = new DefineButtonTag(data, version, pos); - break; - case 34: - ret = new DefineButton2Tag(data, version, pos); - break; - case 69: - ret = new FileAttributes(data, version, pos); - break; - case 77: - ret = new Metadata(data, pos); - break; - case 65: - ret = new ScriptLimits(data, version, pos); - break; - case 9: - ret = new SetBackgroundColor(data, pos); - break; - case 41: - ret = new ProductInfo(data, version, pos); - break; - case 43: - ret = new FrameLabel(data, version, pos); - break; - case 36: - ret = new DefineBitsLossless2(data, version, pos); - break; - case 76: - ret = new SymbolClass(data, version, pos); - break; - case 32: - ret = new DefineShape3(data, version, pos); - break; - case 28: - ret = new RemoveObject2(data, version, pos); - break; - case 78: - ret = new DefineScalingGrid(data, version, pos); - break; - case 2: - ret = new DefineShape(data, version, pos); - break; - case 22: - ret = new DefineShape2(data, version, pos); - break; - case 83: - ret = new DefineShape4(data, version, pos); - break; - case 20: - ret = new DefineBitsLossless(data, version, pos); - break; - case 35: - ret = new DefineBitsJPEG3(data, version, pos); - break; - case 87: - ret = new DefineBinaryData(data, version, pos); - break; - case 8: - ret = new JPEGTables(data, pos); - break; - case 6: - ret = new DefineBits(data, version, pos); - break; - case 21: - ret = new DefineBitsJPEG2(data, version, pos); - break; - case 75: - ret = new DefineFont3(data, version, pos); - break; - case 73: - ret = new DefineFontAlignZones(data, version, pos); - break; - case 88: - ret = new DefineFontName(data, version, pos); - break; - case 91: - ret = new DefineFont4(data, version, pos); - break; + } + if (actionCode == -1) { + return null; + } + int actionLength = 0; + if (actionCode >= 0x80) { + actionLength = readUI16(); + } + switch (actionCode) { + //SWF3 Actions + case 0x81: + return new ActionGotoFrame(this); + case 0x83: + return new ActionGetURL(actionLength, this, version); + case 0x04: + return new ActionNextFrame(); + case 0x05: + return new ActionPrevFrame(); + case 0x06: + return new ActionPlay(); + case 0x07: + return new ActionStop(); + case 0x08: + return new ActionToggleQuality(); + case 0x09: + return new ActionStopSounds(); + case 0x8A: + return new ActionWaitForFrame(this); + case 0x8B: + return new ActionSetTarget(actionLength, this, version); + case 0x8C: + return new ActionGoToLabel(actionLength, this, version); + //SWF4 Actions + case 0x96: + return new ActionPush(actionLength, this, version); + case 0x17: + return new ActionPop(); + case 0x0A: + return new ActionAdd(); + case 0x0B: + return new ActionSubtract(); + case 0x0C: + return new ActionMultiply(); + case 0x0D: + return new ActionDivide(); + case 0x0E: + return new ActionEquals(); + case 0x0F: + return new ActionLess(); + case 0x10: + return new ActionAnd(); + case 0x11: + return new ActionOr(); + case 0x12: + return new ActionNot(); + case 0x13: + return new ActionStringEquals(); + case 0x14: + return new ActionStringLength(); + case 0x21: + return new ActionStringAdd(); + case 0x15: + return new ActionStringExtract(); + case 0x29: + return new ActionStringLess(); + case 0x31: + return new ActionMBStringLength(); + case 0x35: + return new ActionMBStringExtract(); + case 0x18: + return new ActionToInteger(); + case 0x32: + return new ActionCharToAscii(); + case 0x33: + return new ActionAsciiToChar(); + case 0x36: + return new ActionMBCharToAscii(); + case 0x37: + return new ActionMBAsciiToChar(); + case 0x99: + return new ActionJump(this); + case 0x9D: + return new ActionIf(this); + case 0x9E: + return new ActionCall(); + case 0x1C: + return new ActionGetVariable(); + case 0x1D: + return new ActionSetVariable(); + case 0x9A: + return new ActionGetURL2(this); + case 0x9F: + return new ActionGotoFrame2(actionLength, this); + case 0x20: + return new ActionSetTarget2(); + case 0x22: + return new ActionGetProperty(); + case 0x23: + return new ActionSetProperty(); + case 0x24: + return new ActionCloneSprite(); + case 0x25: + return new ActionRemoveSprite(); + case 0x27: + return new ActionStartDrag(); + case 0x28: + return new ActionEndDrag(); + case 0x8D: + return new ActionWaitForFrame2(this); + case 0x26: + return new ActionTrace(); + case 0x34: + return new ActionGetTime(); + case 0x30: + return new ActionRandomNumber(); + //SWF5 Actions + case 0x3D: + return new ActionCallFunction(); + case 0x52: + return new ActionCallMethod(); + case 0x88: + return new ActionConstantPool(actionLength, this, version); + case 0x9B: + return new ActionDefineFunction(actionLength, this, version); + case 0x3C: + return new ActionDefineLocal(); + case 0x41: + return new ActionDefineLocal2(); + case 0x3A: + return new ActionDelete(); + case 0x3B: + return new ActionDelete2(); + case 0x46: + return new ActionEnumerate(); + case 0x49: + return new ActionEquals2(); + case 0x4E: + return new ActionGetMember(); + case 0x42: + return new ActionInitArray(); + case 0x43: + return new ActionInitObject(); + case 0x53: + return new ActionNewMethod(); + case 0x40: + return new ActionNewObject(); + case 0x4F: + return new ActionSetMember(); + case 0x45: + return new ActionTargetPath(); + case 0x94: + return new ActionWith(this, version); + case 0x4A: + return new ActionToNumber(); + case 0x4B: + return new ActionToString(); + case 0x44: + return new ActionTypeOf(); + case 0x47: + return new ActionAdd2(); + case 0x48: + return new ActionLess2(); + case 0x3F: + return new ActionModulo(); + case 0x60: + return new ActionBitAnd(); + case 0x63: + return new ActionBitLShift(); + case 0x61: + return new ActionBitOr(); + case 0x64: + return new ActionBitRShift(); + case 0x65: + return new ActionBitURShift(); + case 0x62: + return new ActionBitXor(); + case 0x51: + return new ActionDecrement(); + case 0x50: + return new ActionIncrement(); + case 0x4C: + return new ActionPushDuplicate(); + case 0x3E: + return new ActionReturn(); + case 0x4D: + return new ActionStackSwap(); + case 0x87: + return new ActionStoreRegister(this); + //SWF6 Actions + case 0x54: + return new ActionInstanceOf(); + case 0x55: + return new ActionEnumerate2(); + case 0x66: + return new ActionStrictEquals(); + case 0x67: + return new ActionGreater(); + case 0x68: + return new ActionStringGreater(); + //SWF7 Actions + case 0x8E: + return new ActionDefineFunction2(actionLength, this, version); + case 0x69: + return new ActionExtends(); + case 0x2B: + return new ActionCastOp(); + case 0x2C: + return new ActionImplementsOp(); + case 0x8F: + return new ActionTry(actionLength, this, version); + case 0x2A: + return new ActionThrow(); default: - ret = new Tag(tagID, data, pos); - } - ret.forceWriteAsLong = readLong; - return ret; - } + if (actionLength > 0) { + skip(actionLength); + } + return new Action(actionCode, actionLength); + } + } + } - /** - * Reads one Action from the stream - * - * @return Action or null when ActionEndFlag or end of the stream - * @throws IOException - */ - public Action readAction() throws IOException { - { - int actionCode = readUI8(); - if (actionCode == 0) return null; - if (actionCode == -1) return null; - int actionLength = 0; - if (actionCode >= 0x80) { - actionLength = readUI16(); + /** + * Reads one MATRIX value from the stream + * + * @return MATRIX value + * @throws IOException + */ + public MATRIX readMatrix() throws IOException { + MATRIX ret = new MATRIX(); + ret.hasScale = readUB(1) == 1; + if (ret.hasScale) { + int NScaleBits = (int) readUB(5); + ret.scaleNBits = NScaleBits; + + ret.scaleX = readFB(NScaleBits); + ret.scaleY = readFB(NScaleBits); + } + ret.hasRotate = readUB(1) == 1; + if (ret.hasRotate) { + int NRotateBits = (int) readUB(5); + ret.rotateNBits = NRotateBits; + ret.rotateSkew0 = readFB(NRotateBits); + ret.rotateSkew1 = readFB(NRotateBits); + } + int NTranslateBits = (int) readUB(5); + ret.translateNBits = NTranslateBits; + ret.translateX = (int) readSB(NTranslateBits); + ret.translateY = (int) readSB(NTranslateBits); + alignByte(); + return ret; + } + + /** + * Reads one CXFORMWITHALPHA value from the stream + * + * @return CXFORMWITHALPHA value + * @throws IOException + */ + public CXFORMWITHALPHA readCXFORMWITHALPHA() throws IOException { + CXFORMWITHALPHA ret = new CXFORMWITHALPHA(); + ret.hasAddTerms = readUB(1) == 1; + ret.hasMultTerms = readUB(1) == 1; + int Nbits = (int) readUB(4); + ret.nbits = Nbits; + if (ret.hasMultTerms) { + ret.redMultTerm = (int) readSB(Nbits); + ret.greenMultTerm = (int) readSB(Nbits); + ret.blueMultTerm = (int) readSB(Nbits); + ret.alphaMultTerm = (int) readSB(Nbits); + } + if (ret.hasAddTerms) { + ret.redAddTerm = (int) readSB(Nbits); + ret.greenAddTerm = (int) readSB(Nbits); + ret.blueAddTerm = (int) readSB(Nbits); + ret.alphaAddTerm = (int) readSB(Nbits); + } + alignByte(); + return ret; + } + + /** + * Reads one CLIPEVENTFLAGS value from the stream + * + * @return CLIPEVENTFLAGS value + * @throws IOException + */ + public CLIPEVENTFLAGS readCLIPEVENTFLAGS() throws IOException { + CLIPEVENTFLAGS ret = new CLIPEVENTFLAGS(); + ret.clipEventKeyUp = readUB(1) == 1; + ret.clipEventKeyDown = readUB(1) == 1; + ret.clipEventMouseUp = readUB(1) == 1; + ret.clipEventMouseDown = readUB(1) == 1; + ret.clipEventMouseMove = readUB(1) == 1; + ret.clipEventUnload = readUB(1) == 1; + ret.clipEventEnterFrame = readUB(1) == 1; + ret.clipEventLoad = readUB(1) == 1; + ret.clipEventDragOver = readUB(1) == 1; + ret.clipEventRollOut = readUB(1) == 1; + ret.clipEventRollOver = readUB(1) == 1; + ret.clipEventReleaseOutside = readUB(1) == 1; + ret.clipEventRelease = readUB(1) == 1; + ret.clipEventPress = readUB(1) == 1; + ret.clipEventInitialize = readUB(1) == 1; + ret.clipEventData = readUB(1) == 1; + if (version >= 6) { + readUB(5); + ret.clipEventConstruct = readUB(1) == 1; + ret.clipEventKeyPress = readUB(1) == 1; + ret.clipEventDragOut = readUB(1) == 1; + readUB(8); + } + return ret; + } + + /** + * Reads one CLIPACTIONRECORD value from the stream + * + * @return CLIPACTIONRECORD value + * @throws IOException + */ + public CLIPACTIONRECORD readCLIPACTIONRECORD() throws IOException { + CLIPACTIONRECORD ret = new CLIPACTIONRECORD(); + ret.eventFlags = readCLIPEVENTFLAGS(); + if (ret.eventFlags.isClear()) { + return null; + } + long actionRecordSize = readUI32(); + if (ret.eventFlags.clipEventKeyPress) { + ret.keyCode = readUI8(); + actionRecordSize--; + } + ret.actionBytes = readBytes(actionRecordSize); + //ret.actions = (new SWFInputStream(new ByteArrayInputStream(readBytes(actionRecordSize)), version)).readActionList(); + return ret; + } + + /** + * Reads one CLIPACTIONS value from the stream + * + * @return CLIPACTIONS value + * @throws IOException + */ + public CLIPACTIONS readCLIPACTIONS() throws IOException { + CLIPACTIONS ret = new CLIPACTIONS(); + readUI16();//reserved + ret.allEventFlags = readCLIPEVENTFLAGS(); + CLIPACTIONRECORD cr; + ret.clipActionRecords = new ArrayList(); + while ((cr = readCLIPACTIONRECORD()) != null) { + ret.clipActionRecords.add(cr); + } + return ret; + } + + /** + * Reads one COLORMATRIXFILTER value from the stream + * + * @return COLORMATRIXFILTER value + * @throws IOException + */ + public COLORMATRIXFILTER readCOLORMATRIXFILTER() throws IOException { + COLORMATRIXFILTER ret = new COLORMATRIXFILTER(); + ret.matrix = new float[20]; + for (int i = 0; i < 20; i++) { + ret.matrix[i] = readFLOAT(); + } + return ret; + } + + /** + * Reads one RGBA value from the stream + * + * @return RGBA value + * @throws IOException + */ + public RGBA readRGBA() throws IOException { + RGBA ret = new RGBA(); + ret.red = readUI8(); + ret.green = readUI8(); + ret.blue = readUI8(); + ret.alpha = readUI8(); + return ret; + } + + /** + * Reads one CONVOLUTIONFILTER value from the stream + * + * @return CONVOLUTIONFILTER value + * @throws IOException + */ + public CONVOLUTIONFILTER readCONVOLUTIONFILTER() throws IOException { + CONVOLUTIONFILTER ret = new CONVOLUTIONFILTER(); + ret.matrixX = readUI8(); + ret.matrixY = readUI8(); + ret.divisor = readFLOAT(); + ret.bias = readFLOAT(); + ret.matrix = new float[ret.matrixX][ret.matrixY]; + for (int x = 0; x < ret.matrixX; x++) { + for (int y = 0; y < ret.matrixY; y++) { + ret.matrix[x][y] = readFLOAT(); + } + } + ret.defaultColor = readRGBA(); + readUB(6);//reserved + ret.clamp = readUB(1) == 1; + ret.preserveAlpha = readUB(1) == 1; + return ret; + } + + /** + * Reads one BLURFILTER value from the stream + * + * @return BLURFILTER value + * @throws IOException + */ + public BLURFILTER readBLURFILTER() throws IOException { + BLURFILTER ret = new BLURFILTER(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.passes = (int) readUB(5); + readUB(3); //reserved + return ret; + } + + /** + * Reads one DROPSHADOWFILTER value from the stream + * + * @return DROPSHADOWFILTER value + * @throws IOException + */ + public DROPSHADOWFILTER readDROPSHADOWFILTER() throws IOException { + DROPSHADOWFILTER ret = new DROPSHADOWFILTER(); + ret.dropShadowColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.passes = (int) readUB(5); + return ret; + } + + /** + * Reads one GLOWFILTER value from the stream + * + * @return GLOWFILTER value + * @throws IOException + */ + public GLOWFILTER readGLOWFILTER() throws IOException { + GLOWFILTER ret = new GLOWFILTER(); + ret.glowColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.strength = readFIXED8(); + ret.innerGlow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.passes = (int) readUB(5); + return ret; + } + + /** + * Reads one BEVELFILTER value from the stream + * + * @return BEVELFILTER value + * @throws IOException + */ + public BEVELFILTER readBEVELFILTER() throws IOException { + BEVELFILTER ret = new BEVELFILTER(); + ret.shadowColor = readRGBA(); + ret.highlightColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads one GRADIENTGLOWFILTER value from the stream + * + * @return GRADIENTGLOWFILTER value + * @throws IOException + */ + public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER() throws IOException { + GRADIENTGLOWFILTER ret = new GRADIENTGLOWFILTER(); + int numColors = readUI8(); + ret.gradientColors = new RGBA[numColors]; + ret.gradientRatio = new int[numColors]; + for (int i = 0; i < numColors; i++) { + ret.gradientColors[i] = readRGBA(); + } + for (int i = 0; i < numColors; i++) { + ret.gradientRatio[i] = readUI8(); + } + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads one GRADIENTBEVELFILTER value from the stream + * + * @return GRADIENTBEVELFILTER value + * @throws IOException + */ + public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER() throws IOException { + GRADIENTBEVELFILTER ret = new GRADIENTBEVELFILTER(); + int numColors = readUI8(); + ret.gradientColors = new RGBA[numColors]; + ret.gradientRatio = new int[numColors]; + for (int i = 0; i < numColors; i++) { + ret.gradientColors[i] = readRGBA(); + } + for (int i = 0; i < numColors; i++) { + ret.gradientRatio[i] = readUI8(); + } + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads list of FILTER values from the stream + * + * @return List of FILTER values + * @throws IOException + */ + public List readFILTERLIST() throws IOException { + List ret = new ArrayList(); + int numberOfFilters = readUI8(); + for (int i = 0; i < numberOfFilters; i++) { + ret.add(readFILTER()); + } + return ret; + } + + /** + * Reads one FILTER value from the stream + * + * @return FILTER value + * @throws IOException + */ + public FILTER readFILTER() throws IOException { + int filterId = readUI8(); + switch (filterId) { + case 0: + return readDROPSHADOWFILTER(); + case 1: + return readBLURFILTER(); + case 2: + return readGLOWFILTER(); + case 3: + return readBEVELFILTER(); + case 4: + return readGRADIENTGLOWFILTER(); + case 5: + return readCONVOLUTIONFILTER(); + case 6: + return readCOLORMATRIXFILTER(); + case 7: + return readGRADIENTBEVELFILTER(); + default: + return null; + } + } + + /** + * Reads list of BUTTONRECORD values from the stream + * + * @param inDefineButton2 Whether read from inside of DefineButton2Tag or not + * @return List of BUTTONRECORD values + * @throws IOException + */ + public List readBUTTONRECORDList(boolean inDefineButton2) throws IOException { + List ret = new ArrayList(); + BUTTONRECORD br; + while ((br = readBUTTONRECORD(inDefineButton2)) != null) { + ret.add(br); + } + return ret; + } + + /** + * Reads one BUTTONRECORD value from the stream + * + * @return BUTTONRECORD value + * @throws IOException + */ + public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2) throws IOException { + BUTTONRECORD ret = new BUTTONRECORD(); + int res = (int) readUB(2); //reserved + ret.buttonHasBlendMode = readUB(1) == 1; + ret.buttonHasFilterList = readUB(1) == 1; + ret.buttonStateHitTest = readUB(1) == 1; + ret.buttonStateDown = readUB(1) == 1; + ret.buttonStateOver = readUB(1) == 1; + ret.buttonStateUp = readUB(1) == 1; + + if (!ret.buttonHasBlendMode) { + if (!ret.buttonHasFilterList) { + if (!ret.buttonStateHitTest) { + if (!ret.buttonStateDown) { + if (!ret.buttonStateOver) { + if (!ret.buttonStateUp) { + if (res == 0) { + return null; + } + } + } + } } - switch (actionCode) { - //SWF3 Actions - case 0x81: - return new ActionGotoFrame(this); - case 0x83: - return new ActionGetURL(actionLength, this,version); - case 0x04: - return new ActionNextFrame(); - case 0x05: - return new ActionPrevFrame(); - case 0x06: - return new ActionPlay(); - case 0x07: - return new ActionStop(); - case 0x08: - return new ActionToggleQuality(); - case 0x09: - return new ActionStopSounds(); - case 0x8A: - return new ActionWaitForFrame(this); - case 0x8B: - return new ActionSetTarget(actionLength, this,version); - case 0x8C: - return new ActionGoToLabel(actionLength, this,version); - //SWF4 Actions - case 0x96: - return new ActionPush(actionLength, this, version); - case 0x17: - return new ActionPop(); - case 0x0A: - return new ActionAdd(); - case 0x0B: - return new ActionSubtract(); - case 0x0C: - return new ActionMultiply(); - case 0x0D: - return new ActionDivide(); - case 0x0E: - return new ActionEquals(); - case 0x0F: - return new ActionLess(); - case 0x10: - return new ActionAnd(); - case 0x11: - return new ActionOr(); - case 0x12: - return new ActionNot(); - case 0x13: - return new ActionStringEquals(); - case 0x14: - return new ActionStringLength(); - case 0x21: - return new ActionStringAdd(); - case 0x15: - return new ActionStringExtract(); - case 0x29: - return new ActionStringLess(); - case 0x31: - return new ActionMBStringLength(); - case 0x35: - return new ActionMBStringExtract(); - case 0x18: - return new ActionToInteger(); - case 0x32: - return new ActionCharToAscii(); - case 0x33: - return new ActionAsciiToChar(); - case 0x36: - return new ActionMBCharToAscii(); - case 0x37: - return new ActionMBAsciiToChar(); - case 0x99: - return new ActionJump(this); - case 0x9D: - return new ActionIf(this); - case 0x9E: - return new ActionCall(); - case 0x1C: - return new ActionGetVariable(); - case 0x1D: - return new ActionSetVariable(); - case 0x9A: - return new ActionGetURL2(this); - case 0x9F: - return new ActionGotoFrame2(actionLength, this); - case 0x20: - return new ActionSetTarget2(); - case 0x22: - return new ActionGetProperty(); - case 0x23: - return new ActionSetProperty(); - case 0x24: - return new ActionCloneSprite(); - case 0x25: - return new ActionRemoveSprite(); - case 0x27: - return new ActionStartDrag(); - case 0x28: - return new ActionEndDrag(); - case 0x8D: - return new ActionWaitForFrame2(this); - case 0x26: - return new ActionTrace(); - case 0x34: - return new ActionGetTime(); - case 0x30: - return new ActionRandomNumber(); - //SWF5 Actions - case 0x3D: - return new ActionCallFunction(); - case 0x52: - return new ActionCallMethod(); - case 0x88: - return new ActionConstantPool(actionLength, this,version); - case 0x9B: - return new ActionDefineFunction(actionLength, this, version); - case 0x3C: - return new ActionDefineLocal(); - case 0x41: - return new ActionDefineLocal2(); - case 0x3A: - return new ActionDelete(); - case 0x3B: - return new ActionDelete2(); - case 0x46: - return new ActionEnumerate(); - case 0x49: - return new ActionEquals2(); - case 0x4E: - return new ActionGetMember(); - case 0x42: - return new ActionInitArray(); - case 0x43: - return new ActionInitObject(); - case 0x53: - return new ActionNewMethod(); - case 0x40: - return new ActionNewObject(); - case 0x4F: - return new ActionSetMember(); - case 0x45: - return new ActionTargetPath(); - case 0x94: - return new ActionWith(this, version); - case 0x4A: - return new ActionToNumber(); - case 0x4B: - return new ActionToString(); - case 0x44: - return new ActionTypeOf(); - case 0x47: - return new ActionAdd2(); - case 0x48: - return new ActionLess2(); - case 0x3F: - return new ActionModulo(); - case 0x60: - return new ActionBitAnd(); - case 0x63: - return new ActionBitLShift(); - case 0x61: - return new ActionBitOr(); - case 0x64: - return new ActionBitRShift(); - case 0x65: - return new ActionBitURShift(); - case 0x62: - return new ActionBitXor(); - case 0x51: - return new ActionDecrement(); - case 0x50: - return new ActionIncrement(); - case 0x4C: - return new ActionPushDuplicate(); - case 0x3E: - return new ActionReturn(); - case 0x4D: - return new ActionStackSwap(); - case 0x87: - return new ActionStoreRegister(this); - //SWF6 Actions - case 0x54: - return new ActionInstanceOf(); - case 0x55: - return new ActionEnumerate2(); - case 0x66: - return new ActionStrictEquals(); - case 0x67: - return new ActionGreater(); - case 0x68: - return new ActionStringGreater(); - //SWF7 Actions - case 0x8E: - return new ActionDefineFunction2(actionLength, this, version); - case 0x69: - return new ActionExtends(); - case 0x2B: - return new ActionCastOp(); - case 0x2C: - return new ActionImplementsOp(); - case 0x8F: - return new ActionTry(actionLength, this, version); - case 0x2A: - return new ActionThrow(); - default: - if (actionLength > 0) skip(actionLength); - return new Action(actionCode, actionLength); - } - } - } + } + } - /** - * Reads one MATRIX value from the stream - * - * @return MATRIX value - * @throws IOException - */ - public MATRIX readMatrix() throws IOException { - MATRIX ret = new MATRIX(); - ret.hasScale = readUB(1) == 1; - if (ret.hasScale) { - int NScaleBits = (int) readUB(5); - ret.scaleNBits = NScaleBits; - - ret.scaleX = readFB(NScaleBits); - ret.scaleY = readFB(NScaleBits); - } - ret.hasRotate = readUB(1) == 1; - if (ret.hasRotate) { - int NRotateBits = (int) readUB(5); - ret.rotateNBits = NRotateBits; - ret.rotateSkew0 = readFB(NRotateBits); - ret.rotateSkew1 = readFB(NRotateBits); - } - int NTranslateBits = (int) readUB(5); - ret.translateNBits = NTranslateBits; - ret.translateX = (int)readSB(NTranslateBits); - ret.translateY = (int)readSB(NTranslateBits); - alignByte(); - return ret; - } - - /** - * Reads one CXFORMWITHALPHA value from the stream - * - * @return CXFORMWITHALPHA value - * @throws IOException - */ - public CXFORMWITHALPHA readCXFORMWITHALPHA() throws IOException { - CXFORMWITHALPHA ret = new CXFORMWITHALPHA(); - ret.hasAddTerms = readUB(1) == 1; - ret.hasMultTerms = readUB(1) == 1; - int Nbits = (int) readUB(4); - ret.nbits = Nbits; - if (ret.hasMultTerms) { - ret.redMultTerm = (int) readSB(Nbits); - ret.greenMultTerm = (int) readSB(Nbits); - ret.blueMultTerm = (int) readSB(Nbits); - ret.alphaMultTerm = (int) readSB(Nbits); - } - if (ret.hasAddTerms) { - ret.redAddTerm = (int) readSB(Nbits); - ret.greenAddTerm = (int) readSB(Nbits); - ret.blueAddTerm = (int) readSB(Nbits); - ret.alphaAddTerm = (int) readSB(Nbits); - } - alignByte(); - return ret; - } - - /** - * Reads one CLIPEVENTFLAGS value from the stream - * - * @return CLIPEVENTFLAGS value - * @throws IOException - */ - - public CLIPEVENTFLAGS readCLIPEVENTFLAGS() throws IOException { - CLIPEVENTFLAGS ret = new CLIPEVENTFLAGS(); - ret.clipEventKeyUp = readUB(1) == 1; - ret.clipEventKeyDown = readUB(1) == 1; - ret.clipEventMouseUp = readUB(1) == 1; - ret.clipEventMouseDown = readUB(1) == 1; - ret.clipEventMouseMove = readUB(1) == 1; - ret.clipEventUnload = readUB(1) == 1; - ret.clipEventEnterFrame = readUB(1) == 1; - ret.clipEventLoad = readUB(1) == 1; - ret.clipEventDragOver = readUB(1) == 1; - ret.clipEventRollOut = readUB(1) == 1; - ret.clipEventRollOver = readUB(1) == 1; - ret.clipEventReleaseOutside = readUB(1) == 1; - ret.clipEventRelease = readUB(1) == 1; - ret.clipEventPress = readUB(1) == 1; - ret.clipEventInitialize = readUB(1) == 1; - ret.clipEventData = readUB(1) == 1; - if (version >= 6) { - readUB(5); - ret.clipEventConstruct = readUB(1) == 1; - ret.clipEventKeyPress = readUB(1) == 1; - ret.clipEventDragOut = readUB(1) == 1; - readUB(8); - } - return ret; - } - - /** - * Reads one CLIPACTIONRECORD value from the stream - * - * @return CLIPACTIONRECORD value - * @throws IOException - */ - public CLIPACTIONRECORD readCLIPACTIONRECORD() throws IOException { - CLIPACTIONRECORD ret = new CLIPACTIONRECORD(); - ret.eventFlags = readCLIPEVENTFLAGS(); - if (ret.eventFlags.isClear()) return null; - long actionRecordSize = readUI32(); - if (ret.eventFlags.clipEventKeyPress) { - ret.keyCode = readUI8(); - actionRecordSize--; - } - ret.actionBytes=readBytes(actionRecordSize); - //ret.actions = (new SWFInputStream(new ByteArrayInputStream(readBytes(actionRecordSize)), version)).readActionList(); - return ret; - } - - /** - * Reads one CLIPACTIONS value from the stream - * - * @return CLIPACTIONS value - * @throws IOException - */ - public CLIPACTIONS readCLIPACTIONS() throws IOException { - CLIPACTIONS ret = new CLIPACTIONS(); - readUI16();//reserved - ret.allEventFlags = readCLIPEVENTFLAGS(); - CLIPACTIONRECORD cr; - ret.clipActionRecords = new ArrayList(); - while ((cr = readCLIPACTIONRECORD()) != null) { - ret.clipActionRecords.add(cr); - } - return ret; - } - - - /** - * Reads one COLORMATRIXFILTER value from the stream - * - * @return COLORMATRIXFILTER value - * @throws IOException - */ - public COLORMATRIXFILTER readCOLORMATRIXFILTER() throws IOException { - COLORMATRIXFILTER ret = new COLORMATRIXFILTER(); - ret.matrix = new float[20]; - for (int i = 0; i < 20; i++) { - ret.matrix[i] = readFLOAT(); - } - return ret; - } - - /** - * Reads one RGBA value from the stream - * - * @return RGBA value - * @throws IOException - */ - public RGBA readRGBA() throws IOException { - RGBA ret = new RGBA(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - ret.alpha = readUI8(); - return ret; - } - - /** - * Reads one CONVOLUTIONFILTER value from the stream - * - * @return CONVOLUTIONFILTER value - * @throws IOException - */ - public CONVOLUTIONFILTER readCONVOLUTIONFILTER() throws IOException { - CONVOLUTIONFILTER ret = new CONVOLUTIONFILTER(); - ret.matrixX = readUI8(); - ret.matrixY = readUI8(); - ret.divisor = readFLOAT(); - ret.bias = readFLOAT(); - ret.matrix = new float[ret.matrixX][ret.matrixY]; - for (int x = 0; x < ret.matrixX; x++) { - for (int y = 0; y < ret.matrixY; y++) { - ret.matrix[x][y] = readFLOAT(); - } - } - ret.defaultColor = readRGBA(); - readUB(6);//reserved - ret.clamp = readUB(1) == 1; - ret.preserveAlpha = readUB(1) == 1; - return ret; - } - - /** - * Reads one BLURFILTER value from the stream - * - * @return BLURFILTER value - * @throws IOException - */ - public BLURFILTER readBLURFILTER() throws IOException { - BLURFILTER ret = new BLURFILTER(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.passes = (int) readUB(5); - readUB(3); //reserved - return ret; - } - - /** - * Reads one DROPSHADOWFILTER value from the stream - * - * @return DROPSHADOWFILTER value - * @throws IOException - */ - public DROPSHADOWFILTER readDROPSHADOWFILTER() throws IOException { - DROPSHADOWFILTER ret = new DROPSHADOWFILTER(); - ret.dropShadowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); - return ret; - } - - /** - * Reads one GLOWFILTER value from the stream - * - * @return GLOWFILTER value - * @throws IOException - */ - public GLOWFILTER readGLOWFILTER() throws IOException { - GLOWFILTER ret = new GLOWFILTER(); - ret.glowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.strength = readFIXED8(); - ret.innerGlow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); - return ret; - } - - /** - * Reads one BEVELFILTER value from the stream - * - * @return BEVELFILTER value - * @throws IOException - */ - public BEVELFILTER readBEVELFILTER() throws IOException { - BEVELFILTER ret = new BEVELFILTER(); - ret.shadowColor = readRGBA(); - ret.highlightColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - /** - * Reads one GRADIENTGLOWFILTER value from the stream - * - * @return GRADIENTGLOWFILTER value - * @throws IOException - */ - public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER() throws IOException { - GRADIENTGLOWFILTER ret = new GRADIENTGLOWFILTER(); - int numColors = readUI8(); - ret.gradientColors = new RGBA[numColors]; - ret.gradientRatio = new int[numColors]; - for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); - } - for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); - } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - /** - * Reads one GRADIENTBEVELFILTER value from the stream - * - * @return GRADIENTBEVELFILTER value - * @throws IOException - */ - public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER() throws IOException { - GRADIENTBEVELFILTER ret = new GRADIENTBEVELFILTER(); - int numColors = readUI8(); - ret.gradientColors = new RGBA[numColors]; - ret.gradientRatio = new int[numColors]; - for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); - } - for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); - } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - - /** - * Reads list of FILTER values from the stream - * - * @return List of FILTER values - * @throws IOException - */ - public List readFILTERLIST() throws IOException { - List ret = new ArrayList(); - int numberOfFilters = readUI8(); - for (int i = 0; i < numberOfFilters; i++) { - ret.add(readFILTER()); - } - return ret; - } - - /** - * Reads one FILTER value from the stream - * - * @return FILTER value - * @throws IOException - */ - public FILTER readFILTER() throws IOException { - int filterId = readUI8(); - switch (filterId) { - case 0: - return readDROPSHADOWFILTER(); - case 1: - return readBLURFILTER(); - case 2: - return readGLOWFILTER(); - case 3: - return readBEVELFILTER(); - case 4: - return readGRADIENTGLOWFILTER(); - case 5: - return readCONVOLUTIONFILTER(); - case 6: - return readCOLORMATRIXFILTER(); - case 7: - return readGRADIENTBEVELFILTER(); - default: - return null; - } - } - - /** - * Reads list of BUTTONRECORD values from the stream - * - * @param inDefineButton2 Whether read from inside of DefineButton2Tag or not - * @return List of BUTTONRECORD values - * @throws IOException - */ - public List readBUTTONRECORDList(boolean inDefineButton2) throws IOException { - List ret = new ArrayList(); - BUTTONRECORD br; - while ((br = readBUTTONRECORD(inDefineButton2)) != null) { - ret.add(br); - } - return ret; - } - - /** - * Reads one BUTTONRECORD value from the stream - * - * @return BUTTONRECORD value - * @throws IOException - */ - public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2) throws IOException { - BUTTONRECORD ret = new BUTTONRECORD(); - int res = (int) readUB(2); //reserved - ret.buttonHasBlendMode = readUB(1) == 1; - ret.buttonHasFilterList = readUB(1) == 1; - ret.buttonStateHitTest = readUB(1) == 1; - ret.buttonStateDown = readUB(1) == 1; - ret.buttonStateOver = readUB(1) == 1; - ret.buttonStateUp = readUB(1) == 1; - - if (!ret.buttonHasBlendMode) - if (!ret.buttonHasFilterList) - if (!ret.buttonStateHitTest) - if (!ret.buttonStateDown) - if (!ret.buttonStateOver) - if (!ret.buttonStateUp) - if (res == 0) - return null; - - ret.characterId = readUI16(); - ret.placeDepth = readUI16(); - ret.placeMatrix = readMatrix(); - if (inDefineButton2) { - ret.colorTransform = readCXFORMWITHALPHA(); - if (ret.buttonHasFilterList) { - ret.filterList = readFILTERLIST(); - } - if (ret.buttonHasBlendMode) { - ret.blendMode = readUI8(); - } - } - return ret; - } - - /** - * Reads list of BUTTONCONDACTION values from the stream - * - * @return List of BUTTONCONDACTION values - * @throws IOException - */ - public List readBUTTONCONDACTIONList() throws IOException { - List ret = new ArrayList(); - BUTTONCONDACTION bc; - while (!(bc = readBUTTONCONDACTION()).isLast) { - ret.add(bc); - } - ret.add(bc); - return ret; - } - - /** - * Reads one BUTTONCONDACTION value from the stream - * - * @return BUTTONCONDACTION value - * @throws IOException - */ - public BUTTONCONDACTION readBUTTONCONDACTION() throws IOException { - BUTTONCONDACTION ret = new BUTTONCONDACTION(); - int condActionSize = readUI16(); - ret.isLast = condActionSize <= 0; - ret.condIdleToOverDown = readUB(1) == 1; - ret.condOutDownToIdle = readUB(1) == 1; - ret.condOutDownToOverDown = readUB(1) == 1; - ret.condOverDownToOutDown = readUB(1) == 1; - ret.condOverDownToOverUp = readUB(1) == 1; - ret.condOverUpToOverDown = readUB(1) == 1; - ret.condOverUpToIddle = readUB(1) == 1; - ret.condIdleToOverUp = readUB(1) == 1; - ret.condKeyPress = (int) readUB(7); - ret.condOverDownToIddle = readUB(1) == 1; - if(condActionSize<=0){ - ret.actionBytes=readBytes(available()); - }else{ - ret.actionBytes=readBytes(condActionSize-4); - } - //ret.actions = readActionList(); - return ret; - } - - @Override - public int available() throws IOException { - return is.available(); - } + ret.characterId = readUI16(); + ret.placeDepth = readUI16(); + ret.placeMatrix = readMatrix(); + if (inDefineButton2) { + ret.colorTransform = readCXFORMWITHALPHA(); + if (ret.buttonHasFilterList) { + ret.filterList = readFILTERLIST(); + } + if (ret.buttonHasBlendMode) { + ret.blendMode = readUI8(); + } + } + return ret; + } + /** + * Reads list of BUTTONCONDACTION values from the stream + * + * @return List of BUTTONCONDACTION values + * @throws IOException + */ + public List readBUTTONCONDACTIONList() throws IOException { + List ret = new ArrayList(); + BUTTONCONDACTION bc; + while (!(bc = readBUTTONCONDACTION()).isLast) { + ret.add(bc); + } + ret.add(bc); + return ret; + } + /** + * Reads one BUTTONCONDACTION value from the stream + * + * @return BUTTONCONDACTION value + * @throws IOException + */ + public BUTTONCONDACTION readBUTTONCONDACTION() throws IOException { + BUTTONCONDACTION ret = new BUTTONCONDACTION(); + int condActionSize = readUI16(); + ret.isLast = condActionSize <= 0; + ret.condIdleToOverDown = readUB(1) == 1; + ret.condOutDownToIdle = readUB(1) == 1; + ret.condOutDownToOverDown = readUB(1) == 1; + ret.condOverDownToOutDown = readUB(1) == 1; + ret.condOverDownToOverUp = readUB(1) == 1; + ret.condOverUpToOverDown = readUB(1) == 1; + ret.condOverUpToIddle = readUB(1) == 1; + ret.condIdleToOverUp = readUB(1) == 1; + ret.condKeyPress = (int) readUB(7); + ret.condOverDownToIddle = readUB(1) == 1; + if (condActionSize <= 0) { + ret.actionBytes = readBytes(available()); + } else { + ret.actionBytes = readBytes(condActionSize - 4); + } + //ret.actions = readActionList(); + return ret; + } + @Override + public int available() throws IOException { + return is.available(); + } } diff --git a/trunk/src/com/jpexs/asdec/SWFOutputStream.java b/trunk/src/com/jpexs/asdec/SWFOutputStream.java index 872483e66..8f448451e 100644 --- a/trunk/src/com/jpexs/asdec/SWFOutputStream.java +++ b/trunk/src/com/jpexs/asdec/SWFOutputStream.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec; import com.jpexs.asdec.tags.Tag; @@ -31,889 +30,895 @@ import java.util.List; * @author JPEXS */ public class SWFOutputStream extends OutputStream { - private OutputStream os; - private int version; - private long pos = 0; - /** - * Constructor - * - * @param os OutputStream for writing data - * @param version Version of SWF - */ - public SWFOutputStream(OutputStream os, int version) { - this.version = version; - this.os = os; - } + private OutputStream os; + private int version; + private long pos = 0; - /** - * Writes byte to the stream - * - * @param b byte to write - * @throws IOException - */ - @Override - public void write(int b) throws IOException { - alignByte(); - os.write(b); - pos++; - } + /** + * Constructor + * + * @param os OutputStream for writing data + * @param version Version of SWF + */ + public SWFOutputStream(OutputStream os, int version) { + this.version = version; + this.os = os; + } - private void alignByte() throws IOException { - if (bitPos > 0) { + /** + * Writes byte to the stream + * + * @param b byte to write + * @throws IOException + */ + @Override + public void write(int b) throws IOException { + alignByte(); + os.write(b); + pos++; + } + + private void alignByte() throws IOException { + if (bitPos > 0) { + bitPos = 0; + write(tempByte); + tempByte = 0; + } + } + + /** + * Writes UI8 (Unsigned 8bit integer) value to the stream + * + * @param val UI8 value to write + * @throws IOException + */ + public void writeUI8(int val) throws IOException { + write(val); + } + + /** + * Writes String value to the stream + * + * @param value String value + * @throws IOException + */ + public void writeString(String value) throws IOException { + write(value.getBytes("utf8")); + write(0); + } + + /** + * Writes UI32 (Unsigned 32bit integer) value to the stream + * + * @param value UI32 value + * @throws IOException + */ + public void writeUI32(long value) throws IOException { + write((int) (value & 0xff)); + write((int) ((value >> 8) & 0xff)); + write((int) ((value >> 16) & 0xff)); + write((int) ((value >> 24) & 0xff)); + } + + /** + * Writes UI16 (Unsigned 16bit integer) value to the stream + * + * @param value UI16 value + * @throws IOException + */ + public void writeUI16(int value) throws IOException { + write((int) (value & 0xff)); + write((int) ((value >> 8) & 0xff)); + } + + /** + * Writes SI32 (Signed 32bit integer) value to the stream + * + * @param value SI32 value + * @throws IOException + */ + public void writeSI32(long value) throws IOException { + writeUI32(value); + } + + /** + * Writes SI16 (Signed 16bit integer) value to the stream + * + * @param value SI16 value + * @throws IOException + */ + public void writeSI16(int value) throws IOException { + writeUI16(value); + } + + /** + * Writes SI8 (Signed 8bit integer) value to the stream + * + * @param value SI8 value + * @throws IOException + */ + public void writeSI8(int value) throws IOException { + writeUI8(value); + } + + /** + * Writes FIXED (Fixed point 16.16) value to the stream + * + * @param value FIXED value + * @throws IOException + */ + public void writeFIXED(double value) throws IOException { + long valueLong = (long) (value * (1 << 16)); + int beforePoint = (int) valueLong >> 16; + + int afterPoint = (int) valueLong % (1 << 16); + writeUI16(afterPoint); + writeUI16(beforePoint); + } + + /** + * Writes FIXED8 (Fixed point 8.8) value to the stream + * + * @param value FIXED8 value + * @throws IOException + */ + public void writeFIXED8(float value) throws IOException { + int beforePoint = (int) getIntPart(value); + int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256); + writeUI8(afterPoint); + writeUI8(beforePoint); + } + + private void writeLong(long value) throws IOException { + byte writeBuffer[] = new byte[8]; + writeBuffer[3] = (byte) (value >>> 56); + writeBuffer[2] = (byte) (value >>> 48); + writeBuffer[1] = (byte) (value >>> 40); + writeBuffer[0] = (byte) (value >>> 32); + writeBuffer[7] = (byte) (value >>> 24); + writeBuffer[6] = (byte) (value >>> 16); + writeBuffer[5] = (byte) (value >>> 8); + writeBuffer[4] = (byte) (value >>> 0); + write(writeBuffer); + } + + /** + * Writes DOUBLE (double precision floating point value) value to the stream + * + * @param value DOUBLE value + * @throws IOException + */ + public void writeDOUBLE(double value) throws IOException { + writeLong(Double.doubleToLongBits(value)); + } + + /** + * Writes FLOAT (single precision floating point value) value to the stream + * + * @param value FLOAT value + * @throws IOException + */ + public void writeFLOAT(float value) throws IOException { + writeUI32(Float.floatToIntBits(value)); + } + + /** + * Writes FLOAT16 (16bit floating point value) value to the stream + * + * @param value FLOAT16 value + * @throws IOException + */ + public void writeFLOAT16(float value) throws IOException { + int bits = Float.floatToRawIntBits(value); + int sign = bits >> 31; + int exponent = (bits >> 22) & 0xff; + int mantisa = bits & 0x3FFFFF; + mantisa = mantisa >> 13; + writeUI16((sign << 15) + (exponent << 10) + mantisa); + } + + /** + * Writes EncodedU32 (Encoded unsigned 32bit value) value to the stream + * + * @param value U32 value + * @throws IOException + */ + public void writeEncodedU32(long value) throws IOException { + boolean loop = true; + value = value & 0xFFFFFFFF; + do { + int ret = (int) (value & 0x7F); + if (value < 0x80) { + loop = false; + } + if (value > 0x7F) { + ret += 0x80; + } + write(ret); + value = value >> 7; + } while (loop); + } + private int bitPos = 0; + private int tempByte = 0; + + /** + * Flushes data to underlying stream + * + * @throws IOException + */ + @Override + public void flush() throws IOException { + if (bitPos > 0) { + bitPos = 0; + write(tempByte); + tempByte = 0; + } + os.flush(); + } + + /** + * Closes the stream + * + * @throws IOException + */ + @Override + public void close() throws IOException { + flush(); + os.close(); + } + + /** + * Writes UB[nBits] (Unsigned-bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Unsigned value to write + * @throws IOException + */ + public void writeUB(int nBits, long value) throws IOException { + for (int bit = 0; bit < nBits; bit++) { + int nb = (int) ((value >> (nBits - 1 - bit)) & 1); + tempByte += nb * (1 << (7 - bitPos)); + bitPos++; + if (bitPos == 8) { bitPos = 0; write(tempByte); tempByte = 0; - } - } + } + } + } - /** - * Writes UI8 (Unsigned 8bit integer) value to the stream - * - * @param val UI8 value to write - * @throws IOException - */ - public void writeUI8(int val) throws IOException { - write(val); - } + /** + * Writes SB[nBits] (Signed-bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Signed value to write + * @throws IOException + */ + public void writeSB(int nBits, long value) throws IOException { + writeUB(nBits, value); + } - /** - * Writes String value to the stream - * - * @param value String value - * @throws IOException - */ - public void writeString(String value) throws IOException { - write(value.getBytes("utf8")); - write(0); - } + /** + * Writes FB[nBits] (Signed fixed-point bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Double value to write + * @throws IOException + */ + public void writeFB(int nBits, double value) throws IOException { + long longVal = (long) (value * (1 << 16)); + writeSB(nBits, longVal); + } - /** - * Writes UI32 (Unsigned 32bit integer) value to the stream - * - * @param value UI32 value - * @throws IOException - */ - public void writeUI32(long value) throws IOException { - write((int) (value & 0xff)); - write((int) ((value >> 8) & 0xff)); - write((int) ((value >> 16) & 0xff)); - write((int) ((value >> 24) & 0xff)); - } + /** + * Writes RECT value to the stream + * + * @param value RECT value + * @throws IOException + */ + public void writeRECT(RECT value) throws IOException { + int nBits = 0; + nBits = enlargeBitCountS(nBits, value.Xmin); + nBits = enlargeBitCountS(nBits, value.Xmax); + nBits = enlargeBitCountS(nBits, value.Ymin); + nBits = enlargeBitCountS(nBits, value.Ymax); - /** - * Writes UI16 (Unsigned 16bit integer) value to the stream - * - * @param value UI16 value - * @throws IOException - */ - public void writeUI16(int value) throws IOException { - write((int) (value & 0xff)); - write((int) ((value >> 8) & 0xff)); - } + writeUB(5, nBits); + writeSB(nBits, value.Xmin); + writeSB(nBits, value.Xmax); + writeSB(nBits, value.Ymin); + writeSB(nBits, value.Ymax); + } - /** - * Writes SI32 (Signed 32bit integer) value to the stream - * - * @param value SI32 value - * @throws IOException - */ - public void writeSI32(long value) throws IOException { - writeUI32(value); - } - - /** - * Writes SI16 (Signed 16bit integer) value to the stream - * - * @param value SI16 value - * @throws IOException - */ - public void writeSI16(int value) throws IOException { - writeUI16(value); - } - - /** - * Writes SI8 (Signed 8bit integer) value to the stream - * - * @param value SI8 value - * @throws IOException - */ - public void writeSI8(int value) throws IOException { - writeUI8(value); - } - - /** - * Writes FIXED (Fixed point 16.16) value to the stream - * - * @param value FIXED value - * @throws IOException - */ - public void writeFIXED(double value) throws IOException { - long valueLong = (long) (value * (1 << 16)); - int beforePoint = (int) valueLong >> 16; - - int afterPoint = (int) valueLong % (1 << 16); - writeUI16(afterPoint); - writeUI16(beforePoint); - } - - /** - * Writes FIXED8 (Fixed point 8.8) value to the stream - * - * @param value FIXED8 value - * @throws IOException - */ - public void writeFIXED8(float value) throws IOException { - int beforePoint = (int) getIntPart(value); - int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256); - writeUI8(afterPoint); - writeUI8(beforePoint); - } - - private void writeLong(long value) throws IOException { - byte writeBuffer[] = new byte[8]; - writeBuffer[3] = (byte) (value >>> 56); - writeBuffer[2] = (byte) (value >>> 48); - writeBuffer[1] = (byte) (value >>> 40); - writeBuffer[0] = (byte) (value >>> 32); - writeBuffer[7] = (byte) (value >>> 24); - writeBuffer[6] = (byte) (value >>> 16); - writeBuffer[5] = (byte) (value >>> 8); - writeBuffer[4] = (byte) (value >>> 0); - write(writeBuffer); - } - - /** - * Writes DOUBLE (double precision floating point value) value to the stream - * - * @param value DOUBLE value - * @throws IOException - */ - public void writeDOUBLE(double value) throws IOException { - writeLong(Double.doubleToLongBits(value)); - } - - /** - * Writes FLOAT (single precision floating point value) value to the stream - * - * @param value FLOAT value - * @throws IOException - */ - public void writeFLOAT(float value) throws IOException { - writeUI32(Float.floatToIntBits(value)); - } - - /** - * Writes FLOAT16 (16bit floating point value) value to the stream - * - * @param value FLOAT16 value - * @throws IOException - */ - public void writeFLOAT16(float value) throws IOException { - int bits = Float.floatToRawIntBits(value); - int sign = bits >> 31; - int exponent = (bits >> 22) & 0xff; - int mantisa = bits & 0x3FFFFF; - mantisa = mantisa >> 13; - writeUI16((sign << 15) + (exponent << 10) + mantisa); - } - - /** - * Writes EncodedU32 (Encoded unsigned 32bit value) value to the stream - * - * @param value U32 value - * @throws IOException - */ - public void writeEncodedU32(long value) throws IOException { - boolean loop = true; - value = value & 0xFFFFFFFF; - do { - int ret = (int) (value & 0x7F); - if (value < 0x80) { - loop = false; - } - if (value > 0x7F) { - ret += 0x80; - } - write(ret); - value = value >> 7; - } while (loop); - } - - private int bitPos = 0; - private int tempByte = 0; - - /** - * Flushes data to underlying stream - * - * @throws IOException - */ - @Override - public void flush() throws IOException { - if (bitPos > 0) { - bitPos = 0; - write(tempByte); - tempByte = 0; - } - os.flush(); - } - - /** - * Closes the stream - * - * @throws IOException - */ - @Override - public void close() throws IOException { - flush(); - os.close(); - } - - /** - * Writes UB[nBits] (Unsigned-bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Unsigned value to write - * @throws IOException - */ - public void writeUB(int nBits, long value) throws IOException { - for (int bit = 0; bit < nBits; bit++) { - int nb = (int) ((value >> (nBits - 1 - bit)) & 1); - tempByte += nb * (1 << (7 - bitPos)); - bitPos++; - if (bitPos == 8) { - bitPos = 0; - write(tempByte); - tempByte = 0; - } - } - } - - /** - * Writes SB[nBits] (Signed-bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Signed value to write - * @throws IOException - */ - public void writeSB(int nBits, long value) throws IOException { - writeUB(nBits, value); - } - - /** - * Writes FB[nBits] (Signed fixed-point bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Double value to write - * @throws IOException - */ - public void writeFB(int nBits, double value) throws IOException { - long longVal = (long) (value * (1 << 16)); - writeSB(nBits, longVal); - } - - /** - * Writes RECT value to the stream - * - * @param value RECT value - * @throws IOException - */ - public void writeRECT(RECT value) throws IOException { - int nBits = 0; - nBits = enlargeBitCountS(nBits, value.Xmin); - nBits = enlargeBitCountS(nBits, value.Xmax); - nBits = enlargeBitCountS(nBits, value.Ymin); - nBits = enlargeBitCountS(nBits, value.Ymax); - - writeUB(5, nBits); - writeSB(nBits, value.Xmin); - writeSB(nBits, value.Xmax); - writeSB(nBits, value.Ymin); - writeSB(nBits, value.Ymax); - } - - /** - * Writes list of Tag values to the stream - * - * @param tags List of tag values - * @throws IOException - */ - public void writeTags(List tags) throws IOException { - for (Tag tag : tags) { - //try { - writeTag(tag); - /*} catch (NotSameException nse) { - throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse); - }*/ + /** + * Writes list of Tag values to the stream + * + * @param tags List of tag values + * @throws IOException + */ + public void writeTags(List tags) throws IOException { + for (Tag tag : tags) { + //try { + writeTag(tag); + /*} catch (NotSameException nse) { + throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse); + }*/ //NotSameException must be processed in order to catch it elsewhere - } - } + } + } - /** - * Writes Tag value to the stream - * - * @param tag Tag value - * @throws IOException - */ - public void writeTag(Tag tag) throws IOException { - byte data[] = tag.getData(version); - int tagLength = data.length; - int tagID = tag.getId(); - int tagIDLength = (tagID << 6); - if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { - tagIDLength += tagLength; - writeUI16(tagIDLength); - } else { - tagIDLength += 0x3f; - writeUI16(tagIDLength); - writeSI32(tagLength); - } - write(data); - } + /** + * Writes Tag value to the stream + * + * @param tag Tag value + * @throws IOException + */ + public void writeTag(Tag tag) throws IOException { + byte data[] = tag.getData(version); + int tagLength = data.length; + int tagID = tag.getId(); + int tagIDLength = (tagID << 6); + if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { + tagIDLength += tagLength; + writeUI16(tagIDLength); + } else { + tagIDLength += 0x3f; + writeUI16(tagIDLength); + writeSI32(tagLength); + } + write(data); + } + + /** + * Get needed bits + * + * @param number + * @param bits 1 for signed,0 if unsigned + * @return + */ + public static int getNeededBits(int number, int bits) { + number = Math.abs(number); + int val = 1; + for (int x = 1; val <= number && !(bits > 32); x <<= 1) { + val = val | x; + bits++; + } + + if (bits > 32) { + assert false : ("minBits " + bits + " must not exceed 32"); + } + return bits; + } + + /** + * Calculates number of bits needed for representing unsigned value + * + * @param v Unsigned value + * @return Number of bits + */ + public static int getNeededBitsU(int v) { + + return getNeededBits(v, 0); + } + + /** + * Calculates number of bits needed for representing signed value + * + * @param v Signed value + * @return Number of bits + */ + public static int getNeededBitsS(int v) { + return getNeededBits(v, 1); + } + + private static long getIntPart(double value) { + if (value < 0) { + return (long) Math.ceil(value); + } + return (long) Math.floor(value); + } + + private static double getFloatPart(double value) { + if (value < 0) { + return value - getIntPart(value); + } + return value + getIntPart(value); + } + + /** + * Calculates number of bits needed for representing fixed-point value + * + * @param value Fixed-point value + * @return Number of bits + */ + public static int getNeededBitsF(double value) { + if (value == -1) { + return 18; + } + int val = (int) (value * (1 << 16)); + return getNeededBitsS(val); + } + + private int enlargeBitCountU(int currentBitCount, int value) { + int neededNew = getNeededBitsU(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } + + private int enlargeBitCountS(int currentBitCount, int value) { + int neededNew = getNeededBitsS(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } + + private int enlargeBitCountF(int currentBitCount, double value) { + int neededNew = getNeededBitsF(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } + + /** + * Writes MATRIX value to the stream + * + * @param value MATRIX value + * @throws IOException + */ + public void writeMatrix(MATRIX value) throws IOException { + writeUB(1, value.hasScale ? 1 : 0); + if (value.hasScale) { + int nBits = 0; + nBits = enlargeBitCountF(nBits, value.scaleX); + nBits = enlargeBitCountF(nBits, value.scaleY); + nBits = value.scaleNBits; //FFFUUU + writeUB(5, nBits); + writeFB(nBits, value.scaleX); + writeFB(nBits, value.scaleY); + } + writeUB(1, value.hasRotate ? 1 : 0); + if (value.hasRotate) { + int nBits = 0; + nBits = enlargeBitCountF(nBits, value.rotateSkew0); + nBits = enlargeBitCountF(nBits, value.rotateSkew1); + nBits = value.rotateNBits; //FFFUUU + writeUB(5, nBits); + writeFB(nBits, value.rotateSkew0); + writeFB(nBits, value.rotateSkew1); + } + int NTranslateBits = 0; + NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX); + NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY); + NTranslateBits = value.translateNBits; //FFFUUU + writeUB(5, NTranslateBits); - /** - * Get needed bits - * @param number - * @param bits 1 for signed,0 if unsigned - * @return - */ - public static int getNeededBits(int number, int bits) - { - number=Math.abs(number); - int val = 1; - for (int x = 1; val <= number && !(bits > 32); x <<= 1) - { - val = val | x; - bits++; - } + writeSB(NTranslateBits, value.translateX); + writeSB(NTranslateBits, value.translateY); + alignByte(); - if (bits > 32) - { - assert false : ("minBits " + bits + " must not exceed 32"); - } - return bits; - } + } + /** + * Writes CXFORMWITHALPHA value to the stream + * + * @param value CXFORMWITHALPHA value + * @throws IOException + */ + public void writeCXFORMWITHALPHA(CXFORMWITHALPHA value) throws IOException { + writeUB(1, value.hasAddTerms ? 1 : 0); + writeUB(1, value.hasMultTerms ? 1 : 0); + int Nbits = 1; + if (value.hasMultTerms) { + Nbits = enlargeBitCountS(Nbits, value.redMultTerm); + Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); + Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); + Nbits = enlargeBitCountS(Nbits, value.alphaMultTerm); + } + if (value.hasAddTerms) { + Nbits = enlargeBitCountS(Nbits, value.redAddTerm); + Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); + Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); + Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm); + } + writeUB(4, Nbits); + if (value.hasMultTerms) { + writeSB(Nbits, value.redMultTerm); + writeSB(Nbits, value.greenMultTerm); + writeSB(Nbits, value.blueMultTerm); + writeSB(Nbits, value.alphaMultTerm); + } + if (value.hasAddTerms) { + writeSB(Nbits, value.redAddTerm); + writeSB(Nbits, value.greenAddTerm); + writeSB(Nbits, value.blueAddTerm); + writeSB(Nbits, value.alphaAddTerm); + } + alignByte(); + } - /** - * Calculates number of bits needed for representing unsigned value - * - * @param v Unsigned value - * @return Number of bits - */ - public static int getNeededBitsU(int v) { + /** + * Writes CLIPEVENTFLAGS value to the stream + * + * @param value CLIPEVENTFLAGS value + * @throws IOException + */ + public void writeCLIPEVENTFLAGS(CLIPEVENTFLAGS value) throws IOException { + writeUB(1, value.clipEventKeyUp ? 1 : 0); + writeUB(1, value.clipEventKeyDown ? 1 : 0); + writeUB(1, value.clipEventMouseUp ? 1 : 0); + writeUB(1, value.clipEventMouseDown ? 1 : 0); + writeUB(1, value.clipEventMouseMove ? 1 : 0); + writeUB(1, value.clipEventUnload ? 1 : 0); + writeUB(1, value.clipEventEnterFrame ? 1 : 0); + writeUB(1, value.clipEventLoad ? 1 : 0); + writeUB(1, value.clipEventDragOver ? 1 : 0); + writeUB(1, value.clipEventRollOut ? 1 : 0); + writeUB(1, value.clipEventRollOver ? 1 : 0); + writeUB(1, value.clipEventReleaseOutside ? 1 : 0); + writeUB(1, value.clipEventRelease ? 1 : 0); + writeUB(1, value.clipEventPress ? 1 : 0); + writeUB(1, value.clipEventInitialize ? 1 : 0); + writeUB(1, value.clipEventData ? 1 : 0); + if (version >= 6) { + writeUB(5, 0); + writeUB(1, value.clipEventConstruct ? 1 : 0); + writeUB(1, value.clipEventKeyPress ? 1 : 0); + writeUB(1, value.clipEventDragOut ? 1 : 0); + writeUB(8, 0); + } + } - return getNeededBits(v,0); - } + /** + * Writes CLIPACTIONRECORD value to the stream + * + * @param value CLIPACTIONRECORD value + * @throws IOException + */ + public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException { + writeCLIPEVENTFLAGS(value.eventFlags); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); - /** - * Calculates number of bits needed for representing signed value - * - * @param v Signed value - * @return Number of bits - */ - public static int getNeededBitsS(int v) { - return getNeededBits(v,1); - } + if (value.eventFlags.clipEventKeyPress) { + sos.writeUI8(value.keyCode); + } + sos.write(value.actionBytes); + //sos.write(Action.actionsToBytes(value.actions, true, version)); + sos.close(); + byte data[] = baos.toByteArray(); + writeUI32(data.length); //actionRecordSize + write(data); + } + /** + * Writes CLIPACTIONS value to the stream + * + * @param value CLIPACTIONS value + * @throws IOException + */ + public void writeCLIPACTIONS(CLIPACTIONS value) throws IOException { + writeUI16(0);//reserved + writeCLIPEVENTFLAGS(value.allEventFlags); + for (CLIPACTIONRECORD car : value.clipActionRecords) { + writeCLIPACTIONRECORD(car); + } + if (version <= 5) { + writeUI16(0); + } else { + writeUI32(0); + } + } - private static long getIntPart(double value) { - if (value < 0) return (long) Math.ceil(value); - return (long) Math.floor(value); - } + /** + * Writes COLORMATRIXFILTER value to the stream + * + * @param value COLORMATRIXFILTER value + * @throws IOException + */ + public void writeCOLORMATRIXFILTER(COLORMATRIXFILTER value) throws IOException { + for (int i = 0; i < 20; i++) { + writeFLOAT(value.matrix[i]); + } + } - private static double getFloatPart(double value) { - if (value < 0) return value - getIntPart(value); - return value + getIntPart(value); - } + /** + * Writes RGBA value to the stream + * + * @param value RGBA value + * @throws IOException + */ + public void writeRGBA(RGBA value) throws IOException { + writeUI8(value.red); + writeUI8(value.green); + writeUI8(value.blue); + writeUI8(value.alpha); + } - /** - * Calculates number of bits needed for representing fixed-point value - * - * @param value Fixed-point value - * @return Number of bits - */ - public static int getNeededBitsF(double value) { - if (value == -1) return 18; - int val = (int) (value * (1 << 16)); - return getNeededBitsS(val); - } + /** + * Writes CONVOLUTIONFILTER value to the stream + * + * @param value CONVOLUTIONFILTER value + * @throws IOException + */ + public void writeCONVOLUTIONFILTER(CONVOLUTIONFILTER value) throws IOException { + writeUI8(value.matrixX); + writeUI8(value.matrixY); + writeFLOAT(value.divisor); + writeFLOAT(value.bias); + for (int x = 0; x < value.matrixX; x++) { + for (int y = 0; y < value.matrixY; y++) { + writeFLOAT(value.matrix[x][y]); + } + } + writeRGBA(value.defaultColor); + writeUB(6, 0); //reserved + writeUB(1, value.clamp ? 1 : 0); + writeUB(1, value.preserveAlpha ? 1 : 0); + } - private int enlargeBitCountU(int currentBitCount, int value) { - int neededNew = getNeededBitsU(value); - if (neededNew > currentBitCount) return neededNew; - return currentBitCount; - } + /** + * Writes BLURFILTER value to the stream + * + * @param value BLURFILTER value + * @throws IOException + */ + public void writeBLURFILTER(BLURFILTER value) throws IOException { + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeUB(5, value.passes); + writeUB(3, 0);//reserved + } - private int enlargeBitCountS(int currentBitCount, int value) { - int neededNew = getNeededBitsS(value); - if (neededNew > currentBitCount) return neededNew; - return currentBitCount; - } + /** + * Writes DROPSHADOWFILTER value to the stream + * + * @param value DROPSHADOWFILTER value + * @throws IOException + */ + public void writeDROPSHADOWFILTER(DROPSHADOWFILTER value) throws IOException { + writeRGBA(value.dropShadowColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(5, value.passes); + } - private int enlargeBitCountF(int currentBitCount, double value) { - int neededNew = getNeededBitsF(value); - if (neededNew > currentBitCount) return neededNew; - return currentBitCount; - } + /** + * Writes GLOWFILTER value to the stream + * + * @param value GLOWFILTER value + * @throws IOException + */ + public void writeGLOWFILTER(GLOWFILTER value) throws IOException { + writeRGBA(value.glowColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED8(value.strength); + writeUB(1, value.innerGlow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(5, value.passes); + } - /** - * Writes MATRIX value to the stream - * - * @param value MATRIX value - * @throws IOException - */ - public void writeMatrix(MATRIX value) throws IOException { - writeUB(1, value.hasScale ? 1 : 0); - if (value.hasScale) { - int nBits = 0; - nBits = enlargeBitCountF(nBits, value.scaleX); - nBits = enlargeBitCountF(nBits, value.scaleY); - nBits = value.scaleNBits; //FFFUUU - writeUB(5, nBits); - writeFB(nBits, value.scaleX); - writeFB(nBits, value.scaleY); - } - writeUB(1, value.hasRotate ? 1 : 0); - if (value.hasRotate) { - int nBits = 0; - nBits = enlargeBitCountF(nBits, value.rotateSkew0); - nBits = enlargeBitCountF(nBits, value.rotateSkew1); - nBits = value.rotateNBits; //FFFUUU - writeUB(5, nBits); - writeFB(nBits, value.rotateSkew0); - writeFB(nBits, value.rotateSkew1); - } - int NTranslateBits = 0; - NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX); - NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY); - NTranslateBits = value.translateNBits; //FFFUUU - writeUB(5, NTranslateBits); + /** + * Writes BEVELFILTER value to the stream + * + * @param value BEVELFILTER value + * @throws IOException + */ + public void writeBEVELFILTER(BEVELFILTER value) throws IOException { + writeRGBA(value.shadowColor); + writeRGBA(value.highlightColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } + /** + * Writes GRADIENTGLOWFILTER value to the stream + * + * @param value GRADIENTGLOWFILTER value + * @throws IOException + */ + public void writeGRADIENTGLOWFILTER(GRADIENTGLOWFILTER value) throws IOException { + writeUI8(value.gradientColors.length); + for (int i = 0; i < value.gradientColors.length; i++) { + writeRGBA(value.gradientColors[i]); + } + for (int i = 0; i < value.gradientColors.length; i++) { + writeUI8(value.gradientRatio[i]); + } + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } - writeSB(NTranslateBits, value.translateX); - writeSB(NTranslateBits, value.translateY); - alignByte(); + /** + * Writes GRADIENTBEVELFILTER value to the stream + * + * @param value GRADIENTBEVELFILTER value + * @throws IOException + */ + public void writeGRADIENTBEVELFILTER(GRADIENTBEVELFILTER value) throws IOException { + writeUI8(value.gradientColors.length); + for (int i = 0; i < value.gradientColors.length; i++) { + writeRGBA(value.gradientColors[i]); + } + for (int i = 0; i < value.gradientColors.length; i++) { + writeUI8(value.gradientRatio[i]); + } + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } - } + /** + * Writes list of FILTER values to the stream + * + * @param list List of FILTER values + * @throws IOException + */ + public void writeFILTERLIST(List list) throws IOException { + writeUI8(list.size()); + for (int i = 0; i < list.size(); i++) { + writeFILTER(list.get(i)); + } + } - /** - * Writes CXFORMWITHALPHA value to the stream - * - * @param value CXFORMWITHALPHA value - * @throws IOException - */ - public void writeCXFORMWITHALPHA(CXFORMWITHALPHA value) throws IOException { - writeUB(1, value.hasAddTerms ? 1 : 0); - writeUB(1, value.hasMultTerms ? 1 : 0); - int Nbits = 1; - if (value.hasMultTerms) { - Nbits = enlargeBitCountS(Nbits, value.redMultTerm); - Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); - Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); - Nbits = enlargeBitCountS(Nbits, value.alphaMultTerm); - } - if (value.hasAddTerms) { - Nbits = enlargeBitCountS(Nbits, value.redAddTerm); - Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); - Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); - Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm); - } - writeUB(4, Nbits); - if (value.hasMultTerms) { - writeSB(Nbits, value.redMultTerm); - writeSB(Nbits, value.greenMultTerm); - writeSB(Nbits, value.blueMultTerm); - writeSB(Nbits, value.alphaMultTerm); - } - if (value.hasAddTerms) { - writeSB(Nbits, value.redAddTerm); - writeSB(Nbits, value.greenAddTerm); - writeSB(Nbits, value.blueAddTerm); - writeSB(Nbits, value.alphaAddTerm); - } - alignByte(); - } + /** + * Writes FILTER value to the stream + * + * @param value FILTER value + * @throws IOException + */ + public void writeFILTER(FILTER value) throws IOException { + writeUI8(value.id); + switch (value.id) { + case 0: + writeDROPSHADOWFILTER((DROPSHADOWFILTER) value); + break; + case 1: + writeBLURFILTER((BLURFILTER) value); + break; + case 2: + writeGLOWFILTER((GLOWFILTER) value); + break; + case 3: + writeBEVELFILTER((BEVELFILTER) value); + break; + case 4: + writeGRADIENTGLOWFILTER((GRADIENTGLOWFILTER) value); + break; + case 5: + writeCONVOLUTIONFILTER((CONVOLUTIONFILTER) value); + break; + case 6: + writeCOLORMATRIXFILTER((COLORMATRIXFILTER) value); + break; + case 7: + writeGRADIENTBEVELFILTER((GRADIENTBEVELFILTER) value); + break; + } + } - /** - * Writes CLIPEVENTFLAGS value to the stream - * - * @param value CLIPEVENTFLAGS value - * @throws IOException - */ - public void writeCLIPEVENTFLAGS(CLIPEVENTFLAGS value) throws IOException { - writeUB(1, value.clipEventKeyUp ? 1 : 0); - writeUB(1, value.clipEventKeyDown ? 1 : 0); - writeUB(1, value.clipEventMouseUp ? 1 : 0); - writeUB(1, value.clipEventMouseDown ? 1 : 0); - writeUB(1, value.clipEventMouseMove ? 1 : 0); - writeUB(1, value.clipEventUnload ? 1 : 0); - writeUB(1, value.clipEventEnterFrame ? 1 : 0); - writeUB(1, value.clipEventLoad ? 1 : 0); - writeUB(1, value.clipEventDragOver ? 1 : 0); - writeUB(1, value.clipEventRollOut ? 1 : 0); - writeUB(1, value.clipEventRollOver ? 1 : 0); - writeUB(1, value.clipEventReleaseOutside ? 1 : 0); - writeUB(1, value.clipEventRelease ? 1 : 0); - writeUB(1, value.clipEventPress ? 1 : 0); - writeUB(1, value.clipEventInitialize ? 1 : 0); - writeUB(1, value.clipEventData ? 1 : 0); - if (version >= 6) { - writeUB(5, 0); - writeUB(1, value.clipEventConstruct ? 1 : 0); - writeUB(1, value.clipEventKeyPress ? 1 : 0); - writeUB(1, value.clipEventDragOut ? 1 : 0); - writeUB(8, 0); - } - } + /** + * Writes list of BUTTONRECORD values to the stream + * + * @param list List of BUTTONRECORD values + * @param inDefineButton2 Whether write inside of DefineButton2Tag or not + * @throws IOException + */ + public void writeBUTTONRECORDList(List list, boolean inDefineButton2) throws IOException { + for (BUTTONRECORD brec : list) { + writeBUTTONRECORD(brec, inDefineButton2); + } + writeUI8(0); + } - /** - * Writes CLIPACTIONRECORD value to the stream - * - * @param value CLIPACTIONRECORD value - * @throws IOException - */ - public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException { - writeCLIPEVENTFLAGS(value.eventFlags); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); + /** + * Writes BUTTONRECORD value to the stream + * + * @param value BUTTONRECORD value + * @param inDefineButton2 Whether write inside of DefineButton2Tag or not + * @throws IOException + */ + public void writeBUTTONRECORD(BUTTONRECORD value, boolean inDefineButton2) throws IOException { + writeUB(2, 0);//reserved + writeUB(1, value.buttonHasBlendMode ? 1 : 0); + writeUB(1, value.buttonHasFilterList ? 1 : 0); + writeUB(1, value.buttonStateHitTest ? 1 : 0); + writeUB(1, value.buttonStateDown ? 1 : 0); + writeUB(1, value.buttonStateOver ? 1 : 0); + writeUB(1, value.buttonStateUp ? 1 : 0); + writeUI16(value.characterId); + writeUI16(value.placeDepth); + writeMatrix(value.placeMatrix); + if (inDefineButton2) { + writeCXFORMWITHALPHA(value.colorTransform); + if (value.buttonHasFilterList) { + writeFILTERLIST(value.filterList); + } + if (value.buttonHasBlendMode) { + writeUI8(value.blendMode); + } + } + } - if (value.eventFlags.clipEventKeyPress) { - sos.writeUI8(value.keyCode); - } - sos.write(value.actionBytes); - //sos.write(Action.actionsToBytes(value.actions, true, version)); - sos.close(); - byte data[] = baos.toByteArray(); - writeUI32(data.length); //actionRecordSize - write(data); - } + /** + * Writes list of BUTTONCONDACTION values to the stream + * + * @param list List of BUTTONCONDACTION values + * @throws IOException + */ + public void writeBUTTONCONDACTIONList(List list) throws IOException { + for (int i = 0; i < list.size(); i++) { + writeBUTTONCONDACTION(list.get(i), i == list.size() - 1); + } + } + /** + * Writes BUTTONCONDACTION value to the stream + * + * @param value BUTTONCONDACTION value + * @param isLast True if it is last on the list + * @throws IOException + */ + public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException { + BUTTONCONDACTION ret = new BUTTONCONDACTION(); - /** - * Writes CLIPACTIONS value to the stream - * - * @param value CLIPACTIONS value - * @throws IOException - */ - public void writeCLIPACTIONS(CLIPACTIONS value) throws IOException { - writeUI16(0);//reserved - writeCLIPEVENTFLAGS(value.allEventFlags); - for (CLIPACTIONRECORD car : value.clipActionRecords) { - writeCLIPACTIONRECORD(car); - } - if (version <= 5) { - writeUI16(0); - } else { - writeUI32(0); - } - } - - /** - * Writes COLORMATRIXFILTER value to the stream - * - * @param value COLORMATRIXFILTER value - * @throws IOException - */ - public void writeCOLORMATRIXFILTER(COLORMATRIXFILTER value) throws IOException { - for (int i = 0; i < 20; i++) { - writeFLOAT(value.matrix[i]); - } - } - - /** - * Writes RGBA value to the stream - * - * @param value RGBA value - * @throws IOException - */ - public void writeRGBA(RGBA value) throws IOException { - writeUI8(value.red); - writeUI8(value.green); - writeUI8(value.blue); - writeUI8(value.alpha); - } - - /** - * Writes CONVOLUTIONFILTER value to the stream - * - * @param value CONVOLUTIONFILTER value - * @throws IOException - */ - public void writeCONVOLUTIONFILTER(CONVOLUTIONFILTER value) throws IOException { - writeUI8(value.matrixX); - writeUI8(value.matrixY); - writeFLOAT(value.divisor); - writeFLOAT(value.bias); - for (int x = 0; x < value.matrixX; x++) { - for (int y = 0; y < value.matrixY; y++) { - writeFLOAT(value.matrix[x][y]); - } - } - writeRGBA(value.defaultColor); - writeUB(6, 0); //reserved - writeUB(1, value.clamp ? 1 : 0); - writeUB(1, value.preserveAlpha ? 1 : 0); - } - - /** - * Writes BLURFILTER value to the stream - * - * @param value BLURFILTER value - * @throws IOException - */ - public void writeBLURFILTER(BLURFILTER value) throws IOException { - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeUB(5, value.passes); - writeUB(3, 0);//reserved - } - - /** - * Writes DROPSHADOWFILTER value to the stream - * - * @param value DROPSHADOWFILTER value - * @throws IOException - */ - public void writeDROPSHADOWFILTER(DROPSHADOWFILTER value) throws IOException { - writeRGBA(value.dropShadowColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(5, value.passes); - } - - /** - * Writes GLOWFILTER value to the stream - * - * @param value GLOWFILTER value - * @throws IOException - */ - public void writeGLOWFILTER(GLOWFILTER value) throws IOException { - writeRGBA(value.glowColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED8(value.strength); - writeUB(1, value.innerGlow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(5, value.passes); - } - - /** - * Writes BEVELFILTER value to the stream - * - * @param value BEVELFILTER value - * @throws IOException - */ - public void writeBEVELFILTER(BEVELFILTER value) throws IOException { - writeRGBA(value.shadowColor); - writeRGBA(value.highlightColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } - - /** - * Writes GRADIENTGLOWFILTER value to the stream - * - * @param value GRADIENTGLOWFILTER value - * @throws IOException - */ - public void writeGRADIENTGLOWFILTER(GRADIENTGLOWFILTER value) throws IOException { - writeUI8(value.gradientColors.length); - for (int i = 0; i < value.gradientColors.length; i++) { - writeRGBA(value.gradientColors[i]); - } - for (int i = 0; i < value.gradientColors.length; i++) { - writeUI8(value.gradientRatio[i]); - } - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } - - /** - * Writes GRADIENTBEVELFILTER value to the stream - * - * @param value GRADIENTBEVELFILTER value - * @throws IOException - */ - public void writeGRADIENTBEVELFILTER(GRADIENTBEVELFILTER value) throws IOException { - writeUI8(value.gradientColors.length); - for (int i = 0; i < value.gradientColors.length; i++) { - writeRGBA(value.gradientColors[i]); - } - for (int i = 0; i < value.gradientColors.length; i++) { - writeUI8(value.gradientRatio[i]); - } - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } - - /** - * Writes list of FILTER values to the stream - * - * @param list List of FILTER values - * @throws IOException - */ - public void writeFILTERLIST(List list) throws IOException { - writeUI8(list.size()); - for (int i = 0; i < list.size(); i++) { - writeFILTER(list.get(i)); - } - } - - /** - * Writes FILTER value to the stream - * - * @param value FILTER value - * @throws IOException - */ - public void writeFILTER(FILTER value) throws IOException { - writeUI8(value.id); - switch (value.id) { - case 0: - writeDROPSHADOWFILTER((DROPSHADOWFILTER) value); - break; - case 1: - writeBLURFILTER((BLURFILTER) value); - break; - case 2: - writeGLOWFILTER((GLOWFILTER) value); - break; - case 3: - writeBEVELFILTER((BEVELFILTER) value); - break; - case 4: - writeGRADIENTGLOWFILTER((GRADIENTGLOWFILTER) value); - break; - case 5: - writeCONVOLUTIONFILTER((CONVOLUTIONFILTER) value); - break; - case 6: - writeCOLORMATRIXFILTER((COLORMATRIXFILTER) value); - break; - case 7: - writeGRADIENTBEVELFILTER((GRADIENTBEVELFILTER) value); - break; - } - } - - /** - * Writes list of BUTTONRECORD values to the stream - * - * @param list List of BUTTONRECORD values - * @param inDefineButton2 Whether write inside of DefineButton2Tag or not - * @throws IOException - */ - public void writeBUTTONRECORDList(List list, boolean inDefineButton2) throws IOException { - for (BUTTONRECORD brec : list) { - writeBUTTONRECORD(brec, inDefineButton2); - } - writeUI8(0); - } - - /** - * Writes BUTTONRECORD value to the stream - * - * @param value BUTTONRECORD value - * @param inDefineButton2 Whether write inside of DefineButton2Tag or not - * @throws IOException - */ - public void writeBUTTONRECORD(BUTTONRECORD value, boolean inDefineButton2) throws IOException { - writeUB(2, 0);//reserved - writeUB(1, value.buttonHasBlendMode ? 1 : 0); - writeUB(1, value.buttonHasFilterList ? 1 : 0); - writeUB(1, value.buttonStateHitTest ? 1 : 0); - writeUB(1, value.buttonStateDown ? 1 : 0); - writeUB(1, value.buttonStateOver ? 1 : 0); - writeUB(1, value.buttonStateUp ? 1 : 0); - writeUI16(value.characterId); - writeUI16(value.placeDepth); - writeMatrix(value.placeMatrix); - if (inDefineButton2) { - writeCXFORMWITHALPHA(value.colorTransform); - if (value.buttonHasFilterList) { - writeFILTERLIST(value.filterList); - } - if (value.buttonHasBlendMode) { - writeUI8(value.blendMode); - } - } - } - - /** - * Writes list of BUTTONCONDACTION values to the stream - * - * @param list List of BUTTONCONDACTION values - * @throws IOException - */ - public void writeBUTTONCONDACTIONList(List list) throws IOException { - for (int i = 0; i < list.size(); i++) { - writeBUTTONCONDACTION(list.get(i), i == list.size() - 1); - } - } - - /** - * Writes BUTTONCONDACTION value to the stream - * - * @param value BUTTONCONDACTION value - * @param isLast True if it is last on the list - * @throws IOException - */ - public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException { - BUTTONCONDACTION ret = new BUTTONCONDACTION(); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - sos.writeUB(1, value.condIdleToOverDown ? 1 : 0); - sos.writeUB(1, value.condOutDownToIdle ? 1 : 0); - sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0); - sos.writeUB(1, value.condOverDownToOutDown ? 1 : 0); - sos.writeUB(1, value.condOverDownToOverUp ? 1 : 0); - sos.writeUB(1, value.condOverUpToOverDown ? 1 : 0); - sos.writeUB(1, value.condOverUpToIddle ? 1 : 0); - sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); - sos.writeUB(7, value.condKeyPress); - sos.writeUB(1, value.condOverDownToIddle ? 1 : 0); - sos.write(value.actionBytes); - //sos.write(Action.actionsToBytes(value.actions, true, version)); - sos.close(); - byte data[] = baos.toByteArray(); - if (isLast) { - writeUI16(0); - } else { - writeUI16(data.length + 2); - } - write(data); - } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + sos.writeUB(1, value.condIdleToOverDown ? 1 : 0); + sos.writeUB(1, value.condOutDownToIdle ? 1 : 0); + sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0); + sos.writeUB(1, value.condOverDownToOutDown ? 1 : 0); + sos.writeUB(1, value.condOverDownToOverUp ? 1 : 0); + sos.writeUB(1, value.condOverUpToOverDown ? 1 : 0); + sos.writeUB(1, value.condOverUpToIddle ? 1 : 0); + sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); + sos.writeUB(7, value.condKeyPress); + sos.writeUB(1, value.condOverDownToIddle ? 1 : 0); + sos.write(value.actionBytes); + //sos.write(Action.actionsToBytes(value.actions, true, version)); + sos.close(); + byte data[] = baos.toByteArray(); + if (isLast) { + writeUI16(0); + } else { + writeUI16(data.length + 2); + } + write(data); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/ABC.java b/trunk/src/com/jpexs/asdec/abc/ABC.java index 9489e1e9c..b693918e1 100644 --- a/trunk/src/com/jpexs/asdec/abc/ABC.java +++ b/trunk/src/com/jpexs/asdec/abc/ABC.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc; import com.jpexs.asdec.Main; @@ -55,21 +54,16 @@ public class ABC { public static String IDENT_STRING = " "; public static final int MINORwithDECIMAL = 17; public static final boolean AUTOINIT_STATIC_VARIABLES = false; - - public int deobfuscateIdentifiers() - { - int ret=0; - for(int i=1;i outTraits=new LinkedList(); - + List outTraits = new LinkedList(); + //if (class_info[i].cinit_index != 0) { if (AUTOINIT_STATIC_VARIABLES) { int bodyIndex = findBodyIndex(class_info[i].cinit_index); - List initializer = bodies[bodyIndex].code.toTree(true, i, this, constants, method_info, bodies[bodyIndex],bodies[bodyIndex].code.getLocalRegNamesFromDebug(this)); + List initializer = bodies[bodyIndex].code.toTree(true, i, this, constants, method_info, bodies[bodyIndex], bodies[bodyIndex].code.getLocalRegNamesFromDebug(this)); for (TreeItem ti : initializer) { if (ti instanceof SetPropertyTreeItem) { int multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex; @@ -620,7 +615,7 @@ public class ABC { if (highlight) { toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length + 1); } - outTraits.add(toPrint); + outTraits.add(toPrint); //} //} @@ -708,7 +703,7 @@ public class ABC { out.println(IDENT_STRING + "}");//class out.println("}");//package out.flush(); - Highlighting.doHighlight=true; + Highlighting.doHighlight = true; return baos.toString(); } @@ -716,9 +711,9 @@ public class ABC { for (int i = 0; i < instance_info.length; i++) { String packageName = instance_info[i].getName(constants).getNamespace(constants).getName(constants); String className = instance_info[i].getName(constants).getName(constants); - String fullName=className; - if((packageName!=null)&&(!packageName.equals(""))){ - fullName=packageName+"."+fullName; + String fullName = className; + if ((packageName != null) && (!packageName.equals(""))) { + fullName = packageName + "." + fullName; } Main.startWork("Exporting " + (i + 1) + "/" + instance_info.length + " " + fullName + " ..."); File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar)); @@ -762,9 +757,8 @@ public class ABC { "return", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", "with", "dynamic", "default", "final", "in"}; public int unknownCount = 0; - - public static final String validFirstCharacters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; - public static final String validNextCharacters=validFirstCharacters+"0123456789"; + public static final String validFirstCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; + public static final String validNextCharacters = validFirstCharacters + "0123456789"; public boolean deobfuscateNameSpace(int strIndex) { if (strIndex <= 0) { @@ -780,7 +774,7 @@ public class ABC { break; } } - if (isValid) { + if (isValid) { for (int i = 0; i < s.length(); i++) { if (s.charAt(i) > 127) { isValid = false; @@ -789,17 +783,17 @@ public class ABC { } } - if (!isValid) { + if (!isValid) { if (isReserved) { constants.constant_string[strIndex] = "name_" + s.replace(" ", "_"); } else { unknownCount++; constants.constant_string[strIndex] = "_name" + unknownCount; - } + } } return !isValid; } - + public boolean deobfuscateName(int strIndex) { if (strIndex <= 0) { return false; @@ -814,10 +808,10 @@ public class ABC { break; } } - - Pattern pat=Pattern.compile("^["+Pattern.quote(validFirstCharacters) +"]"+"["+Pattern.quote(validFirstCharacters+validNextCharacters) +"]*$"); - if(!pat.matcher(s).matches()){ - isValid=false; + + Pattern pat = Pattern.compile("^[" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters) + "]*$"); + if (!pat.matcher(s).matches()) { + isValid = false; } if (isValid) { for (int i = 0; i < s.length(); i++) { @@ -828,41 +822,41 @@ public class ABC { } } - if (!isValid) { + if (!isValid) { if (isReserved) { constants.constant_string[strIndex] = "name_" + s.replace(" ", "_"); } else { unknownCount++; constants.constant_string[strIndex] = "_name" + unknownCount; - } + } } return !isValid; } - private void checkMultinameUsedInMethod(int multinameIndex, int methodInfo, List ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer,Traits traits,int parentTraitIndex) { + private void checkMultinameUsedInMethod(int multinameIndex, int methodInfo, List ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { for (int p = 0; p < method_info[methodInfo].param_types.length; p++) { if (method_info[methodInfo].param_types[p] == multinameIndex) { - ret.add(new MethodParamsMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer,traits,parentTraitIndex)); + ret.add(new MethodParamsMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); break; } } if (method_info[methodInfo].ret_type == multinameIndex) { - ret.add(new MethodReturnTypeMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer,traits,parentTraitIndex)); + ret.add(new MethodReturnTypeMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); } MethodBody body = findBody(methodInfo); if (body != null) { - findMultinameUsageInTraits(body.traits,multinameIndex,isStatic,classIndex,ret,traitIndex); - for(ABCException e:body.exceptions){ - if((e.name_index==multinameIndex)||(e.type_index==multinameIndex)){ - ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer,traits,parentTraitIndex)); - return; + findMultinameUsageInTraits(body.traits, multinameIndex, isStatic, classIndex, ret, traitIndex); + for (ABCException e : body.exceptions) { + if ((e.name_index == multinameIndex) || (e.type_index == multinameIndex)) { + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); + return; } } for (AVM2Instruction ins : body.code.code) { for (int o = 0; o < ins.definition.operands.length; o++) { if (ins.definition.operands[o] == AVM2Code.DAT_MULTINAME_INDEX) { if (ins.operands[o] == multinameIndex) { - ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer,traits,parentTraitIndex)); + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); return; } } @@ -871,23 +865,23 @@ public class ABC { } } - private void findMultinameUsageInTraits(Traits traits, int multinameIndex, boolean isStatic, int classIndex, List ret,int parentTraitIndex) { + private void findMultinameUsageInTraits(Traits traits, int multinameIndex, boolean isStatic, int classIndex, List ret, int parentTraitIndex) { for (int t = 0; t < traits.traits.length; t++) { if (traits.traits[t] instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) traits.traits[t]; if (tsc.name_index == multinameIndex) { - ret.add(new ConstVarNameMultinameUsage(multinameIndex, classIndex, t, isStatic,traits,parentTraitIndex)); + ret.add(new ConstVarNameMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); } if (tsc.type_index == multinameIndex) { - ret.add(new ConstVarTypeMultinameUsage(multinameIndex, classIndex, t, isStatic,traits,parentTraitIndex)); + ret.add(new ConstVarTypeMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); } } if (traits.traits[t] instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) traits.traits[t]; if (tmgs.name_index == multinameIndex) { - ret.add(new MethodNameMultinameUsage(multinameIndex, classIndex, t, isStatic, false,traits,parentTraitIndex)); + ret.add(new MethodNameMultinameUsage(multinameIndex, classIndex, t, isStatic, false, traits, parentTraitIndex)); } - checkMultinameUsedInMethod(multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false,traits,parentTraitIndex); + checkMultinameUsedInMethod(multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false, traits, parentTraitIndex); } } } @@ -909,10 +903,10 @@ public class ABC { ret.add(new ImplementsMultinameUsage(multinameIndex, c)); } } - checkMultinameUsedInMethod(multinameIndex, instance_info[c].iinit_index, ret, c, 0, false, true,null,-1); - checkMultinameUsedInMethod(multinameIndex, class_info[c].cinit_index, ret, c, 0, true, true,null,-1); - findMultinameUsageInTraits(instance_info[c].instance_traits, multinameIndex, false, c, ret,-1); - findMultinameUsageInTraits(class_info[c].static_traits, multinameIndex, true, c, ret,-1); + checkMultinameUsedInMethod(multinameIndex, instance_info[c].iinit_index, ret, c, 0, false, true, null, -1); + checkMultinameUsedInMethod(multinameIndex, class_info[c].cinit_index, ret, c, 0, true, true, null, -1); + findMultinameUsageInTraits(instance_info[c].instance_traits, multinameIndex, false, c, ret, -1); + findMultinameUsageInTraits(class_info[c].static_traits, multinameIndex, true, c, ret, -1); } loopm: for (int m = 1; m < constants.constant_multiname.length; m++) { diff --git a/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java b/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java index bb72a1bca..b123e5a77 100644 --- a/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java +++ b/trunk/src/com/jpexs/asdec/abc/ABCInputStream.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc; import com.jpexs.asdec.abc.types.*; @@ -25,364 +24,352 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; - public class ABCInputStream extends InputStream { - private static final int CLASS_PROTECTED_NS = 8; + private static final int CLASS_PROTECTED_NS = 8; + private static final int ATTR_METADATA = 4; + private InputStream is; + private long bytesRead = 0; + private ByteArrayOutputStream bufferOs = null; + public static boolean DEBUG_READ = false; - private static final int ATTR_METADATA = 4; + public void startBuffer() { + bufferOs = new ByteArrayOutputStream(); + } - private InputStream is; - private long bytesRead = 0; - private ByteArrayOutputStream bufferOs = null; - public static boolean DEBUG_READ=false; + public byte[] stopBuffer() { + if (bufferOs == null) { + return new byte[0]; + } + byte ret[] = bufferOs.toByteArray(); + bufferOs = null; + return ret; + } - public void startBuffer() { - bufferOs = new ByteArrayOutputStream(); - } + public ABCInputStream(InputStream is) { + this.is = is; + } - public byte[] stopBuffer() { - if (bufferOs == null) return new byte[0]; - byte ret[] = bufferOs.toByteArray(); - bufferOs = null; - return ret; - } + @Override + public int read() throws IOException { + bytesRead++; + int i = is.read(); + if (DEBUG_READ) { + System.out.println("Read:0x" + Integer.toHexString(i)); + } + if (bufferOs != null) { + if (i != -1) { + bufferOs.write(i); + } + } + return i; + } - public ABCInputStream(InputStream is) { - this.is = is; - } + @Override + public int read(byte[] b) throws IOException { + int currBytesRead = is.read(b); + bytesRead += currBytesRead; + if (DEBUG_READ) { + StringBuilder sb = new StringBuilder("Read["); + sb.append(currBytesRead); + sb.append('/'); + sb.append(b.length); + sb.append("]: "); + for (int jj = 0; jj < currBytesRead; jj++) { + sb.append("0x"); + sb.append(Integer.toHexString(b[jj])); + sb.append(' '); + } + System.out.println(sb.toString()); + } + if (bufferOs != null) { + if (currBytesRead > 0) { + bufferOs.write(b, 0, currBytesRead); + } + } + return currBytesRead; + } - @Override - public int read() throws IOException { - bytesRead++; - int i = is.read(); - if(DEBUG_READ) - { - System.out.println("Read:0x"+Integer.toHexString(i)); - } - if (bufferOs != null) { - if (i != -1) - bufferOs.write(i); - } - return i; - } - - @Override - public int read(byte[] b) throws IOException { - int currBytesRead = is.read(b); - bytesRead += currBytesRead; - if(DEBUG_READ) - { - StringBuilder sb = new StringBuilder("Read["); - sb.append(currBytesRead); - sb.append('/'); - sb.append(b.length); - sb.append("]: "); - for (int jj = 0; jj < currBytesRead; jj++) { - sb.append("0x"); - sb.append(Integer.toHexString(b[jj])); - sb.append(' '); - } - System.out.println(sb.toString()); - } - if (bufferOs != null) { - if (currBytesRead > 0) - bufferOs.write(b, 0, currBytesRead); - } - return currBytesRead; - }; + ; public int readU8() throws IOException { - return read(); - } + return read(); + } - public int readU32() throws IOException { - int i = 0; - int ret = 0; - int bytePos = 0; - int byteCount = 0; - boolean nextByte = false; - do { - i = read(); - nextByte = (i >> 7) == 1; - i = i & 0x7f; - ret = ret + (i << bytePos); - byteCount++; - bytePos += 7; - } while (nextByte); - return ret; - } + public int readU32() throws IOException { + int i = 0; + int ret = 0; + int bytePos = 0; + int byteCount = 0; + boolean nextByte = false; + do { + i = read(); + nextByte = (i >> 7) == 1; + i = i & 0x7f; + ret = ret + (i << bytePos); + byteCount++; + bytePos += 7; + } while (nextByte); + return ret; + } - public int readU30() throws IOException { - return readU32(); - } + public int readU30() throws IOException { + return readU32(); + } - public int readS24() throws IOException { - int ret = (read()) + (read() << 8) + (read() << 16); + public int readS24() throws IOException { + int ret = (read()) + (read() << 8) + (read() << 16); - if ((ret >> 23) == 1) { - ret = ret | 0xff000000; - } + if ((ret >> 23) == 1) { + ret = ret | 0xff000000; + } - return ret; - } + return ret; + } - public int readU16() throws IOException { - return (read()) + (read() << 8); - } + public int readU16() throws IOException { + return (read()) + (read() << 8); + } - public long readS32() throws IOException { - int i = 0; - long ret = 0; - int bytePos = 0; - int byteCount = 0; - boolean nextByte = false; - do { - i = read(); - nextByte = (i >> 7) == 1; - i = i & 0x7f; - ret = ret + (i << bytePos); - byteCount++; - bytePos += 7; - if (bytePos == 35) { - if ((ret >> 31) == 1) - ret = -(ret & 0x7fffffff); - break; + public long readS32() throws IOException { + int i = 0; + long ret = 0; + int bytePos = 0; + int byteCount = 0; + boolean nextByte = false; + do { + i = read(); + nextByte = (i >> 7) == 1; + i = i & 0x7f; + ret = ret + (i << bytePos); + byteCount++; + bytePos += 7; + if (bytePos == 35) { + if ((ret >> 31) == 1) { + ret = -(ret & 0x7fffffff); } - } while (nextByte); - return ret; - } + break; + } + } while (nextByte); + return ret; + } - @Override - public int available() throws IOException { - return is.available(); - } + @Override + public int available() throws IOException { + return is.available(); + } + public final long readLong() throws IOException { + byte readBuffer[] = safeRead(8); + return (((long) readBuffer[7] << 56) + + ((long) (readBuffer[6] & 255) << 48) + + ((long) (readBuffer[5] & 255) << 40) + + ((long) (readBuffer[4] & 255) << 32) + + ((long) (readBuffer[3] & 255) << 24) + + ((readBuffer[2] & 255) << 16) + + ((readBuffer[1] & 255) << 8) + + ((readBuffer[0] & 255) << 0)); + } - public final long readLong() throws IOException { - byte readBuffer[] = safeRead(8); - return (((long) readBuffer[7] << 56) + - ((long) (readBuffer[6] & 255) << 48) + - ((long) (readBuffer[5] & 255) << 40) + - ((long) (readBuffer[4] & 255) << 32) + - ((long) (readBuffer[3] & 255) << 24) + - ((readBuffer[2] & 255) << 16) + - ((readBuffer[1] & 255) << 8) + - ((readBuffer[0] & 255) << 0)); - } + public double readDouble() throws IOException { + long el = readLong(); + double ret = Double.longBitsToDouble(el); + return ret; + } - public double readDouble() throws IOException { - long el = readLong(); - double ret = Double.longBitsToDouble(el); - return ret; - } + private byte[] safeRead(int count) throws IOException { + byte ret[] = new byte[count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } - - private byte[] safeRead(int count) throws IOException { - byte ret[] = new byte[count]; - for (int i = 0; i < count; i++) { - ret[i] = (byte) read(); - } - return ret; - } - - public Namespace readNamespace() throws IOException { - int kind = read(); - int name_index = 0; - for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { - if (Namespace.nameSpaceKinds[k] == kind) { - name_index = readU30(); - break; - } - } - return new Namespace(kind, name_index); - } - - public Multiname readMultiname() throws IOException { - int kind = readU8(); - int namespace_index = -1; - int name_index = -1; - int namespace_set_index = -1; - int qname_index=-1; - List params=new ArrayList(); - - if ((kind == 7) || (kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. - namespace_index = readU30(); + public Namespace readNamespace() throws IOException { + int kind = read(); + int name_index = 0; + for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { + if (Namespace.nameSpaceKinds[k] == kind) { name_index = readU30(); - } - else - if ((kind == 0xf) || (kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA - name_index = readU30(); - }else - if((kind==0x11)||(kind==0x12))//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. - { + break; + } + } + return new Namespace(kind, name_index); + } - } - else - if ((kind == 9) || (kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. - name_index = readU30(); - namespace_set_index = readU30(); - } - else - if ((kind == 0x1B) || (kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA - namespace_set_index = readU30(); - } - else if(kind==0x1D) - { - //Constant_TypeName - qname_index=readU30(); //Multiname index!!! - int paramsLength=readU30(); - for(int i=0;i params = new ArrayList(); - public MethodInfo readMethodInfo() throws IOException { - int param_count = readU30(); - int ret_type = readU30(); - int param_types[] = new int[param_count]; - for (int i = 0; i < param_count; i++) { - param_types[i] = readU30(); - } - int name_index = readU30(); - int flags = read(); + if ((kind == 7) || (kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. + namespace_index = readU30(); + name_index = readU30(); + } else if ((kind == 0xf) || (kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA + name_index = readU30(); + } else if ((kind == 0x11) || (kind == 0x12))//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. + { + } else if ((kind == 9) || (kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. + name_index = readU30(); + namespace_set_index = readU30(); + } else if ((kind == 0x1B) || (kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA + namespace_set_index = readU30(); + } else if (kind == 0x1D) { + //Constant_TypeName + qname_index = readU30(); //Multiname index!!! + int paramsLength = readU30(); + for (int i = 0; i < paramsLength; i++) { + params.add(readU30()); //multiname indices! + } + } else { + System.err.println("Unknown kind of Multiname:0x" + Integer.toHexString(kind)); + System.exit(1); + } - //// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames + return new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params); + } - ValueKind optional[] = new ValueKind[0]; - if ((flags & 8) == 8) { //if has_optional - int optional_count = readU30(); - optional = new ValueKind[optional_count]; - for (int i = 0; i < optional_count; i++) { - optional[i] = new ValueKind(readU30(), read()); + public MethodInfo readMethodInfo() throws IOException { + int param_count = readU30(); + int ret_type = readU30(); + int param_types[] = new int[param_count]; + for (int i = 0; i < param_count; i++) { + param_types[i] = readU30(); + } + int name_index = readU30(); + int flags = read(); + + //// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames + + ValueKind optional[] = new ValueKind[0]; + if ((flags & 8) == 8) { //if has_optional + int optional_count = readU30(); + optional = new ValueKind[optional_count]; + for (int i = 0; i < optional_count; i++) { + optional[i] = new ValueKind(readU30(), read()); + } + } + + int param_names[] = new int[param_count]; + if ((flags & 128) == 128) { //if has_paramnames + for (int i = 0; i < param_count; i++) { + param_names[i] = readU30(); + } + } + return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names); + } + + public Trait readTrait() throws IOException { + long pos = getPosition(); + startBuffer(); + int name_index = readU30(); + int kind = read(); + int kindType = 0xf & kind; + int kindFlags = kind >> 4; + Trait trait = new Trait(); + + switch (kindType) { + case 0: //slot + case 6: //const + TraitSlotConst t1 = new TraitSlotConst(); + t1.slot_id = readU30(); + t1.type_index = readU30(); + t1.value_index = readU30(); + if (t1.value_index != 0) { + t1.value_kind = read(); } - } + trait = t1; + break; + case 1: //method + case 2: //getter + case 3: //setter + TraitMethodGetterSetter t2 = new TraitMethodGetterSetter(); + t2.disp_id = readU30(); + t2.method_info = readU30(); + trait = t2; + break; + case 4: //class + TraitClass t3 = new TraitClass(); + t3.slot_id = readU30(); + t3.class_info = readU30(); + trait = t3; + break; + case 5: //function + TraitFunction t4 = new TraitFunction(); + t4.slot_index = readU30(); + t4.method_info = readU30(); + trait = t4; + break; + } + trait.fileOffset = pos; + trait.kindType = kindType; + trait.kindFlags = kindFlags; + trait.name_index = name_index; + if ((kindFlags & ATTR_METADATA) != 0) { + int metadata_count = readU30(); + trait.metadata = new int[metadata_count]; + for (int i = 0; i < metadata_count; i++) { + trait.metadata[i] = readU30(); + } + } + trait.bytes = stopBuffer(); + return trait; + } - int param_names[] = new int[param_count]; - if ((flags & 128) == 128) { //if has_paramnames - for (int i = 0; i < param_count; i++) { - param_names[i] = readU30(); - } - } - return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names); - } + public Traits readTraits() throws IOException { + int count = readU30(); + Traits traits = new Traits(); + traits.traits = new Trait[count]; + for (int i = 0; i < count; i++) { + traits.traits[i] = readTrait(); + } + return traits; + } - public Trait readTrait() throws IOException { - long pos = getPosition(); - startBuffer(); - int name_index = readU30(); - int kind = read(); - int kindType = 0xf & kind; - int kindFlags = kind >> 4; - Trait trait = new Trait(); + public byte[] readBytes(int count) throws IOException { + byte ret[] = new byte[count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } - switch (kindType) { - case 0: //slot - case 6: //const - TraitSlotConst t1 = new TraitSlotConst(); - t1.slot_id = readU30(); - t1.type_index = readU30(); - t1.value_index = readU30(); - if (t1.value_index != 0) - t1.value_kind = read(); - trait = t1; - break; - case 1: //method - case 2: //getter - case 3: //setter - TraitMethodGetterSetter t2 = new TraitMethodGetterSetter(); - t2.disp_id = readU30(); - t2.method_info = readU30(); - trait = t2; - break; - case 4: //class - TraitClass t3 = new TraitClass(); - t3.slot_id = readU30(); - t3.class_info = readU30(); - trait = t3; - break; - case 5: //function - TraitFunction t4 = new TraitFunction(); - t4.slot_index = readU30(); - t4.method_info = readU30(); - trait = t4; - break; - } - trait.fileOffset = pos; - trait.kindType = kindType; - trait.kindFlags = kindFlags; - trait.name_index = name_index; - if ((kindFlags & ATTR_METADATA) != 0) { - int metadata_count = readU30(); - trait.metadata = new int[metadata_count]; - for (int i = 0; i < metadata_count; i++) { - trait.metadata[i] = readU30(); - } - } - trait.bytes = stopBuffer(); - return trait; - } + public Decimal readDecimal() throws IOException { + byte data[] = readBytes(16); + return new Decimal(data); + } - public Traits readTraits() throws IOException { - int count = readU30(); - Traits traits = new Traits(); - traits.traits = new Trait[count]; - for (int i = 0; i < count; i++) { - traits.traits[i] = readTrait(); - } - return traits; - } + public InstanceInfo readInstanceInfo() throws IOException { + InstanceInfo ret = new InstanceInfo(); + ret.name_index = readU30(); + ret.super_index = readU30(); + ret.flags = read(); + if ((ret.flags & CLASS_PROTECTED_NS) != 0) { + ret.protectedNS = readU30(); + } + int interfaces_count = readU30(); + ret.interfaces = new int[interfaces_count]; + for (int i = 0; i < interfaces_count; i++) { + ret.interfaces[i] = readU30(); + } + ret.iinit_index = readU30(); + ret.instance_traits = readTraits(); + return ret; + } - public byte[] readBytes(int count) throws IOException{ - byte ret[]=new byte[count]; - for(int i=0;i. */ - package com.jpexs.asdec.abc; import com.jpexs.asdec.abc.types.*; @@ -24,252 +23,250 @@ import java.io.OutputStream; public class ABCOutputStream extends OutputStream { - private OutputStream os; + private OutputStream os; - public ABCOutputStream(OutputStream os) { - this.os = os; - } + public ABCOutputStream(OutputStream os) { + this.os = os; + } - @Override - public void write(int b) throws IOException { - os.write(b); - } + @Override + public void write(int b) throws IOException { + os.write(b); + } - public void writeU30(long value) throws IOException { - writeS32(value); - /*boolean loop = true; - boolean underZero=value<0; + public void writeU30(long value) throws IOException { + writeS32(value); + /*boolean loop = true; + boolean underZero=value<0; - if(underZero){ - value = value & 0xFFFFFFFF; - }else{ - value = value & 0x7FFFFFFF; - } - do { - int ret = (int) (value & 0x7F); - if (value < 0x80) { - loop = false; - } - if (value > 0x7F) { - ret += 0x80; - } - write(ret); - value = value >> 7; - } while (loop); -*/ - } + if(underZero){ + value = value & 0xFFFFFFFF; + }else{ + value = value & 0x7FFFFFFF; + } + do { + int ret = (int) (value & 0x7F); + if (value < 0x80) { + loop = false; + } + if (value > 0x7F) { + ret += 0x80; + } + write(ret); + value = value >> 7; + } while (loop); + */ + } - public void writeU32(long value) throws IOException { - boolean loop = true; - value = value & 0xFFFFFFFF; - do { - int ret = (int) (value & 0x7F); - if (value < 0x80) { - loop = false; - } - if (value > 0x7F) { - ret += 0x80; - } - write(ret); - value = value >> 7; - } while (loop); - } + public void writeU32(long value) throws IOException { + boolean loop = true; + value = value & 0xFFFFFFFF; + do { + int ret = (int) (value & 0x7F); + if (value < 0x80) { + loop = false; + } + if (value > 0x7F) { + ret += 0x80; + } + write(ret); + value = value >> 7; + } while (loop); + } - public void writeS24(long value) throws IOException { - int ret = (int) (value & 0xff); - write(ret); - value = value >> 8; - ret = (int) (value & 0xff); - write(ret); - value = value >> 8; - ret = (int) (value & 0xff); - write(ret); - value = value >> 8; - } + public void writeS24(long value) throws IOException { + int ret = (int) (value & 0xff); + write(ret); + value = value >> 8; + ret = (int) (value & 0xff); + write(ret); + value = value >> 8; + ret = (int) (value & 0xff); + write(ret); + value = value >> 8; + } - public void writeS32(long value) throws IOException { - boolean belowZero = value < 0; - /*if (belowZero) { - value = -value; - }*/ - int bitcount = 0; - boolean loop = true; - //value = value & 0xFFFFFFFF; - do { - bitcount += 7; - int ret = (int) (value & 0x7F); - if (value < 0x80) { - if (belowZero) { //&& bitcount < 35 - ret += 0x80; - } else { - loop = false; - } + public void writeS32(long value) throws IOException { + boolean belowZero = value < 0; + /*if (belowZero) { + value = -value; + }*/ + int bitcount = 0; + boolean loop = true; + //value = value & 0xFFFFFFFF; + do { + bitcount += 7; + int ret = (int) (value & 0x7F); + if (value < 0x80) { + if (belowZero) { //&& bitcount < 35 + ret += 0x80; } else { - ret += 0x80; + loop = false; } + } else { + ret += 0x80; + } - if (bitcount == 35) { - ret = ret & 0xf; - } - write(ret); - if (bitcount == 35) { - break; - } - value = value >> 7; - } while (loop); - } + if (bitcount == 35) { + ret = ret & 0xf; + } + write(ret); + if (bitcount == 35) { + break; + } + value = value >> 7; + } while (loop); + } - public void writeLong(long value) throws IOException { - byte writeBuffer[] = new byte[8]; - writeBuffer[7] = (byte) (value >>> 56); - writeBuffer[6] = (byte) (value >>> 48); - writeBuffer[5] = (byte) (value >>> 40); - writeBuffer[4] = (byte) (value >>> 32); - writeBuffer[3] = (byte) (value >>> 24); - writeBuffer[2] = (byte) (value >>> 16); - writeBuffer[1] = (byte) (value >>> 8); - writeBuffer[0] = (byte) (value >>> 0); - write(writeBuffer); - } + public void writeLong(long value) throws IOException { + byte writeBuffer[] = new byte[8]; + writeBuffer[7] = (byte) (value >>> 56); + writeBuffer[6] = (byte) (value >>> 48); + writeBuffer[5] = (byte) (value >>> 40); + writeBuffer[4] = (byte) (value >>> 32); + writeBuffer[3] = (byte) (value >>> 24); + writeBuffer[2] = (byte) (value >>> 16); + writeBuffer[1] = (byte) (value >>> 8); + writeBuffer[0] = (byte) (value >>> 0); + write(writeBuffer); + } - public void writeDouble(double value) throws IOException { - writeLong(Double.doubleToLongBits(value)); - } + public void writeDouble(double value) throws IOException { + writeLong(Double.doubleToLongBits(value)); + } - public void writeU8(int value) throws IOException { - write(value); - } + public void writeU8(int value) throws IOException { + write(value); + } - public void writeU16(int value) throws IOException { - write(value & 0xff); - write((value >> 8) & 0xff); - } + public void writeU16(int value) throws IOException { + write(value & 0xff); + write((value >> 8) & 0xff); + } - public void writeString(String s) throws IOException { - byte sbytes[] = s.getBytes("utf8"); - writeU30(sbytes.length); - write(sbytes); - } + public void writeString(String s) throws IOException { + byte sbytes[] = s.getBytes("utf8"); + writeU30(sbytes.length); + write(sbytes); + } - public void writeNamespace(Namespace ns) throws IOException { - write(ns.kind); - for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { - if (Namespace.nameSpaceKinds[k] == ns.kind) { - writeU30(ns.name_index); - break; - } - } - } + public void writeNamespace(Namespace ns) throws IOException { + write(ns.kind); + for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { + if (Namespace.nameSpaceKinds[k] == ns.kind) { + writeU30(ns.name_index); + break; + } + } + } - public void writeMultiname(Multiname m) throws IOException { - writeU8(m.kind); - if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. - writeU30(m.namespace_index); - writeU30(m.name_index); - } - if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. - writeU30(m.name_index); - writeU30(m.namespace_set_index); - } - if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA - writeU30(m.name_index); - } - if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA - writeU30(m.namespace_set_index); - } - if(m.kind==0x1D) - { - writeU30(m.qname_index); - writeU30(m.params.size()); - for(int i=0;i. */ - package com.jpexs.asdec.abc; import java.io.IOException; @@ -22,46 +21,47 @@ import java.io.InputStream; import java.io.OutputStream; public class CopyOutputStream extends OutputStream { - private OutputStream os; - private InputStream is; - private long pos = 0; - private int TEMPSIZE = 5; - private int temp[] = new int[TEMPSIZE]; - private int tempPos = 0; - public CopyOutputStream(OutputStream os, InputStream is) { - this.os = os; - this.is = is; - } + private OutputStream os; + private InputStream is; + private long pos = 0; + private int TEMPSIZE = 5; + private int temp[] = new int[TEMPSIZE]; + private int tempPos = 0; - @Override - public void write(int b) throws IOException { - temp[tempPos] = b; - tempPos = (tempPos + 1) % TEMPSIZE; + public CopyOutputStream(OutputStream os, InputStream is) { + this.os = os; + this.is = is; + } - pos++; - int r = is.read(); - if ((b & 0xff) != r) { - os.flush(); + @Override + public void write(int b) throws IOException { + temp[tempPos] = b; + tempPos = (tempPos + 1) % TEMPSIZE; - boolean output = false; + pos++; + int r = is.read(); + if ((b & 0xff) != r) { + os.flush(); - if (output) { - System.out.print("Last written:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); - } - System.out.println(""); - System.out.println("More expected:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.println("" + Integer.toHexString(is.read())); - } + boolean output = false; - System.out.println(""); - System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); + if (output) { + System.out.print("Last written:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); } - throw new NotSameException(pos); - } - os.write(b); - } + System.out.println(""); + System.out.println("More expected:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.println("" + Integer.toHexString(is.read())); + } + + System.out.println(""); + System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); + } + throw new NotSameException(pos); + } + os.write(b); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/NotSameException.java b/trunk/src/com/jpexs/asdec/abc/NotSameException.java index 503fffa71..6b1ada14b 100644 --- a/trunk/src/com/jpexs/asdec/abc/NotSameException.java +++ b/trunk/src/com/jpexs/asdec/abc/NotSameException.java @@ -14,14 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc; import com.jpexs.asdec.helpers.Helper; - public class NotSameException extends RuntimeException { - public NotSameException(long pos) { - super("Streams are not the same at pos " + Helper.formatHex((int)pos, 8)); - } + + public NotSameException(long pos) { + super("Streams are not the same at pos " + Helper.formatHex((int) pos, 8)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java index f66f5731f..29a88373e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/AVM2Code.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; import com.jpexs.asdec.abc.ABC; @@ -57,1149 +56,1072 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; - public class AVM2Code { - - public static int toSourceLimit=-1; - public ArrayList code = new ArrayList(); - public static boolean DEBUG_REWRITE=false; - public static final int OPT_U30 = 0x100; - public static final int OPT_U8 = 0x200; - public static final int OPT_S24 = 0x300; - public static final int OPT_CASE_OFFSETS = 0x400; - public static final int OPT_BYTE = 0x500; - public static final int DAT_MULTINAME_INDEX = OPT_U30 + 0x01; - public static final int DAT_ARG_COUNT = OPT_U30 + 0x02; - public static final int DAT_METHOD_INDEX = OPT_U30 + 0x03; - public static final int DAT_STRING_INDEX = OPT_U30 + 0x04; - public static final int DAT_DEBUG_TYPE = OPT_U8 + 0x05; - public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06; - public static final int DAT_LINENUM = OPT_U30 + 0x07; - public static final int DAT_LOCAL_REG_INDEX = OPT_U30 + 0x08; - public static final int DAT_SLOT_INDEX = OPT_U30 + 0x09; - public static final int DAT_SLOT_SCOPE_INDEX = OPT_U30 + 0x0A; - public static final int DAT_OFFSET = OPT_S24 + 0x0B; - public static final int DAT_EXCEPTION_INDEX = OPT_U30 + 0x0C; - public static final int DAT_CLASS_INDEX = OPT_U30 + 0x0D; - public static final int DAT_INT_INDEX = OPT_U30 + 0x0E; - public static final int DAT_UINT_INDEX = OPT_U30 + 0x0F; - public static final int DAT_DOUBLE_INDEX = OPT_U30 + 0x10; - public static final int DAT_DECIMAL_INDEX = OPT_U30 + 0x11; - public static final int DAT_CASE_BASEOFFSET = OPT_S24 + 0x12; - public static InstructionDefinition instructionSet[] = new InstructionDefinition[]{ - new AddIns(), - new InstructionDefinition(0x9b,"add_d",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; //? - } - - }, - new AddIIns(), - new InstructionDefinition(0xb5,"add_p",new int[]{AVM2Code.OPT_U30}), - new ApplyTypeIns(), - new AsTypeIns(), - new AsTypeLateIns(), - new BitAndIns(), - new BitNotIns(), - new BitOrIns(), - new BitXorIns(), - new InstructionDefinition(0x01,"bkpt",new int[]{}), - new InstructionDefinition(0xf2,"bkptline",new int[]{AVM2Code.OPT_U30}), - new CallIns(), - new InstructionDefinition(0x4d,"callinterface",new int[]{AVM2Code.OPT_U30}), - new CallMethodIns(), - new CallPropertyIns(), - new CallPropLexIns(), - new CallPropVoidIns(), - new CallStaticIns(), - new CallSuperIns(), - new InstructionDefinition(0x4b,"callsuperid",new int[]{}), - new CallSuperVoidIns(), - new CheckFilterIns(), - new CoerceIns(), - new CoerceAIns(), - new InstructionDefinition(0x81,"coerce_b",new int[]{}), //stack:-1+1 - new InstructionDefinition(0x84,"coerce_d",new int[]{}), //stack:-1+1 - new InstructionDefinition(0x83,"coerce_i",new int[]{}), //stack:-1+1 - new InstructionDefinition(0x89,"coerce_o",new int[]{}), //stack:-1+1 - new CoerceSIns(), - new InstructionDefinition(0x88,"coerce_u",new int[]{}), //stack:-1+1 - new InstructionDefinition(0x9a,"concat",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; //? - } - - }, - new ConstructIns(), - new ConstructPropIns(), - new ConstructSuperIns(), - new ConvertBIns(), - new ConvertIIns(), - new ConvertDIns(), - new ConvertOIns(), - new ConvertUIns(), - new ConvertSIns(), - new InstructionDefinition(0x79,"convert_m",new int[]{}), //-1 +1 - new InstructionDefinition(0x7a,"convert_m_p",new int[]{AVM2Code.OPT_U30 /*param (?)*/}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new DebugIns(), - new DebugFileIns(), - new DebugLineIns(), - new DecLocalIns(), - new DecLocalIIns(), - new DecrementIns(), - new DecrementIIns(), - new InstructionDefinition(0x5b,"deldescendants",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new DeletePropertyIns(), - new InstructionDefinition(0x6b,"deletepropertylate",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new DivideIns(), - new InstructionDefinition(0xb8,"divide_p",new int[]{AVM2Code.OPT_U30}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; //? - } - - }, - new DupIns(), - new DXNSIns(), - new DXNSLateIns(), - new EqualsIns(), - new EscXAttrIns(), - new EscXElemIns(), - new InstructionDefinition(0x5f,"finddef",new int[]{AVM2Code.DAT_MULTINAME_INDEX}), - /* //Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler) - new InstructionDefinition(0x5b,"findpropglobalstrict",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - },*/ - new InstructionDefinition(0x5c,"findpropglobal",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new FindPropertyIns(), - new FindPropertyStrictIns(), - new GetDescendantsIns(), - new GetGlobalScopeIns(), - new GetGlobalSlotIns(), - new GetLexIns(), - new GetLocalIns(), - new GetLocal0Ins(), - new GetLocal1Ins(), - new GetLocal2Ins(), - new GetLocal3Ins(), - new InstructionDefinition(0x67,"getouterscope",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new GetPropertyIns(), - new GetScopeObjectIns(), - new GetSlotIns(), - new GetSuperIns(), - new GreaterEqualsIns(), - new GreaterThanIns(), - new HasNextIns(), - new HasNext2Ins(), - new IfEqIns(), - new IfFalseIns(), - new IfGeIns(), - new IfGtIns(), - new IfLeIns(), - new IfLtIns(), - new IfNGeIns(), - new IfNGtIns(), - new IfNLeIns(), - new IfNLtIns(), - new IfNeIns(), - new IfStrictEqIns(), - new IfStrictNeIns(), - new IfTrueIns(), - new InIns(), - new IncLocalIns(), - new IncLocalIIns(), - new IncrementIns(), - new IncrementIIns(), - new InstructionDefinition(0x9c,"increment_p",new int[]{AVM2Code.OPT_U30 /*param*/}), - new InstructionDefinition(0x9d,"inclocal_p",new int[]{AVM2Code.OPT_U30 /*param*/,AVM2Code.DAT_REGISTER_INDEX}), - new InstructionDefinition(0x9e,"decrement_p",new int[]{AVM2Code.OPT_U30 /*param*/}), - new InstructionDefinition(0x9f,"declocal_p",new int[]{AVM2Code.OPT_U30 /*param*/,AVM2Code.DAT_REGISTER_INDEX}), - new InitPropertyIns(), - new InstanceOfIns(), - new IsTypeIns(), - new IsTypeLateIns(), - new JumpIns(), - new KillIns(), - new LabelIns(), - new LessEqualsIns(), - new LessThanIns(), - new LookupSwitchIns(), - new LShiftIns(), - new ModuloIns(), - new InstructionDefinition(0xb9,"modulo_p",new int[]{AVM2Code.OPT_U30}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; //? - } - - }, - new MultiplyIns(), - new MultiplyIIns(), - new InstructionDefinition(0xb7,"multiply_p",new int[]{AVM2Code.OPT_U30}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; //? - } - - }, - new NegateIns(), - new NegateIIns(), - new InstructionDefinition(0x8f,"negate_p",new int[]{AVM2Code.OPT_U30 /* param */}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new NewActivationIns(), - new NewArrayIns(), - new NewCatchIns(), - new NewClassIns(), - new NewFunctionIns(), - new NewObjectIns(), - new NextNameIns(), - new NextValueIns(), - new NopIns(), - new NotIns(), - new PopIns(), - new PopScopeIns(), - new PushByteIns(), - new InstructionDefinition(0x22,"pushconstant",new int[]{AVM2Code.DAT_STRING_INDEX}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - - }, - new InstructionDefinition(0x33,"pushdecimal",new int[]{AVM2Code.DAT_DECIMAL_INDEX}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - - }, - new InstructionDefinition(0x34,"pushdnan",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - - }, - new PushDoubleIns(), - new PushFalseIns(), - new PushIntIns(), - new PushNamespaceIns(), - new PushNanIns(), - new PushNullIns(), - new PushScopeIns(), - new PushShortIns(), - new PushStringIns(), - new PushTrueIns(), - new PushUIntIns(), - new PushUndefinedIns(), - new PushWithIns(), - new ReturnValueIns(), - new ReturnVoidIns(), - new RShiftIns(), - new SetLocalIns(), - new SetLocal0Ins(), - new SetLocal1Ins(), - new SetLocal2Ins(), - new SetLocal3Ins(), - new SetGlobalSlotIns(), - new SetPropertyIns(), - new InstructionDefinition(0x69,"setpropertylate",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new SetSlotIns(), - new SetSuperIns(), - new StrictEqualsIns(), - new SubtractIns(), - new SubtractIIns(), - new InstructionDefinition(0xb6,"subtract_p",new int[]{AVM2Code.OPT_U30}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new SwapIns(), - new ThrowIns(), - new InstructionDefinition(0xf3,"timestamp",new int[]{}), - new TypeOfIns(), - new URShiftIns(), - new InstructionDefinition(0x35,"li8",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x36,"li16",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x37,"li32",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x38,"lf32",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x39,"lf64",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x3A,"si8",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x3B,"si16",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x3C,"si32",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x3D,"sf32",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x3E,"sf64",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x50,"sxi1",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x51,"sxi8",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - }, - new InstructionDefinition(0x52,"sxi16",new int[]{}){ - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - + public static int toSourceLimit = -1; + public ArrayList code = new ArrayList(); + public static boolean DEBUG_REWRITE = false; + public static final int OPT_U30 = 0x100; + public static final int OPT_U8 = 0x200; + public static final int OPT_S24 = 0x300; + public static final int OPT_CASE_OFFSETS = 0x400; + public static final int OPT_BYTE = 0x500; + public static final int DAT_MULTINAME_INDEX = OPT_U30 + 0x01; + public static final int DAT_ARG_COUNT = OPT_U30 + 0x02; + public static final int DAT_METHOD_INDEX = OPT_U30 + 0x03; + public static final int DAT_STRING_INDEX = OPT_U30 + 0x04; + public static final int DAT_DEBUG_TYPE = OPT_U8 + 0x05; + public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06; + public static final int DAT_LINENUM = OPT_U30 + 0x07; + public static final int DAT_LOCAL_REG_INDEX = OPT_U30 + 0x08; + public static final int DAT_SLOT_INDEX = OPT_U30 + 0x09; + public static final int DAT_SLOT_SCOPE_INDEX = OPT_U30 + 0x0A; + public static final int DAT_OFFSET = OPT_S24 + 0x0B; + public static final int DAT_EXCEPTION_INDEX = OPT_U30 + 0x0C; + public static final int DAT_CLASS_INDEX = OPT_U30 + 0x0D; + public static final int DAT_INT_INDEX = OPT_U30 + 0x0E; + public static final int DAT_UINT_INDEX = OPT_U30 + 0x0F; + public static final int DAT_DOUBLE_INDEX = OPT_U30 + 0x10; + public static final int DAT_DECIMAL_INDEX = OPT_U30 + 0x11; + public static final int DAT_CASE_BASEOFFSET = OPT_S24 + 0x12; + public static InstructionDefinition instructionSet[] = new InstructionDefinition[]{ + new AddIns(), + new InstructionDefinition(0x9b, "add_d", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new AddIIns(), + new InstructionDefinition(0xb5, "add_p", new int[]{AVM2Code.OPT_U30}), + new ApplyTypeIns(), + new AsTypeIns(), + new AsTypeLateIns(), + new BitAndIns(), + new BitNotIns(), + new BitOrIns(), + new BitXorIns(), + new InstructionDefinition(0x01, "bkpt", new int[]{}), + new InstructionDefinition(0xf2, "bkptline", new int[]{AVM2Code.OPT_U30}), + new CallIns(), + new InstructionDefinition(0x4d, "callinterface", new int[]{AVM2Code.OPT_U30}), + new CallMethodIns(), + new CallPropertyIns(), + new CallPropLexIns(), + new CallPropVoidIns(), + new CallStaticIns(), + new CallSuperIns(), + new InstructionDefinition(0x4b, "callsuperid", new int[]{}), + new CallSuperVoidIns(), + new CheckFilterIns(), + new CoerceIns(), + new CoerceAIns(), + new InstructionDefinition(0x81, "coerce_b", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x84, "coerce_d", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x83, "coerce_i", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x89, "coerce_o", new int[]{}), //stack:-1+1 + new CoerceSIns(), + new InstructionDefinition(0x88, "coerce_u", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x9a, "concat", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } +}, + new ConstructIns(), + new ConstructPropIns(), + new ConstructSuperIns(), + new ConvertBIns(), + new ConvertIIns(), + new ConvertDIns(), + new ConvertOIns(), + new ConvertUIns(), + new ConvertSIns(), + new InstructionDefinition(0x79, "convert_m", new int[]{}), //-1 +1 + new InstructionDefinition(0x7a, "convert_m_p", new int[]{AVM2Code.OPT_U30 /*param (?)*/}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } +}, + new DebugIns(), + new DebugFileIns(), + new DebugLineIns(), + new DecLocalIns(), + new DecLocalIIns(), + new DecrementIns(), + new DecrementIIns(), + new InstructionDefinition(0x5b, "deldescendants", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new DeletePropertyIns(), + new InstructionDefinition(0x6b, "deletepropertylate", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new DivideIns(), + new InstructionDefinition(0xb8, "divide_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new DupIns(), + new DXNSIns(), + new DXNSLateIns(), + new EqualsIns(), + new EscXAttrIns(), + new EscXElemIns(), + new InstructionDefinition(0x5f, "finddef", new int[]{AVM2Code.DAT_MULTINAME_INDEX}), + /* //Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler) + new InstructionDefinition(0x5b,"findpropglobalstrict",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + },*/ + new InstructionDefinition(0x5c, "findpropglobal", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new FindPropertyIns(), + new FindPropertyStrictIns(), + new GetDescendantsIns(), + new GetGlobalScopeIns(), + new GetGlobalSlotIns(), + new GetLexIns(), + new GetLocalIns(), + new GetLocal0Ins(), + new GetLocal1Ins(), + new GetLocal2Ins(), + new GetLocal3Ins(), + new InstructionDefinition(0x67, "getouterscope", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new GetPropertyIns(), + new GetScopeObjectIns(), + new GetSlotIns(), + new GetSuperIns(), + new GreaterEqualsIns(), + new GreaterThanIns(), + new HasNextIns(), + new HasNext2Ins(), + new IfEqIns(), + new IfFalseIns(), + new IfGeIns(), + new IfGtIns(), + new IfLeIns(), + new IfLtIns(), + new IfNGeIns(), + new IfNGtIns(), + new IfNLeIns(), + new IfNLtIns(), + new IfNeIns(), + new IfStrictEqIns(), + new IfStrictNeIns(), + new IfTrueIns(), + new InIns(), + new IncLocalIns(), + new IncLocalIIns(), + new IncrementIns(), + new IncrementIIns(), + new InstructionDefinition(0x9c, "increment_p", new int[]{AVM2Code.OPT_U30 /*param*/}), + new InstructionDefinition(0x9d, "inclocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), + new InstructionDefinition(0x9e, "decrement_p", new int[]{AVM2Code.OPT_U30 /*param*/}), + new InstructionDefinition(0x9f, "declocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), + new InitPropertyIns(), + new InstanceOfIns(), + new IsTypeIns(), + new IsTypeLateIns(), + new JumpIns(), + new KillIns(), + new LabelIns(), + new LessEqualsIns(), + new LessThanIns(), + new LookupSwitchIns(), + new LShiftIns(), + new ModuloIns(), + new InstructionDefinition(0xb9, "modulo_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new MultiplyIns(), + new MultiplyIIns(), + new InstructionDefinition(0xb7, "multiply_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new NegateIns(), + new NegateIIns(), + new InstructionDefinition(0x8f, "negate_p", new int[]{AVM2Code.OPT_U30 /* param */}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new NewActivationIns(), + new NewArrayIns(), + new NewCatchIns(), + new NewClassIns(), + new NewFunctionIns(), + new NewObjectIns(), + new NextNameIns(), + new NextValueIns(), + new NopIns(), + new NotIns(), + new PopIns(), + new PopScopeIns(), + new PushByteIns(), + new InstructionDefinition(0x22, "pushconstant", new int[]{AVM2Code.DAT_STRING_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new InstructionDefinition(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new InstructionDefinition(0x34, "pushdnan", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new PushDoubleIns(), + new PushFalseIns(), + new PushIntIns(), + new PushNamespaceIns(), + new PushNanIns(), + new PushNullIns(), + new PushScopeIns(), + new PushShortIns(), + new PushStringIns(), + new PushTrueIns(), + new PushUIntIns(), + new PushUndefinedIns(), + new PushWithIns(), + new ReturnValueIns(), + new ReturnVoidIns(), + new RShiftIns(), + new SetLocalIns(), + new SetLocal0Ins(), + new SetLocal1Ins(), + new SetLocal2Ins(), + new SetLocal3Ins(), + new SetGlobalSlotIns(), + new SetPropertyIns(), + new InstructionDefinition(0x69, "setpropertylate", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new SetSlotIns(), + new SetSuperIns(), + new StrictEqualsIns(), + new SubtractIns(), + new SubtractIIns(), + new InstructionDefinition(0xb6, "subtract_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new SwapIns(), + new ThrowIns(), + new InstructionDefinition(0xf3, "timestamp", new int[]{}), + new TypeOfIns(), + new URShiftIns(), + new InstructionDefinition(0x35, "li8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x36, "li16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x37, "li32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x38, "lf32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x39, "lf64", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3A, "si8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3B, "si16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3C, "si32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3D, "sf32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3E, "sf64", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x50, "sxi1", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x51, "sxi8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x52, "sxi16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + } + }; + //endoflist + public static InstructionDefinition instructionSetByCode[] = buildInstructionSetByCode(); + + private static InstructionDefinition[] buildInstructionSetByCode() { + InstructionDefinition result[] = new InstructionDefinition[256]; + for (InstructionDefinition id : instructionSet) { + if (result[id.instructionCode] != null) { + System.out.println("Warning: Duplicate OPCODE for instruction " + result[id.instructionCode] + " " + id); + } + result[id.instructionCode] = id; + } + return result; + } + public static final String IDENTOPEN = "/*IDENTOPEN*/"; + public static final String IDENTCLOSE = "/*IDENTCLOSE*/"; + + private class ConvertOutput { + + public Stack stack; + public List output; + + public ConvertOutput(Stack stack, List output) { + this.stack = stack; + this.output = output; + } + } + + public AVM2Code() { + } + + public Object execute(HashMap arguments, ConstantPool constants) { + int pos = 0; + LocalDataArea lda = new LocalDataArea(); + lda.localRegisters = arguments; + try { + while (true) { + AVM2Instruction ins = code.get(pos); + if (ins.definition instanceof JumpIns) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + continue; } - - }; - //endoflist - public static InstructionDefinition instructionSetByCode[] = buildInstructionSetByCode(); - - private static InstructionDefinition[] buildInstructionSetByCode() { - InstructionDefinition result[] = new InstructionDefinition[256]; - for (InstructionDefinition id : instructionSet) { - if (result[id.instructionCode] != null) { - System.out.println("Warning: Duplicate OPCODE for instruction "+result[id.instructionCode]+" "+id); - } - result[id.instructionCode] = id; - } - return result; - } - - public static final String IDENTOPEN = "/*IDENTOPEN*/"; - public static final String IDENTCLOSE = "/*IDENTCLOSE*/"; - - private class ConvertOutput { - - public Stack stack; - public List output; - - public ConvertOutput(Stack stack, List output) { - this.stack = stack; - this.output = output; - } - } - - public AVM2Code() { - } - - public Object execute(HashMap arguments,ConstantPool constants){ - int pos=0; - LocalDataArea lda=new LocalDataArea(); - lda.localRegisters=arguments; - try{ - while(true){ - AVM2Instruction ins=code.get(pos); - if(ins.definition instanceof JumpIns){ - pos=adr2pos((Long)ins.getParamsAsList(constants).get(0)); - continue; + if (ins.definition instanceof IfFalseIns) { + Boolean b = (Boolean) lda.operandStack.pop(); + if (b == false) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + } else { + pos++; + } + continue; } - if(ins.definition instanceof IfFalseIns){ - Boolean b=(Boolean)lda.operandStack.pop(); - if(b==false){ - pos=adr2pos((Long)ins.getParamsAsList(constants).get(0)); - }else{ - pos++; - } - continue; + if (ins.definition instanceof IfTrueIns) { + Boolean b = (Boolean) lda.operandStack.pop(); + if (b == true) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + } else { + pos++; + } + continue; } - if(ins.definition instanceof IfTrueIns){ - Boolean b=(Boolean)lda.operandStack.pop(); - if(b==true){ - pos=adr2pos((Long)ins.getParamsAsList(constants).get(0)); - }else{ - pos++; - } - continue; + if (ins.definition instanceof ReturnValueIns) { + return lda.operandStack.pop(); } - if(ins.definition instanceof ReturnValueIns){ - return lda.operandStack.pop(); - } - if(ins.definition instanceof ReturnVoidIns){ - return null; + if (ins.definition instanceof ReturnVoidIns) { + return null; } ins.definition.execute(lda, constants, ins.getParamsAsList(constants)); pos++; - } - }catch(ConvertException e){ - - } - return null; - } - - public AVM2Code(InputStream is) throws IOException { - ABCInputStream ais = new ABCInputStream(is); - while (ais.available() > 0) { - long startOffset = ais.getPosition(); - ais.startBuffer(); - int instructionCode = ais.read(); - InstructionDefinition instr = instructionSetByCode[instructionCode]; - if (instr != null) { - int actualOperands[]; - if (instructionCode == 0x1b) { //switch - int firstOperand = ais.readS24(); - int case_count = ais.readU30(); - actualOperands = new int[case_count + 3]; - actualOperands[0] = firstOperand; - actualOperands[1] = case_count; - for (int c = 0; c < case_count + 1; c++) { - actualOperands[2 + c] = ais.readS24(); - } - } else { - actualOperands = new int[instr.operands.length]; - for (int op = 0; op < instr.operands.length; op++) { - switch (instr.operands[op] & 0xff00) { - case OPT_U30: - actualOperands[op] = ais.readU30(); - break; - case OPT_U8: - actualOperands[op] = ais.read(); - break; - case OPT_BYTE: - actualOperands[op] = (byte) ais.read(); - break; - case OPT_S24: - actualOperands[op] = ais.readS24(); - break; - } - } - } - - code.add(new AVM2Instruction(startOffset, instr, actualOperands, ais.stopBuffer())); - } else { - throw new UnknownInstructionCode(instructionCode); - } - } - } - - public void compact() { - code.trimToSize(); - } - - public byte[] getBytes() { - return getBytes(null); - } - public byte[] getBytes(byte origBytes[]) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - OutputStream cos; - if((origBytes!=null)&&(DEBUG_REWRITE)) - { - ByteArrayInputStream origis=new ByteArrayInputStream(origBytes); - cos=new CopyOutputStream(bos,origis); - }else{ - cos=bos; - } - try { - for (AVM2Instruction instruction : code) { - cos.write(instruction.getBytes()); - } - } catch (IOException ex) { - } - return bos.toByteArray(); - } - - @Override - public String toString() { - String s = ""; - for (AVM2Instruction instruction : code) { - s += instruction.toString() + "\r\n"; - } - return s; - } - - public String toString(ConstantPool constants) { - String s = ""; - int i = 0; - for (AVM2Instruction instruction : code) { - s += Helper.formatAddress(i) + " " + instruction.toString(constants) + "\r\n"; - i++; - } - return s; - } - - private static String popStack(Stack stack) { - for (int i = stack.size() - 1; i >= 0; i--) { - String s = stack.get(i); - if (!s.startsWith("//")) { - stack.remove(i); - return s; - } - } - return null; - } - - public String toASMSource(ConstantPool constants,MethodBody body) { - String ret = ""; - for(int e=0;e offsets = new ArrayList(); - for (AVM2Instruction ins : code) { - offsets.addAll(ins.getOffsets()); - } - long ofs = 0; - for (AVM2Instruction ins : code) { - if (offsets.contains(ofs)) { - ret += "ofs" + Helper.formatAddress(ofs) + ":"; - } - for(int e=0;e posCache; - private void buildCache() - { - posCache=new ArrayList(); - long a = 0; - for (int i = 0; i < code.size(); i++) { - posCache.add(a); - a += code.get(i).getBytes().length; - } - posCache.add(a); - cacheActual=true; - } - - public int adr2pos(long address) throws ConvertException { - if(!cacheActual){ - buildCache(); - } - int ret=posCache.indexOf(address); - if(ret == -1) { - throw new ConvertException("Bad jump", -1); - } - return ret; - } - - public int pos2adr(int pos) { - if(!cacheActual){ - buildCache(); - } - return posCache.get(pos).intValue(); - } - - private static String listToString(List stack, ConstantPool constants,HashMap localRegNames) { - String ret = ""; - for (int d = 0; d < stack.size(); d++) { - TreeItem o = stack.get(d); - ret += o.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - return ret; - } - - private static String innerStackToString(List stack) { - String ret = ""; - for (int d = 0; d < stack.size(); d++) { - Object o = stack.get(d); - ret += o.toString(); - if (d < stack.size() - 1) { - if (!ret.endsWith("\r\n")) { - ret += "\r\n"; - } - } - } - return ret; - } - - private class Loop { - - public int loopContinue; - public int loopBreak; - public int continueCount = 0; - public int breakCount = 0; - - public Loop(int loopContinue, int loopBreak) { - this.loopContinue = loopContinue; - this.loopBreak = loopBreak; - } - } - - private List loopList; - private List unknownJumps; - private List finallyJumps; - private List parsedExceptions; - private List ignoredIns; - - private String stripBrackets(String s) { - if (s.startsWith("(") && (s.endsWith(")"))) { - s = s.substring(1, s.length() - 1); - } - return s; - } - - private int checkCatches(ABC abc, ConstantPool constants, MethodInfo method_info[], Stack stack, Stack scopeStack, List output, MethodBody body, int ip) throws ConvertException { - /*int newip = ip; - loope: - for (int e = 0; e < body.exceptions.length; e++) { - if (pos2adr(ip) == body.exceptions[e].end) { - for (int f = 0; f < e; f++) { - if (body.exceptions[e].startServer == body.exceptions[f].startServer) { - if (body.exceptions[e].end == body.exceptions[f].end) { - continue loope; - } - } - } - output.add("}"); - if (!(code.get(ip).definition instanceof JumpIns)) { - throw new ConvertException("No jump to skip catches"); - } - int addrAfterCatches = pos2adr(ip + 1) + code.get(ip).operands[0]; - int posAfterCatches = adr2pos(addrAfterCatches); - for (int g = 0; g < body.exceptions.length; g++) { - if (body.exceptions[e].startServer == body.exceptions[g].startServer) { - if (body.exceptions[e].end == body.exceptions[g].end) { - if (body.exceptions[g].isFinally()) { - output.add("finally"); - } else { - output.add("catch(" + body.exceptions[g].getVarName(constants) + ":" + body.exceptions[g].getTypeName(constants) + ")"); - } - output.add("{"); - - if (body.exceptions[g].isFinally()) { - int jumppos = adr2pos(body.exceptions[g].target) - 1; - AVM2Instruction jumpIns = code.get(jumppos); - if (!(jumpIns.definition instanceof JumpIns)) { - throw new ConvertException("No jump in finally block"); - } - int nextAddr = pos2adr(jumppos + 1) + jumpIns.operands[0]; - int nextins = adr2pos(nextAddr); - int pos = nextins; - Integer uj = new Integer(nextins); - if (unknownJumps.contains(uj)) { - unknownJumps.remove(uj); - } - int endpos = 0; - do { - if (code.get(pos).definition instanceof LookupSwitchIns) { - if (code.get(pos).operands[0] == 0) { - if (adr2pos(pos2adr(pos) + code.get(pos).operands[2]) < pos) { - endpos = pos - 1; - newip = endpos + 1; - break; - } - } - } - pos++; - } while (pos < code.size()); - output.addAll(toSource(stack, scopeStack, abc, constants, method_info, body, nextins, endpos).output); - } else { - - int pos = adr2pos(body.exceptions[g].target); - int endpos = posAfterCatches - 1; - for (int p = pos; p < posAfterCatches; p++) { - if (code.get(p).definition instanceof JumpIns) { - int nextAddr = pos2adr(p + 1) + code.get(p).operands[0]; - int nextPos = adr2pos(nextAddr); - if (nextPos == posAfterCatches) { - endpos = p - 1; - break; - } - } - } - Stack cstack = new Stack(); - cstack.push("catched " + body.exceptions[g].getVarName(constants)); - List outcatch = toSource(cstack, new Stack(), abc, constants, method_info, body, pos, endpos).output; - output.addAll(outcatch); - newip = endpos + 1; - } - output.add("}"); - } - } - } - } - } - return newip;*/ - return ip; - } - - boolean isCatched = false; - - private boolean isKilled(int regName, int start, int end) { - for (int k = start; k <= end; k++) { - if (code.get(k).definition instanceof KillIns) { - if (code.get(k).operands[0] == regName) { - return true; - } - } - } - return false; - } - - private int toSourceCount = 0; - - -private int ipOfType(int from,boolean up,Class search,Class skipped,int start,int end) -{ - if(up) - { - for(int i=from;i>=start;i--){ - if(search.isInstance(code.get(i).definition)){ - return i; - }else if((skipped!=null)&&skipped.isInstance(code.get(i).definition)) - { - //skipped - }else{ - return -1; } + } catch (ConvertException e) { } - }else - { - for(int i=from;i<=end;i++){ - if(search.isInstance(code.get(i).definition)){ - return i; - }else if((skipped!=null)&&skipped.isInstance(code.get(i).definition)) - { - //skipped - }else{ - return -1; - } - } - + return null; } - return -1; -} -public HashMap getLocalRegNamesFromDebug(ABC abc){ - HashMap localRegNames= new HashMap(); - for(AVM2Instruction ins:code) - { - if (ins.definition instanceof DebugIns) { - if(ins.operands[0]==1){ - localRegNames.put(ins.operands[2]+1, abc.constants.constant_string[ins.operands[1]]); - } - } - } - return localRegNames; - } - - private void clearKilledAssigments(List output){ - for(int i=0;i=code.size()) return code.size()-1; - if(code.get(ip).definition instanceof DebugLineIns){ - return ip+1; - } - return ip; - } - - private int fixAddrAfterDebugLine(int addr) throws ConvertException{ - return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); - } - - private ConvertOutput toSource(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end,HashMap localRegNames) throws ConvertException { - boolean debugMode = false; - if (debugMode) - System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); - //if(true) return ""; - toSourceCount++; - if(toSourceLimit>0){ - if (toSourceCount > toSourceLimit) { - throw new ConvertException("Limit of subs("+toSourceLimit+") was reached", start); + public AVM2Code(InputStream is) throws IOException { + ABCInputStream ais = new ABCInputStream(is); + while (ais.available() > 0) { + long startOffset = ais.getPosition(); + ais.startBuffer(); + int instructionCode = ais.read(); + InstructionDefinition instr = instructionSetByCode[instructionCode]; + if (instr != null) { + int actualOperands[]; + if (instructionCode == 0x1b) { //switch + int firstOperand = ais.readS24(); + int case_count = ais.readU30(); + actualOperands = new int[case_count + 3]; + actualOperands[0] = firstOperand; + actualOperands[1] = case_count; + for (int c = 0; c < case_count + 1; c++) { + actualOperands[2 + c] = ais.readS24(); + } + } else { + actualOperands = new int[instr.operands.length]; + for (int op = 0; op < instr.operands.length; op++) { + switch (instr.operands[op] & 0xff00) { + case OPT_U30: + actualOperands[op] = ais.readU30(); + break; + case OPT_U8: + actualOperands[op] = ais.read(); + break; + case OPT_BYTE: + actualOperands[op] = (byte) ais.read(); + break; + case OPT_S24: + actualOperands[op] = ais.readS24(); + break; + } + } } - } - List output = new ArrayList(); - String ret = ""; - int ip = start; - try { - int addr; - iploop: - while (ip <= end) { - - if(ignoredIns.contains(ip)) - { - ip++; - continue; - } - addr = pos2adr(ip); - int ipfix=fixIPAfterDebugLine(ip); - int addrfix=pos2adr(ipfix); - int maxend = -1; - List catchedExceptions = new ArrayList(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } + + code.add(new AVM2Instruction(startOffset, instr, actualOperands, ais.stopBuffer())); + } else { + throw new UnknownInstructionCode(instructionCode); + } + } + } + + public void compact() { + code.trimToSize(); + } + + public byte[] getBytes() { + return getBytes(null); + } + + public byte[] getBytes(byte origBytes[]) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + OutputStream cos; + if ((origBytes != null) && (DEBUG_REWRITE)) { + ByteArrayInputStream origis = new ByteArrayInputStream(origBytes); + cos = new CopyOutputStream(bos, origis); + } else { + cos = bos; + } + try { + for (AVM2Instruction instruction : code) { + cos.write(instruction.getBytes()); + } + } catch (IOException ex) { + } + return bos.toByteArray(); + } + + @Override + public String toString() { + String s = ""; + for (AVM2Instruction instruction : code) { + s += instruction.toString() + "\r\n"; + } + return s; + } + + public String toString(ConstantPool constants) { + String s = ""; + int i = 0; + for (AVM2Instruction instruction : code) { + s += Helper.formatAddress(i) + " " + instruction.toString(constants) + "\r\n"; + i++; + } + return s; + } + + private static String popStack(Stack stack) { + for (int i = stack.size() - 1; i >= 0; i--) { + String s = stack.get(i); + if (!s.startsWith("//")) { + stack.remove(i); + return s; + } + } + return null; + } + + public String toASMSource(ConstantPool constants, MethodBody body) { + String ret = ""; + for (int e = 0; e < body.exceptions.length; e++) { + ret += "exception " + e + " m[" + body.exceptions[e].name_index + "]\"" + Helper.escapeString(body.exceptions[e].getVarName(constants)) + "\" " + + "m[" + body.exceptions[e].type_index + "]\"" + Helper.escapeString(body.exceptions[e].getTypeName(constants)) + "\"\n"; + } + List offsets = new ArrayList(); + for (AVM2Instruction ins : code) { + offsets.addAll(ins.getOffsets()); + } + long ofs = 0; + for (AVM2Instruction ins : code) { + if (offsets.contains(ofs)) { + ret += "ofs" + Helper.formatAddress(ofs) + ":"; + } + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].start == ofs) { + ret += "exceptionstart " + e + ":"; + } + if (body.exceptions[e].end == ofs) { + ret += "exceptionend " + e + ":"; + } + if (body.exceptions[e].target == ofs) { + ret += "exceptiontarget " + e + ":"; + } + } + ret += ins.toStringNoAddress(constants) + "\n"; + ofs += ins.getBytes().length; + } + + return ret; + } + private boolean cacheActual = false; + private List posCache; + + private void buildCache() { + posCache = new ArrayList(); + long a = 0; + for (int i = 0; i < code.size(); i++) { + posCache.add(a); + a += code.get(i).getBytes().length; + } + posCache.add(a); + cacheActual = true; + } + + public int adr2pos(long address) throws ConvertException { + if (!cacheActual) { + buildCache(); + } + int ret = posCache.indexOf(address); + if (ret == -1) { + throw new ConvertException("Bad jump", -1); + } + return ret; + } + + public int pos2adr(int pos) { + if (!cacheActual) { + buildCache(); + } + return posCache.get(pos).intValue(); + } + + private static String listToString(List stack, ConstantPool constants, HashMap localRegNames) { + String ret = ""; + for (int d = 0; d < stack.size(); d++) { + TreeItem o = stack.get(d); + ret += o.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + return ret; + } + + private static String innerStackToString(List stack) { + String ret = ""; + for (int d = 0; d < stack.size(); d++) { + Object o = stack.get(d); + ret += o.toString(); + if (d < stack.size() - 1) { + if (!ret.endsWith("\r\n")) { + ret += "\r\n"; + } + } + } + return ret; + } + + private class Loop { + + public int loopContinue; + public int loopBreak; + public int continueCount = 0; + public int breakCount = 0; + + public Loop(int loopContinue, int loopBreak) { + this.loopContinue = loopContinue; + this.loopBreak = loopBreak; + } + } + private List loopList; + private List unknownJumps; + private List finallyJumps; + private List parsedExceptions; + private List ignoredIns; + + private String stripBrackets(String s) { + if (s.startsWith("(") && (s.endsWith(")"))) { + s = s.substring(1, s.length() - 1); + } + return s; + } + + private int checkCatches(ABC abc, ConstantPool constants, MethodInfo method_info[], Stack stack, Stack scopeStack, List output, MethodBody body, int ip) throws ConvertException { + /*int newip = ip; + loope: + for (int e = 0; e < body.exceptions.length; e++) { + if (pos2adr(ip) == body.exceptions[e].end) { + for (int f = 0; f < e; f++) { + if (body.exceptions[e].startServer == body.exceptions[f].startServer) { + if (body.exceptions[e].end == body.exceptions[f].end) { + continue loope; + } + } + } + output.add("}"); + if (!(code.get(ip).definition instanceof JumpIns)) { + throw new ConvertException("No jump to skip catches"); + } + int addrAfterCatches = pos2adr(ip + 1) + code.get(ip).operands[0]; + int posAfterCatches = adr2pos(addrAfterCatches); + for (int g = 0; g < body.exceptions.length; g++) { + if (body.exceptions[e].startServer == body.exceptions[g].startServer) { + if (body.exceptions[e].end == body.exceptions[g].end) { + if (body.exceptions[g].isFinally()) { + output.add("finally"); + } else { + output.add("catch(" + body.exceptions[g].getVarName(constants) + ":" + body.exceptions[g].getTypeName(constants) + ")"); + } + output.add("{"); + + if (body.exceptions[g].isFinally()) { + int jumppos = adr2pos(body.exceptions[g].target) - 1; + AVM2Instruction jumpIns = code.get(jumppos); + if (!(jumpIns.definition instanceof JumpIns)) { + throw new ConvertException("No jump in finally block"); + } + int nextAddr = pos2adr(jumppos + 1) + jumpIns.operands[0]; + int nextins = adr2pos(nextAddr); + int pos = nextins; + Integer uj = new Integer(nextins); + if (unknownJumps.contains(uj)) { + unknownJumps.remove(uj); + } + int endpos = 0; + do { + if (code.get(pos).definition instanceof LookupSwitchIns) { + if (code.get(pos).operands[0] == 0) { + if (adr2pos(pos2adr(pos) + code.get(pos).operands[2]) < pos) { + endpos = pos - 1; + newip = endpos + 1; + break; + } + } + } + pos++; + } while (pos < code.size()); + output.addAll(toSource(stack, scopeStack, abc, constants, method_info, body, nextins, endpos).output); + } else { + + int pos = adr2pos(body.exceptions[g].target); + int endpos = posAfterCatches - 1; + for (int p = pos; p < posAfterCatches; p++) { + if (code.get(p).definition instanceof JumpIns) { + int nextAddr = pos2adr(p + 1) + code.get(p).operands[0]; + int nextPos = adr2pos(nextAddr); + if (nextPos == posAfterCatches) { + endpos = p - 1; + break; + } + } + } + Stack cstack = new Stack(); + cstack.push("catched " + body.exceptions[g].getVarName(constants)); + List outcatch = toSource(cstack, new Stack(), abc, constants, method_info, body, pos, endpos).output; + output.addAll(outcatch); + newip = endpos + 1; + } + output.add("}"); + } + } + } + } + } + return newip;*/ + return ip; + } + boolean isCatched = false; + + private boolean isKilled(int regName, int start, int end) { + for (int k = start; k <= end; k++) { + if (code.get(k).definition instanceof KillIns) { + if (code.get(k).operands[0] == regName) { + return true; + } + } + } + return false; + } + private int toSourceCount = 0; + + private int ipOfType(int from, boolean up, Class search, Class skipped, int start, int end) { + if (up) { + for (int i = from; i >= start; i--) { + if (search.isInstance(code.get(i).definition)) { + return i; + } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { + //skipped + } else { + return -1; + } + } + } else { + for (int i = from; i <= end; i++) { + if (search.isInstance(code.get(i).definition)) { + return i; + } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { + //skipped + } else { + return -1; + } + } + + } + return -1; + } + + public HashMap getLocalRegNamesFromDebug(ABC abc) { + HashMap localRegNames = new HashMap(); + for (AVM2Instruction ins : code) { + if (ins.definition instanceof DebugIns) { + if (ins.operands[0] == 1) { + localRegNames.put(ins.operands[2] + 1, abc.constants.constant_string[ins.operands[1]]); + } + } + } + return localRegNames; + } + + private void clearKilledAssigments(List output) { + for (int i = 0; i < output.size(); i++) { + if (output.get(i) instanceof SetLocalTreeItem) { + if (isKilled(((SetLocalTreeItem) output.get(i)).regIndex, 0, code.size() - 1)) { + output.remove(i); + i--; + } + } + } + } + + private int fixIPAfterDebugLine(int ip) { + if (ip >= code.size()) { + return code.size() - 1; + } + if (code.get(ip).definition instanceof DebugLineIns) { + return ip + 1; + } + return ip; + } + + private int fixAddrAfterDebugLine(int addr) throws ConvertException { + return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); + } + + private ConvertOutput toSource(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap localRegNames) throws ConvertException { + boolean debugMode = false; + if (debugMode) { + System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); + } + //if(true) return ""; + toSourceCount++; + if (toSourceLimit > 0) { + if (toSourceCount > toSourceLimit) { + throw new ConvertException("Limit of subs(" + toSourceLimit + ") was reached", start); + } + } + List output = new ArrayList(); + String ret = ""; + int ip = start; + try { + int addr; + iploop: + while (ip <= end) { + + if (ignoredIns.contains(ip)) { + ip++; + continue; + } + addr = pos2adr(ip); + int ipfix = fixIPAfterDebugLine(ip); + int addrfix = pos2adr(ipfix); + int maxend = -1; + List catchedExceptions = new ArrayList(); + for (int e = 0; e < body.exceptions.length; e++) { + if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (!body.exceptions[e].isFinally()) { + if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { + catchedExceptions.clear(); + maxend = fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } + } + } + if (catchedExceptions.size() > 0) { + ip = ipfix; + addr = addrfix; + parsedExceptions.addAll(catchedExceptions); + int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + + + List> catchedCommands = new ArrayList>(); + if (code.get(endpos).definition instanceof JumpIns) { + int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0]; + int afterCatchPos = adr2pos(afterCatchAddr); + Collections.sort(catchedExceptions, new Comparator() { + public int compare(ABCException o1, ABCException o2) { + try { + return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target); + } catch (ConvertException ex) { + return 0; } - } - } - if (catchedExceptions.size() > 0) { - ip=ipfix; - addr=addrfix; - parsedExceptions.addAll(catchedExceptions); - int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + } + }); - List> catchedCommands = new ArrayList>(); - if (code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0]; - int afterCatchPos = adr2pos(afterCatchAddr); - Collections.sort(catchedExceptions, new Comparator() { - - public int compare(ABCException o1, ABCException o2) { - try { - return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target); - } catch (ConvertException ex) { - return 0; - } - } - }); - - - List finallyCommands = new ArrayList(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - finallyJumps.add(finStart); - if (unknownJumps.contains(finStart)) { - unknownJumps.remove((Integer) finStart); - } - for (int f = finStart; f <= end; f++) { - if (code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) { - finallyCommands = toSource(isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1,localRegNames).output; - returnPos = f + 1; - break; - } - } - } - } - } - - break; - } + List finallyCommands = new ArrayList(); + int returnPos = afterCatchPos; + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))); + if (jmpIns.definition instanceof JumpIns) { + int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + finallyJumps.add(finStart); + if (unknownJumps.contains(finStart)) { + unknownJumps.remove((Integer) finStart); + } + for (int f = finStart; f <= end; f++) { + if (code.get(f).definition instanceof LookupSwitchIns) { + AVM2Instruction swins = code.get(f); + if (swins.operands.length >= 3) { + if (swins.operands[0] == swins.getBytes().length) { + if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) { + finallyCommands = toSource(isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames).output; + returnPos = f + 1; + break; + } + } + } } - } - } + } + + break; + } + } } + } + } - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos = 0; - if (e < catchedExceptions.size() - 1) { - eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - Stack substack = new Stack(); - substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - catchedCommands.add(toSource(isStatic, classIndex, localRegs, substack, new Stack(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos,localRegNames).output); - } + for (int e = 0; e < catchedExceptions.size(); e++) { + int eendpos = 0; + if (e < catchedExceptions.size() - 1) { + eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; + } else { + eendpos = afterCatchPos - 1; + } + Stack substack = new Stack(); + substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); + catchedCommands.add(toSource(isStatic, classIndex, localRegs, substack, new Stack(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames).output); + } - List tryCommands = toSource(isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1,localRegNames).output; + List tryCommands = toSource(isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames).output; - output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - addr = pos2adr(ip); - } + output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); + ip = returnPos; + addr = pos2adr(ip); + } - } + } - if (ip > end) - break; + if (ip > end) { + break; + } - if (unknownJumps.contains(ip)) { - unknownJumps.remove(new Integer(ip)); - throw new UnknownJumpException(stack, ip, output); - } - AVM2Instruction ins = code.get(ip); - - if((ip+8 getLocalRegNamesFromDebug(ABC abc){ } } } - } - } - } - - if((ip+2 0) { + int secondAddr = addr + ins.getBytes().length; + int jumpAddr = secondAddr + ins.operands[0]; + int jumpPos = adr2pos(jumpAddr);// + + if (finallyJumps.contains(jumpPos)) { + if (code.get(ip + 1).definition instanceof LabelIns) { + if (code.get(ip + 2).definition instanceof PopIns) { + if (code.get(ip + 3).definition instanceof LabelIns) { + if (code.get(ip + 4).definition instanceof GetLocalTypeIns) { + if (code.get(ip - 1).definition instanceof PushByteIns) { + if (code.get(ip - 2).definition instanceof SetLocalTypeIns) { + if (((SetLocalTypeIns) code.get(ip - 2).definition).getRegisterId(code.get(ip - 2)) == ((GetLocalTypeIns) code.get(ip + 4).definition).getRegisterId(code.get(ip + 4))) { + SetLocalTreeItem ti = (SetLocalTreeItem) output.remove(output.size() - 1); + stack.add(ti.value); + ip = ip + 5; + continue; + } + } + } + } + } + } + } + //continue; + ip++; + continue; + } + for (Loop l : loopList) { + if (l.loopBreak == jumpPos) { + output.add(new BreakTreeItem(ins, l.loopBreak)); + addr = secondAddr; + ip = ip + 1; + continue iploop; + } + if (l.loopContinue == jumpPos) { + l.continueCount++; + output.add(new ContinueTreeItem(ins, l.loopBreak)); + addr = secondAddr; + ip = ip + 1; + continue iploop; + } + } + + + boolean backJumpFound = false; + int afterBackJumpAddr = 0; + AVM2Instruction backJumpIns = null; + boolean isSwitch = false; + int switchPos = 0; + loopj: + for (int j = jumpPos; j <= end; j++) { + if (code.get(j).definition instanceof IfTypeIns) { + afterBackJumpAddr = pos2adr(j + 1); + + if (afterBackJumpAddr + code.get(j).operands[0] == secondAddr) { + backJumpFound = true; + backJumpIns = code.get(j); + break; + } + } + if (code.get(j).definition instanceof LookupSwitchIns) { + for (int h = 2; h < code.get(j).operands.length; h++) { + int ofs = code.get(j).operands[h] + pos2adr(j); + if (ofs == secondAddr) { + isSwitch = true; + switchPos = j; + break loopj; + } + } + } + } + if (isSwitch) { + AVM2Instruction killIns = code.get(switchPos - 1); + if (!(killIns.definition instanceof KillIns)) { + throw new ConvertException("Unknown pattern: no kill before lookupswitch", switchPos - 1); + } + int userReg = killIns.operands[0]; + int evalTo = -1; + for (int g = jumpPos; g < switchPos; g++) { + if ((code.get(g).definition instanceof SetLocal0Ins) && (userReg == 0)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof SetLocal1Ins) && (userReg == 1)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof SetLocal2Ins) && (userReg == 2)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof SetLocal3Ins) && (userReg == 3)) { + evalTo = g; + break; + } + if ((code.get(g).definition instanceof SetLocalIns) && (userReg == code.get(g).operands[0])) { + evalTo = g; + break; + } + } + if (evalTo == -1) { + throw new ConvertException("Unknown pattern: no setlocal before lookupswitch", switchPos); + } + loopList.add(new Loop(ip, switchPos + 1)); + Stack substack = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, jumpPos, evalTo - 1, localRegNames).stack; + TreeItem switchedValue = substack.pop(); + //output.add("loop" + (switchPos + 1) + ":"); + int switchBreak = switchPos + 1; + List casesList = new ArrayList(); + List> caseCommands = new ArrayList>(); + List defaultCommands = new ArrayList(); + //output.add("switch(" + switchedValue + ")"); + //output.add("{"); + int curPos = evalTo + 1; + int casePos = 0; + do { + evalTo = -1; + for (int g = curPos; g < switchPos; g++) { + if ((code.get(g).definition instanceof GetLocal0Ins) && (userReg == 0)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof GetLocal1Ins) && (userReg == 1)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof GetLocal2Ins) && (userReg == 2)) { + evalTo = g; + break; + } else if ((code.get(g).definition instanceof GetLocal3Ins) && (userReg == 3)) { + evalTo = g; + break; + } + if ((code.get(g).definition instanceof GetLocalIns) && (userReg == code.get(g).operands[0])) { + evalTo = g; + break; + } + } + + + if (evalTo > -1) { + substack = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, curPos, evalTo - 1, localRegNames).stack; + casesList.add(substack.pop()); + } + int substart = adr2pos(code.get(switchPos).operands[2 + casePos] + pos2adr(switchPos)); + int subend = jumpPos - 1; + if (casePos + 1 < code.get(switchPos).operands.length - 2) { + subend = adr2pos(code.get(switchPos).operands[2 + casePos + 1] + pos2adr(switchPos)) - 1; + } + + if (evalTo == -1) { + subend--; + } + List commands = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, substart, subend, localRegNames).output; + if ((evalTo == -1) && (casePos + 1 < code.get(switchPos).operands.length - 2)) { + if (commands.size() == 1) { + commands.remove(0); + } + if (commands.size() > 0) { + //hasDefault=true; + } + } + List caseCommandPart = new ArrayList(); + if (evalTo == -1) { + defaultCommands.addAll(commands); + } else { + caseCommandPart.addAll(commands); + caseCommands.add(caseCommandPart); + } + curPos = evalTo + 4; + casePos++; + if (evalTo == -1) { + break; + } + } while (true); + output.add(new SwitchTreeItem(code.get(switchPos), switchBreak, switchedValue, casesList, caseCommands, defaultCommands)); + ip = switchPos + 1; + addr = pos2adr(ip); + continue; + } + + if (!backJumpFound) { + if (jumpPos <= end + 1) { //probably skipping catch + ip = jumpPos; addr = pos2adr(ip); - } else if (ins.operands[0] > 0) { - int secondAddr = addr + ins.getBytes().length; - int jumpAddr = secondAddr + ins.operands[0]; - int jumpPos = adr2pos(jumpAddr);// + continue; + } + output.add(new ContinueTreeItem(ins, jumpPos, false)); + addr = secondAddr; + ip = ip + 1; + if (!unknownJumps.contains(jumpPos)) { + unknownJumps.add(jumpPos); + } + continue; + //throw new ConvertException("Unknown pattern: forjump with no backjump"); + } + Loop currentLoop = new Loop(jumpPos, adr2pos(afterBackJumpAddr)); + loopList.add(currentLoop); - if (finallyJumps.contains(jumpPos)) { - if (code.get(ip + 1).definition instanceof LabelIns) { - if (code.get(ip + 2).definition instanceof PopIns) { - if (code.get(ip + 3).definition instanceof LabelIns) { - if (code.get(ip + 4).definition instanceof GetLocalTypeIns) { - if (code.get(ip - 1).definition instanceof PushByteIns) { - if (code.get(ip - 2).definition instanceof SetLocalTypeIns) { - if (((SetLocalTypeIns) code.get(ip - 2).definition).getRegisterId(code.get(ip - 2)) == ((GetLocalTypeIns) code.get(ip + 4).definition).getRegisterId(code.get(ip + 4))) { - SetLocalTreeItem ti = (SetLocalTreeItem) output.remove(output.size() - 1); - stack.add(ti.value); - ip = ip + 5; - continue; - } - } - } - } - } - } - } - //continue; - ip++; - continue; + + ConvertOutput co = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, jumpPos, adr2pos(afterBackJumpAddr) - 2, localRegNames); + Stack substack = co.stack; + backJumpIns.definition.translate(isStatic, classIndex, localRegs, substack, scopeStack, constants, backJumpIns, method_info, output, body, abc, localRegNames); + + TreeItem expression = substack.pop(); + List subins = new ArrayList(); + boolean isFor = false; + List finalExpression = new ArrayList(); + try { + subins = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, adr2pos(secondAddr) + 1/*label*/, jumpPos - 1, localRegNames).output; + } catch (UnknownJumpException uje) { + if ((uje.ip >= start) && (uje.ip <= end)) { + currentLoop.loopContinue = uje.ip; + subins = uje.output; + + List contList = new ArrayList(); + for (TreeItem ti : subins) { + if (ti instanceof ContinueTreeItem) { + contList.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + contList.addAll(((Block) ti).getContinues()); + } } + for (int u = 0; u < contList.size(); u++) { + if (contList.get(u) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) contList.get(u)).loopPos == uje.ip) { + if (!((ContinueTreeItem) contList.get(u)).isKnown) { + ((ContinueTreeItem) contList.get(u)).isKnown = true; + ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; + } + } + } + } + finalExpression = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, uje.ip, jumpPos - 1, localRegNames).output; + isFor = true; + } else { + throw new ConvertException("Unknown pattern: jump to nowhere", ip); + } + } + boolean isDoWhile = false; + + if (jumpPos == ip + 2) { + if (code.get(ip + 1).definition instanceof LabelIns) { + isDoWhile = true; + } + } + if (!isDoWhile) { + if (!isFor) { for (Loop l : loopList) { - if (l.loopBreak == jumpPos) { - output.add(new BreakTreeItem(ins, l.loopBreak)); - addr = secondAddr; - ip = ip + 1; - continue iploop; - } - if (l.loopContinue == jumpPos) { - l.continueCount++; - output.add(new ContinueTreeItem(ins, l.loopBreak)); - addr = secondAddr; - ip = ip + 1; - continue iploop; - } + if (l.loopContinue == jumpPos) { + if (l.continueCount == 0) { + //isFor = true; + //finalExpression = subins.remove(subins.size() - 1).toString(); + } + break; + } + } + } + } + + String firstIns = ""; + if (isFor) { + if (output.size() > 0) { + //firstIns = output.remove(output.size() - 1).toString(); + } + } + + List loopBody = new ArrayList(); + loopBody.addAll(co.output); + loopBody.addAll(subins); + + if (isFor) { + output.add(new ForTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList(), expression, finalExpression, loopBody)); + } else if (isDoWhile) { + output.add(new DoWhileTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, loopBody, expression)); + } else { + if (expression instanceof InTreeItem) { + boolean found = false; + for (int g = ip + 1; g < jumpPos; g++) { + if (code.get(g).definition instanceof NextValueIns) { + output.add(new ForEachInTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, (InTreeItem) expression, loopBody)); + found = true; + break; + } + if (code.get(g).definition instanceof NextNameIns) { + output.add(new ForInTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, (InTreeItem) expression, loopBody)); + found = true; + break; + } + } + if (!found) { + throw new ConvertException("Unknown pattern: hasnext without nextvalue/nextname", ip); } - - boolean backJumpFound = false; - int afterBackJumpAddr = 0; - AVM2Instruction backJumpIns = null; - boolean isSwitch = false; - int switchPos = 0; - loopj: - for (int j = jumpPos; j <= end; j++) { - if (code.get(j).definition instanceof IfTypeIns) { - afterBackJumpAddr = pos2adr(j + 1); - - if (afterBackJumpAddr + code.get(j).operands[0] == secondAddr) { - backJumpFound = true; - backJumpIns = code.get(j); - break; - } - } - if (code.get(j).definition instanceof LookupSwitchIns) { - for (int h = 2; h < code.get(j).operands.length; h++) { - int ofs = code.get(j).operands[h] + pos2adr(j); - if (ofs == secondAddr) { - isSwitch = true; - switchPos = j; - break loopj; - } - } - } - } - if (isSwitch) { - AVM2Instruction killIns = code.get(switchPos - 1); - if (!(killIns.definition instanceof KillIns)) { - throw new ConvertException("Unknown pattern: no kill before lookupswitch", switchPos - 1); - } - int userReg = killIns.operands[0]; - int evalTo = -1; - for (int g = jumpPos; g < switchPos; g++) { - if ((code.get(g).definition instanceof SetLocal0Ins) && (userReg == 0)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof SetLocal1Ins) && (userReg == 1)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof SetLocal2Ins) && (userReg == 2)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof SetLocal3Ins) && (userReg == 3)) { - evalTo = g; - break; - } - if ((code.get(g).definition instanceof SetLocalIns) && (userReg == code.get(g).operands[0])) { - evalTo = g; - break; - } - } - if (evalTo == -1) { - throw new ConvertException("Unknown pattern: no setlocal before lookupswitch", switchPos); - } - loopList.add(new Loop(ip, switchPos + 1)); - Stack substack = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, jumpPos, evalTo - 1,localRegNames).stack; - TreeItem switchedValue = substack.pop(); - //output.add("loop" + (switchPos + 1) + ":"); - int switchBreak = switchPos + 1; - List casesList = new ArrayList(); - List> caseCommands = new ArrayList>(); - List defaultCommands = new ArrayList(); - //output.add("switch(" + switchedValue + ")"); - //output.add("{"); - int curPos = evalTo + 1; - int casePos = 0; - do { - evalTo = -1; - for (int g = curPos; g < switchPos; g++) { - if ((code.get(g).definition instanceof GetLocal0Ins) && (userReg == 0)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof GetLocal1Ins) && (userReg == 1)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof GetLocal2Ins) && (userReg == 2)) { - evalTo = g; - break; - } else if ((code.get(g).definition instanceof GetLocal3Ins) && (userReg == 3)) { - evalTo = g; - break; - } - if ((code.get(g).definition instanceof GetLocalIns) && (userReg == code.get(g).operands[0])) { - evalTo = g; - break; - } - } - - - if (evalTo > -1) { - substack = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, curPos, evalTo - 1,localRegNames).stack; - casesList.add(substack.pop()); - } - int substart = adr2pos(code.get(switchPos).operands[2 + casePos] + pos2adr(switchPos)); - int subend = jumpPos - 1; - if (casePos + 1 < code.get(switchPos).operands.length - 2) { - subend = adr2pos(code.get(switchPos).operands[2 + casePos + 1] + pos2adr(switchPos)) - 1; - } - - if (evalTo == -1) - subend--; - List commands = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, substart, subend,localRegNames).output; - if ((evalTo == -1) && (casePos + 1< code.get(switchPos).operands.length - 2)) { - if (commands.size() == 1) { - commands.remove(0); - } - if (commands.size() > 0) { - //hasDefault=true; - } - } - List caseCommandPart = new ArrayList(); - if (evalTo == -1) { - defaultCommands.addAll(commands); - } else { - caseCommandPart.addAll(commands); - caseCommands.add(caseCommandPart); - } - curPos = evalTo + 4; - casePos++; - if (evalTo == -1) { - break; - } - } while (true); - output.add(new SwitchTreeItem(code.get(switchPos), switchBreak, switchedValue, casesList, caseCommands, defaultCommands)); - ip = switchPos + 1; - addr = pos2adr(ip); - continue; - } - - if (!backJumpFound) { - if (jumpPos <= end + 1) { //probably skipping catch - ip = jumpPos; - addr = pos2adr(ip); - continue; - } - output.add(new ContinueTreeItem(ins, jumpPos, false)); - addr = secondAddr; - ip = ip + 1; - if (!unknownJumps.contains(jumpPos)) { - unknownJumps.add(jumpPos); - } - continue; - //throw new ConvertException("Unknown pattern: forjump with no backjump"); - } - Loop currentLoop = new Loop(jumpPos, adr2pos(afterBackJumpAddr)); - loopList.add(currentLoop); - - - ConvertOutput co = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, jumpPos, adr2pos(afterBackJumpAddr) - 2,localRegNames); - Stack substack = co.stack; - backJumpIns.definition.translate(isStatic, classIndex, localRegs, substack, scopeStack, constants, backJumpIns, method_info, output, body, abc,localRegNames); - - TreeItem expression = substack.pop(); - List subins = new ArrayList(); - boolean isFor = false; - List finalExpression = new ArrayList(); - try { - subins = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, adr2pos(secondAddr) + 1/*label*/, jumpPos - 1,localRegNames).output; - } catch (UnknownJumpException uje) { - if ((uje.ip >= start) && (uje.ip <= end)) { - currentLoop.loopContinue = uje.ip; - subins = uje.output; - - List contList = new ArrayList(); - for (TreeItem ti : subins) { - if (ti instanceof ContinueTreeItem) { - contList.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - contList.addAll(((Block) ti).getContinues()); - } - } - for (int u = 0; u < contList.size(); u++) { - if (contList.get(u) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) contList.get(u)).loopPos == uje.ip) { - if (!((ContinueTreeItem) contList.get(u)).isKnown) { - ((ContinueTreeItem) contList.get(u)).isKnown = true; - ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; - } - } - } - } - finalExpression = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, uje.ip, jumpPos - 1,localRegNames).output; - isFor = true; - } else { - throw new ConvertException("Unknown pattern: jump to nowhere", ip); - } - } - boolean isDoWhile = false; - - if (jumpPos == ip + 2) { - if (code.get(ip + 1).definition instanceof LabelIns) { - isDoWhile = true; - } - } - if (!isDoWhile) { - if (!isFor) { - for (Loop l : loopList) { - if (l.loopContinue == jumpPos) { - if (l.continueCount == 0) { - //isFor = true; - //finalExpression = subins.remove(subins.size() - 1).toString(); - } - break; - } - } - } - } - - String firstIns = ""; - if (isFor) { - if (output.size() > 0) { - //firstIns = output.remove(output.size() - 1).toString(); - } - } - - List loopBody = new ArrayList(); - loopBody.addAll(co.output); - loopBody.addAll(subins); - - if (isFor) { - output.add(new ForTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList(), expression, finalExpression, loopBody)); - } else if (isDoWhile) { - output.add(new DoWhileTreeItem(ins, currentLoop.loopBreak, currentLoop.loopContinue, loopBody, expression)); - } else { - if (expression instanceof InTreeItem) { - boolean found=false; - for(int g=ip+1;g= start) { - insBefore = code.get(ip - 1); - } - if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b - ip++; - addr=pos2adr(ip); - insAfter = code.get(ip + 1); - } - - boolean isAnd = false; - if (insAfter.definition instanceof IfFalseIns) { - //stack.add("(" + stack.pop() + ")&&"); - isAnd = true; - } else if (insAfter.definition instanceof IfTrueIns) { - //stack.add("(" + stack.pop() + ")||"); - isAnd = false; - } else if ((insAfter.definition instanceof IncrementIIns) || ((insAfter.definition instanceof IncrementIns))) { - int np=-1; - if(((np=ipOfType(ip+2, false, SetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end))>-1) - &&(ipOfType(ip-1, true, GetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end)>-1)) - { - stack.add(new PostIncrementTreeItem(insAfter, stack.pop())); - ip = np+1; - addr = pos2adr(ip); - break; - } - if (((ip - 1 >= start) && (ip + 2 <= end)) - && (code.get(ip + 2).definition instanceof SetLocalTypeIns) - && (isKilled(((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)), ip + 3, end))) { - int pos = -1; - for (int d = ip + 3; d <= end; d++) { - if (!((code.get(d).definition instanceof GetLocalTypeIns) - && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { - pos = d; - break; - } - } - if (pos > -1) { - if (code.get(pos).definition instanceof SetTypeIns) { - stack.push(new PostIncrementTreeItem(insAfter, stack.pop())); - ip = pos + 1; - addr = pos2adr(ip); - break; - } - } - - } - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - ip++; - addr = pos2adr(ip); - break; - } else if ((insAfter.definition instanceof DecrementIIns) || ((insAfter.definition instanceof DecrementIns))) { - int np=-1; - if(((np=ipOfType(ip+2, false, SetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end))>-1) - &&(ipOfType(ip-1, true, GetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end)>-1)) - { - stack.add(new PostDecrementTreeItem(insAfter, stack.pop())); - ip = np+1; - addr = pos2adr(ip); - break; - } - if (((ip - 1 >= start) && (ip + 2 <= end)) - && (code.get(ip + 2).definition instanceof SetLocalTypeIns) - && (isKilled(((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)), ip + 3, end))) { - int pos = -1; - for (int d = ip + 3; d <= end; d++) { - if (!((code.get(d).definition instanceof GetLocalTypeIns) - && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { - pos = d; - break; - } - } - if (pos > -1) { - if (code.get(pos).definition instanceof SetTypeIns) { - stack.push(new PostDecrementTreeItem(insAfter, stack.pop())); - ip = pos + 1; - addr = pos2adr(ip); - break; - } - } - - } - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - ip++; - addr = pos2adr(ip); - break; - } else if ((insBefore.definition instanceof IncrementIIns) || ((insBefore.definition instanceof IncrementIns))) { - if (((ip - 2 >= start) && (ip + 2 <= end)) && (code.get(ip + 1).definition instanceof CoerceOrConvertTypeIns) && (code.get(ip + 2).definition instanceof SetLocalTypeIns) && (code.get(ip - 2).definition instanceof GetLocalTypeIns)) { - stack.pop(); - int regId = ((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)); - stack.add(new PreIncrementTreeItem(insBefore, new LocalRegTreeItem(code.get(ip + 2), regId, localRegs.get(regId)))); - ip += 3; - addr = pos2adr(ip); - break; - } - if (((ip - 1 >= start) && (ip + 2 <= end)) - && (code.get(ip + 1).definition instanceof SetLocalTypeIns) - && (isKilled(((SetLocalTypeIns) code.get(ip + 1).definition).getRegisterId(code.get(ip + 1)), ip + 2, end))) { - int pos = -1; - for (int d = ip + 2; d <= end; d++) { - if (!((code.get(d).definition instanceof GetLocalTypeIns) - && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { - pos = d; - break; - } - } - if (pos > -1) { - if (code.get(pos).definition instanceof SetTypeIns) { - TreeItem s = stack.pop(); - if (s instanceof IncrementTreeItem) { - stack.push(new PreIncrementTreeItem(insBefore, ((IncrementTreeItem) s).object)); - } - ip = pos + 1; - addr = pos2adr(ip); - break; - } - } - - } - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - ip++; - addr = pos2adr(ip); - break; - } else if ((insBefore.definition instanceof DecrementIIns) || ((insBefore.definition instanceof DecrementIns))) { - if (((ip - 2 >= start) && (ip + 2 <= end)) && (code.get(ip + 1).definition instanceof CoerceOrConvertTypeIns) && (code.get(ip + 2).definition instanceof SetLocalTypeIns) && (code.get(ip - 2).definition instanceof GetLocalTypeIns)) { - stack.pop(); - int regId = ((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)); - stack.add(new PreDecrementTreeItem(insBefore, new LocalRegTreeItem(code.get(ip + 2), regId, localRegs.get(regId)))); - ip += 3; - addr = pos2adr(ip); - break; - } - if (((ip - 1 >= start) && (ip + 2 <= end)) - && (code.get(ip + 1).definition instanceof SetLocalTypeIns) - && (isKilled(((SetLocalTypeIns) code.get(ip + 1).definition).getRegisterId(code.get(ip + 1)), ip + 2, end))) { - int pos = -1; - for (int d = ip + 2; d <= end; d++) { - if (!((code.get(d).definition instanceof GetLocalTypeIns) - && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { - pos = d; - break; - } - } - if (pos > -1) { - if (code.get(pos).definition instanceof SetTypeIns) { - TreeItem s = stack.pop(); - if (s instanceof DecrementTreeItem) { - stack.push(new PreDecrementTreeItem(insBefore, ((DecrementTreeItem) s).object)); - } - ip = pos + 1; - addr = pos2adr(ip); - break; - } - } - - } - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - ip++; - addr = pos2adr(ip); - break; - } else if (insAfter.definition instanceof SetLocalTypeIns) { - //chained assignments - int reg=(((SetLocalTypeIns)insAfter.definition).getRegisterId(insAfter)); - for(int t=ip+1;t(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos,localRegNames).stack.pop())); - } else { - stack.add(new OrTreeItem(insAfter, stack.pop(), toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos,localRegNames).stack.pop())); - } - ins = code.get(nextPos + 1); - ip = nextPos + 1; - } while (ins.definition instanceof DupIns); - } else if (ins.definition instanceof IfTypeIns) { - int targetAddr = pos2adr(ip) + ins.getBytes().length + ins.operands[0]; - int targetIns = adr2pos(targetAddr); - ((IfTypeIns) ins.definition).translateInverted(localRegs, stack, ins); - - TreeItem condition = stack.pop(); - - if (condition.isFalse()) { - //ins.definition = new JumpIns(); - //continue; - } - if (condition.isTrue()) { - //ip = targetIns; - //continue; - } - //stack.add("if"+stack.pop()); - //stack.add("{"); - boolean hasElse = false; - boolean hasReturn = false; - if (code.get(targetIns - 1).definition instanceof JumpIns) { - - if ((targetIns - 2 > ip) && ((code.get(targetIns - 2).definition instanceof ReturnValueIns) || (code.get(targetIns - 2).definition instanceof ReturnVoidIns) || (code.get(targetIns - 2).definition instanceof ThrowIns))) { - hasElse = false; - hasReturn = true; - } else { - int jumpAddr = targetAddr + code.get(targetIns - 1).operands[0]; - int jumpPos = adr2pos(jumpAddr); - hasElse = true; - - for (Loop l : loopList) { - if (l.loopBreak == jumpPos) { - hasElse = false; - break; - } - } - if (hasElse) { - if (adr2pos(jumpAddr) > end + 1) { - hasElse = false; - //throw new ConvertException("Unknown pattern: forward jump outside of the block"); - } - } - } - } - ConvertOutput onTrue = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, ip + 1, targetIns - 1 - ((hasElse || hasReturn) ? 1 : 0),localRegNames); - addr = targetAddr; - ip = targetIns; - ConvertOutput onFalse = new ConvertOutput(new Stack(), new ArrayList()); - if (hasElse) { - int finalAddr = targetAddr + code.get(targetIns - 1).operands[0]; - int finalIns = adr2pos(finalAddr); - onFalse = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, targetIns, finalIns - 1,localRegNames); - addr = finalAddr; - ip = finalIns; - } - if ((onTrue.stack.size() > 0) && (onFalse != null) && (onFalse.stack.size() > 0)) { - stack.add(new TernarOpTreeItem(ins, condition, onTrue.stack.pop(), onFalse.stack.pop())); - } else { - output.add(new IfTreeItem(ins, condition, onTrue.output, onFalse.output)); - } - - } else if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - ip = end + 1; - break; - } else { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc,localRegNames); - - addr += ins.getBytes().length; - ip++; - } - - } - if (debugMode) - System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); - //clearKilledAssigments(output); - return new ConvertOutput(stack, output); - } catch (ConvertException cex) { - throw cex; - } catch (Exception ex) { - if (ex instanceof UnknownJumpException) { - throw (UnknownJumpException) ex; - } - throw new ConvertException(ex.getClass().getSimpleName(), ip); - } - } - - public String tabString(int len) { - String ret = ""; - for (int i = 0; i < len; i++) { - ret += ABC.IDENT_STRING; - } - return ret; - } - - public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body,HashMap localRegNames) { - return toSource(isStatic, classIndex, abc, constants, method_info, body, false,localRegNames); - } - - public List toTree(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body,HashMap localRegNames) { - toSourceCount = 0; - loopList = new ArrayList(); - unknownJumps = new ArrayList(); - parsedExceptions = new ArrayList(); - finallyJumps = new ArrayList(); - HashMap localRegs = new HashMap(); - try { - return toSource(isStatic, classIndex, localRegs, new Stack(), new Stack(), abc, constants, method_info, body, 0, code.size() - 1,localRegNames).output; - } catch (ConvertException ex) { - return new ArrayList(); - } - } - - public int getRegisterCount(){ - int maxRegister=-1; - for(AVM2Instruction ins:code) - { - int regId=-1; - if(ins.definition instanceof SetLocalTypeIns) - { - regId=((SetLocalTypeIns)ins.definition).getRegisterId(ins); - } - if(ins.definition instanceof GetLocalTypeIns) - { - regId=((GetLocalTypeIns)ins.definition).getRegisterId(ins); - } - if(regId>maxRegister) - { - maxRegister=regId; - } - } - return maxRegister+1; - } - - public HashMap getLocalRegTypes(ConstantPool constants){ - HashMap ret=new HashMap(); - AVM2Instruction prev=null; - for(AVM2Instruction ins:code){ - if(ins.definition instanceof SetLocalTypeIns){ - if(prev!=null){ - if(prev.definition instanceof CoerceOrConvertTypeIns) - { - ret.put(((SetLocalTypeIns)ins.definition).getRegisterId(ins),((CoerceOrConvertTypeIns)prev.definition).getTargetType(constants, prev)); - } - } - } - prev=ins; - } - return ret; - } - - public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted,HashMap localRegNames) { - toSourceCount = 0; - loopList = new ArrayList(); - unknownJumps = new ArrayList(); - finallyJumps = new ArrayList(); - parsedExceptions = new ArrayList(); - ignoredIns = new ArrayList(); - List list; - String s = ""; - HashMap localRegs = new HashMap(); - try { - list = toSource(isStatic, classIndex, localRegs, new Stack(), new Stack(), abc, constants, method_info, body, 0, code.size() - 1,localRegNames).output; - s = listToString(list, constants,localRegNames); - } catch (Exception ex) { - s = "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex.getMessage()+"\r\n */"; - return s; - } - - - String parts[] = s.split("\r\n"); - String sub = ""; - int level = 0; - for (int t = 0; t < body.traits.traits.length; t++) { - //Skip traits with same name as local registers - if( - (body.traits.traits[t] instanceof TraitSlotConst) - &&(((TraitSlotConst)body.traits.traits[t]).isVar()) - &&(localRegNames.containsValue(((TraitSlotConst)body.traits.traits[t]).getName(constants)))) - { - continue; - }else{ - sub += body.traits.traits[t].convert(constants, method_info,abc) + ";\r\n"; - } - } - int regCount=getRegisterCount(); - int paramCount=0; - if(body.method_info!=-1) - { - MethodInfo mi=method_info[body.method_info]; - paramCount=mi.param_types.length; - if(mi.flagNeed_rest()){ - paramCount++; - } - } - HashMap localRegTypes=getLocalRegTypes(constants); - for(int i=paramCount+1;i loopStack = new Stack(); - for (int p = 0; p < parts.length; p++) { - String stripped = Highlighting.stripHilights(parts[p]); - if (stripped.endsWith(":") && (!stripped.startsWith("case ")) && (!stripped.equals("default:"))) { - loopStack.add(stripped.substring(0, stripped.length() - 1)); - } - if (stripped.startsWith("break ")) { - if (stripped.equals("break " + loopStack.peek() + ";")) { - parts[p] = parts[p].replace(" " + loopStack.peek(), ""); - } - } - if (stripped.startsWith("continue ")) { - if (loopStack.size() > 0) { - if (stripped.equals("continue " + loopStack.peek() + ";")) { - parts[p] = parts[p].replace(" " + loopStack.peek(), ""); + } else if (ins.definition instanceof DupIns) { + int nextPos = 0; + do { + AVM2Instruction insAfter = code.get(ip + 1); + AVM2Instruction insBefore = ins; + if (ip - 1 >= start) { + insBefore = code.get(ip - 1); + } + if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b + ip++; + addr = pos2adr(ip); + insAfter = code.get(ip + 1); + } + + boolean isAnd = false; + if (insAfter.definition instanceof IfFalseIns) { + //stack.add("(" + stack.pop() + ")&&"); + isAnd = true; + } else if (insAfter.definition instanceof IfTrueIns) { + //stack.add("(" + stack.pop() + ")||"); + isAnd = false; + } else if ((insAfter.definition instanceof IncrementIIns) || ((insAfter.definition instanceof IncrementIns))) { + int np = -1; + if (((np = ipOfType(ip + 2, false, SetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end)) > -1) + && (ipOfType(ip - 1, true, GetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end) > -1)) { + stack.add(new PostIncrementTreeItem(insAfter, stack.pop())); + ip = np + 1; + addr = pos2adr(ip); + break; + } + if (((ip - 1 >= start) && (ip + 2 <= end)) + && (code.get(ip + 2).definition instanceof SetLocalTypeIns) + && (isKilled(((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)), ip + 3, end))) { + int pos = -1; + for (int d = ip + 3; d <= end; d++) { + if (!((code.get(d).definition instanceof GetLocalTypeIns) + && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { + pos = d; + break; + } } - } - } - if (stripped.startsWith(":")) { - loopStack.pop(); - } + if (pos > -1) { + if (code.get(pos).definition instanceof SetTypeIns) { + stack.push(new PostIncrementTreeItem(insAfter, stack.pop())); + ip = pos + 1; + addr = pos2adr(ip); + break; + } + } + + } + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + } else if ((insAfter.definition instanceof DecrementIIns) || ((insAfter.definition instanceof DecrementIns))) { + int np = -1; + if (((np = ipOfType(ip + 2, false, SetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end)) > -1) + && (ipOfType(ip - 1, true, GetLocalTypeIns.class, CoerceOrConvertTypeIns.class, start, end) > -1)) { + stack.add(new PostDecrementTreeItem(insAfter, stack.pop())); + ip = np + 1; + addr = pos2adr(ip); + break; + } + if (((ip - 1 >= start) && (ip + 2 <= end)) + && (code.get(ip + 2).definition instanceof SetLocalTypeIns) + && (isKilled(((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)), ip + 3, end))) { + int pos = -1; + for (int d = ip + 3; d <= end; d++) { + if (!((code.get(d).definition instanceof GetLocalTypeIns) + && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { + pos = d; + break; + } + } + if (pos > -1) { + if (code.get(pos).definition instanceof SetTypeIns) { + stack.push(new PostDecrementTreeItem(insAfter, stack.pop())); + ip = pos + 1; + addr = pos2adr(ip); + break; + } + } + + } + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + } else if ((insBefore.definition instanceof IncrementIIns) || ((insBefore.definition instanceof IncrementIns))) { + if (((ip - 2 >= start) && (ip + 2 <= end)) && (code.get(ip + 1).definition instanceof CoerceOrConvertTypeIns) && (code.get(ip + 2).definition instanceof SetLocalTypeIns) && (code.get(ip - 2).definition instanceof GetLocalTypeIns)) { + stack.pop(); + int regId = ((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)); + stack.add(new PreIncrementTreeItem(insBefore, new LocalRegTreeItem(code.get(ip + 2), regId, localRegs.get(regId)))); + ip += 3; + addr = pos2adr(ip); + break; + } + if (((ip - 1 >= start) && (ip + 2 <= end)) + && (code.get(ip + 1).definition instanceof SetLocalTypeIns) + && (isKilled(((SetLocalTypeIns) code.get(ip + 1).definition).getRegisterId(code.get(ip + 1)), ip + 2, end))) { + int pos = -1; + for (int d = ip + 2; d <= end; d++) { + if (!((code.get(d).definition instanceof GetLocalTypeIns) + && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { + pos = d; + break; + } + } + if (pos > -1) { + if (code.get(pos).definition instanceof SetTypeIns) { + TreeItem s = stack.pop(); + if (s instanceof IncrementTreeItem) { + stack.push(new PreIncrementTreeItem(insBefore, ((IncrementTreeItem) s).object)); + } + ip = pos + 1; + addr = pos2adr(ip); + break; + } + } + + } + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + } else if ((insBefore.definition instanceof DecrementIIns) || ((insBefore.definition instanceof DecrementIns))) { + if (((ip - 2 >= start) && (ip + 2 <= end)) && (code.get(ip + 1).definition instanceof CoerceOrConvertTypeIns) && (code.get(ip + 2).definition instanceof SetLocalTypeIns) && (code.get(ip - 2).definition instanceof GetLocalTypeIns)) { + stack.pop(); + int regId = ((SetLocalTypeIns) code.get(ip + 2).definition).getRegisterId(code.get(ip + 2)); + stack.add(new PreDecrementTreeItem(insBefore, new LocalRegTreeItem(code.get(ip + 2), regId, localRegs.get(regId)))); + ip += 3; + addr = pos2adr(ip); + break; + } + if (((ip - 1 >= start) && (ip + 2 <= end)) + && (code.get(ip + 1).definition instanceof SetLocalTypeIns) + && (isKilled(((SetLocalTypeIns) code.get(ip + 1).definition).getRegisterId(code.get(ip + 1)), ip + 2, end))) { + int pos = -1; + for (int d = ip + 2; d <= end; d++) { + if (!((code.get(d).definition instanceof GetLocalTypeIns) + && (isKilled(((GetLocalTypeIns) code.get(d).definition).getRegisterId(code.get(d)), d + 1, end)))) { + pos = d; + break; + } + } + if (pos > -1) { + if (code.get(pos).definition instanceof SetTypeIns) { + TreeItem s = stack.pop(); + if (s instanceof DecrementTreeItem) { + stack.push(new PreDecrementTreeItem(insBefore, ((DecrementTreeItem) s).object)); + } + ip = pos + 1; + addr = pos2adr(ip); + break; + } + } + + } + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + } else if (insAfter.definition instanceof SetLocalTypeIns) { + //chained assignments + int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); + for (int t = ip + 1; t < end - 1; t++) { + if (code.get(t).definition instanceof GetLocalTypeIns) { + if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { + if (code.get(t + 1).definition instanceof KillIns) { + if (code.get(t + 1).operands[0] == reg) { + ConvertOutput assignment = toSource(isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames); + stack.push(assignment.output.remove(assignment.output.size() - 1)); + ip = t + 2; + continue iploop; + } + } + } + } + } + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + //} + + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip++; + addr = pos2adr(ip); + break; + //throw new ConvertException("Unknown pattern after DUP:" + insComparsion.toString()); + } + addr = addr + ins.getBytes().length + insAfter.getBytes().length + insAfter.operands[0]; + nextPos = adr2pos(addr) - 1; + if (isAnd) { + stack.add(new AndTreeItem(insAfter, stack.pop(), toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames).stack.pop())); + } else { + stack.add(new OrTreeItem(insAfter, stack.pop(), toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames).stack.pop())); + } + ins = code.get(nextPos + 1); + ip = nextPos + 1; + } while (ins.definition instanceof DupIns); + } else if (ins.definition instanceof IfTypeIns) { + int targetAddr = pos2adr(ip) + ins.getBytes().length + ins.operands[0]; + int targetIns = adr2pos(targetAddr); + ((IfTypeIns) ins.definition).translateInverted(localRegs, stack, ins); + + TreeItem condition = stack.pop(); + + if (condition.isFalse()) { + //ins.definition = new JumpIns(); + //continue; + } + if (condition.isTrue()) { + //ip = targetIns; + //continue; + } + //stack.add("if"+stack.pop()); + //stack.add("{"); + boolean hasElse = false; + boolean hasReturn = false; + if (code.get(targetIns - 1).definition instanceof JumpIns) { + + if ((targetIns - 2 > ip) && ((code.get(targetIns - 2).definition instanceof ReturnValueIns) || (code.get(targetIns - 2).definition instanceof ReturnVoidIns) || (code.get(targetIns - 2).definition instanceof ThrowIns))) { + hasElse = false; + hasReturn = true; + } else { + int jumpAddr = targetAddr + code.get(targetIns - 1).operands[0]; + int jumpPos = adr2pos(jumpAddr); + hasElse = true; + + for (Loop l : loopList) { + if (l.loopBreak == jumpPos) { + hasElse = false; + break; + } + } + if (hasElse) { + if (adr2pos(jumpAddr) > end + 1) { + hasElse = false; + //throw new ConvertException("Unknown pattern: forward jump outside of the block"); + } + } + } + } + ConvertOutput onTrue = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, ip + 1, targetIns - 1 - ((hasElse || hasReturn) ? 1 : 0), localRegNames); + addr = targetAddr; + ip = targetIns; + ConvertOutput onFalse = new ConvertOutput(new Stack(), new ArrayList()); + if (hasElse) { + int finalAddr = targetAddr + code.get(targetIns - 1).operands[0]; + int finalIns = adr2pos(finalAddr); + onFalse = toSource(isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, targetIns, finalIns - 1, localRegNames); + addr = finalAddr; + ip = finalIns; + } + if ((onTrue.stack.size() > 0) && (onFalse != null) && (onFalse.stack.size() > 0)) { + stack.add(new TernarOpTreeItem(ins, condition, onTrue.stack.pop(), onFalse.stack.pop())); + } else { + output.add(new IfTreeItem(ins, condition, onTrue.output, onFalse.output)); + } + + } else if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + ip = end + 1; + break; + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames); + + addr += ins.getBytes().length; + ip++; } - } catch (Exception ex) { - } - for (int p = 0; p < parts.length; p++) { - if(p==parts.length-1){ - if(parts[p].equals("")) - { - continue; + + } + if (debugMode) { + System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); + } + //clearKilledAssigments(output); + return new ConvertOutput(stack, output); + } catch (ConvertException cex) { + throw cex; + } catch (Exception ex) { + if (ex instanceof UnknownJumpException) { + throw (UnknownJumpException) ex; + } + throw new ConvertException(ex.getClass().getSimpleName(), ip); + } + } + + public String tabString(int len) { + String ret = ""; + for (int i = 0; i < len; i++) { + ret += ABC.IDENT_STRING; + } + return ret; + } + + public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap localRegNames) { + return toSource(isStatic, classIndex, abc, constants, method_info, body, false, localRegNames); + } + + public List toTree(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap localRegNames) { + toSourceCount = 0; + loopList = new ArrayList(); + unknownJumps = new ArrayList(); + parsedExceptions = new ArrayList(); + finallyJumps = new ArrayList(); + HashMap localRegs = new HashMap(); + try { + return toSource(isStatic, classIndex, localRegs, new Stack(), new Stack(), abc, constants, method_info, body, 0, code.size() - 1, localRegNames).output; + } catch (ConvertException ex) { + return new ArrayList(); + } + } + + public int getRegisterCount() { + int maxRegister = -1; + for (AVM2Instruction ins : code) { + int regId = -1; + if (ins.definition instanceof SetLocalTypeIns) { + regId = ((SetLocalTypeIns) ins.definition).getRegisterId(ins); + } + if (ins.definition instanceof GetLocalTypeIns) { + regId = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); + } + if (regId > maxRegister) { + maxRegister = regId; + } + } + return maxRegister + 1; + } + + public HashMap getLocalRegTypes(ConstantPool constants) { + HashMap ret = new HashMap(); + AVM2Instruction prev = null; + for (AVM2Instruction ins : code) { + if (ins.definition instanceof SetLocalTypeIns) { + if (prev != null) { + if (prev.definition instanceof CoerceOrConvertTypeIns) { + ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(constants, prev)); } } - String strippedP = Highlighting.stripHilights(parts[p]); - if (strippedP.endsWith(":") && (!strippedP.startsWith("case ")) && (!strippedP.equals("default:"))) { - String loopname = strippedP.substring(0, strippedP.length() - 1); - boolean dorefer = false; - for (int q = p + 1; q < parts.length; q++) { - String strippedQ = Highlighting.stripHilights(parts[q]); - if (strippedQ.equals("break " + loopname + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals("continue " + loopname + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals(":" + loopname)) { - break; - } - } - if (!dorefer) { - continue; - } - } - if (strippedP.startsWith(":")) { - continue; - } - if (strippedP.equals(IDENTOPEN)) { - level++; - } else if (strippedP.equals(IDENTCLOSE)) { - level--; - } else if (strippedP.equals("{")) { - level++; - sub += tabString(level) + parts[p] + "\r\n"; - level++; - } else if (strippedP.equals("}")||strippedP.equals("};")) { - level--; - sub += tabString(level) + parts[p] + "\r\n"; - level--; - } else { - sub += tabString(level) + parts[p] + "\r\n"; - } - } - if (!hilighted) { - sub = Highlighting.stripHilights(sub); - } - return sub; - } + } + prev = ins; + } + return ret; + } - public static void main(String[] args) { - FileInputStream fis = null; - try { - fis = new FileInputStream("src/asdec/abc/avm2/AVM2Code.java"); - byte[] data = new byte[fis.available()]; - fis.read(data); - - String content = new String(data); - Pattern partPat = Pattern.compile("private static InstructionDefinition instructionSet(.*)endoflist", Pattern.MULTILINE | Pattern.DOTALL); - Matcher m = partPat.matcher(content); - if (m.find()) { - System.out.println("1 found"); - content = m.group(1); - System.out.println(content); - Pattern part2Pat = Pattern.compile("new InstructionDefinition(\\([^\\)]*\"([^\"]*)\"[^\\)]*\\))\\{(.*)\\},", Pattern.MULTILINE | Pattern.DOTALL); - m = part2Pat.matcher(content); - while (m.find()) { - System.out.println("2 found"); - String superCall = m.group(1); - String name = m.group(2); - String methods = m.group(3); - FileOutputStream fos = new FileOutputStream("src/asdec/abc/avm2/instructions/generated/" + name + "Ins.java"); - String out = "public class " + name + "Ins extends InstructionDefinition {\r\n public " + name + "Ins(){\r\nsuper" + superCall + ";\r\n}" + methods + "}"; - fos.write(out.getBytes()); - fos.close(); - } - } - } catch (IOException ex) { - } finally { - try { - fis.close(); - } catch (IOException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public void removeInstruction(int pos, MethodBody body) { - if ((pos < 0) || (pos >= code.size())) { - throw new IndexOutOfBoundsException(); - } - int byteCount = code.get(pos).getBytes().length; - long remOffset = code.get(pos).offset; - for (int i = pos + 1; i < code.size(); i++) { - code.get(i).offset -= byteCount; - } - - for (ABCException ex : body.exceptions) { - if (ex.start > remOffset) { - ex.start -= byteCount; - } - if (ex.end > remOffset) { - ex.end -= byteCount; - } - if (ex.target > remOffset) { - ex.target -= byteCount; - } - } + public String toSource(boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap localRegNames) { + toSourceCount = 0; + loopList = new ArrayList(); + unknownJumps = new ArrayList(); + finallyJumps = new ArrayList(); + parsedExceptions = new ArrayList(); + ignoredIns = new ArrayList(); + List list; + String s = ""; + HashMap localRegs = new HashMap(); + try { + list = toSource(isStatic, classIndex, localRegs, new Stack(), new Stack(), abc, constants, method_info, body, 0, code.size() - 1, localRegNames).output; + s = listToString(list, constants, localRegNames); + } catch (Exception ex) { + s = "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex.getMessage() + "\r\n */"; + return s; + } - for (int i = 0; i < pos; i++) { - if (code.get(i).definition instanceof LookupSwitchIns) { - long target = code.get(i).offset + code.get(i).operands[0]; - if (target > remOffset) { - code.get(i).operands[0] -= byteCount; - } - for (int k = 2; k < code.get(i).operands.length; k++) { - target = code.get(i).offset + code.get(i).operands[k]; - if (target > remOffset) { - code.get(i).operands[k] -= byteCount; - } - } - } else { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target > remOffset) { - code.get(i).operands[j] -= byteCount; - } - } - } + String parts[] = s.split("\r\n"); + String sub = ""; + int level = 0; + for (int t = 0; t < body.traits.traits.length; t++) { + //Skip traits with same name as local registers + if ((body.traits.traits[t] instanceof TraitSlotConst) + && (((TraitSlotConst) body.traits.traits[t]).isVar()) + && (localRegNames.containsValue(((TraitSlotConst) body.traits.traits[t]).getName(constants)))) { + continue; + } else { + sub += body.traits.traits[t].convert(constants, method_info, abc) + ";\r\n"; + } + } + int regCount = getRegisterCount(); + int paramCount = 0; + if (body.method_info != -1) { + MethodInfo mi = method_info[body.method_info]; + paramCount = mi.param_types.length; + if (mi.flagNeed_rest()) { + paramCount++; + } + } + HashMap localRegTypes = getLocalRegTypes(constants); + for (int i = paramCount + 1; i < regCount; i++) { + if ((!(localRegs.get(i) instanceof NewActivationTreeItem))/*&&(!isKilled(i, 0, code.size()-1))*/) { + sub += "var " + TreeItem.localRegName(localRegNames, i); + if (localRegTypes.containsKey(i)) { + sub += ":" + localRegTypes.get(i); } - } - for (int i = pos + 1; i < code.size(); i++) { - if (code.get(i).definition instanceof LookupSwitchIns) { - long target = code.get(i).offset + code.get(i).operands[0]; - if (target < remOffset) { - code.get(i).operands[0] += byteCount; - } - for (int k = 2; k < code.get(i).operands.length; k++) { - target = code.get(i).offset + code.get(i).operands[k]; - if (target < remOffset) { - code.get(i).operands[k] += byteCount; - } - } - } else { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target < remOffset) { - code.get(i).operands[j] += byteCount; - } - } - } + sub += ";\r\n"; + } + } + try { + Stack loopStack = new Stack(); + for (int p = 0; p < parts.length; p++) { + String stripped = Highlighting.stripHilights(parts[p]); + if (stripped.endsWith(":") && (!stripped.startsWith("case ")) && (!stripped.equals("default:"))) { + loopStack.add(stripped.substring(0, stripped.length() - 1)); } - } + if (stripped.startsWith("break ")) { + if (stripped.equals("break " + loopStack.peek() + ";")) { + parts[p] = parts[p].replace(" " + loopStack.peek(), ""); + } + } + if (stripped.startsWith("continue ")) { + if (loopStack.size() > 0) { + if (stripped.equals("continue " + loopStack.peek() + ";")) { + parts[p] = parts[p].replace(" " + loopStack.peek(), ""); + } + } + } + if (stripped.startsWith(":")) { + loopStack.pop(); + } + } + } catch (Exception ex) { + } + for (int p = 0; p < parts.length; p++) { + if (p == parts.length - 1) { + if (parts[p].equals("")) { + continue; + } + } + String strippedP = Highlighting.stripHilights(parts[p]); + if (strippedP.endsWith(":") && (!strippedP.startsWith("case ")) && (!strippedP.equals("default:"))) { + String loopname = strippedP.substring(0, strippedP.length() - 1); + boolean dorefer = false; + for (int q = p + 1; q < parts.length; q++) { + String strippedQ = Highlighting.stripHilights(parts[q]); + if (strippedQ.equals("break " + loopname + ";")) { + dorefer = true; + break; + } + if (strippedQ.equals("continue " + loopname + ";")) { + dorefer = true; + break; + } + if (strippedQ.equals(":" + loopname)) { + break; + } + } + if (!dorefer) { + continue; + } + } + if (strippedP.startsWith(":")) { + continue; + } + if (strippedP.equals(IDENTOPEN)) { + level++; + } else if (strippedP.equals(IDENTCLOSE)) { + level--; + } else if (strippedP.equals("{")) { + level++; + sub += tabString(level) + parts[p] + "\r\n"; + level++; + } else if (strippedP.equals("}") || strippedP.equals("};")) { + level--; + sub += tabString(level) + parts[p] + "\r\n"; + level--; + } else { + sub += tabString(level) + parts[p] + "\r\n"; + } + } + if (!hilighted) { + sub = Highlighting.stripHilights(sub); + } + return sub; + } - code.remove(pos); + public static void main(String[] args) { + FileInputStream fis = null; + try { + fis = new FileInputStream("src/asdec/abc/avm2/AVM2Code.java"); + byte[] data = new byte[fis.available()]; + fis.read(data); - } + String content = new String(data); + Pattern partPat = Pattern.compile("private static InstructionDefinition instructionSet(.*)endoflist", Pattern.MULTILINE | Pattern.DOTALL); + Matcher m = partPat.matcher(content); + if (m.find()) { + System.out.println("1 found"); + content = m.group(1); + System.out.println(content); + Pattern part2Pat = Pattern.compile("new InstructionDefinition(\\([^\\)]*\"([^\"]*)\"[^\\)]*\\))\\{(.*)\\},", Pattern.MULTILINE | Pattern.DOTALL); + m = part2Pat.matcher(content); + while (m.find()) { + System.out.println("2 found"); + String superCall = m.group(1); + String name = m.group(2); + String methods = m.group(3); + FileOutputStream fos = new FileOutputStream("src/asdec/abc/avm2/instructions/generated/" + name + "Ins.java"); + String out = "public class " + name + "Ins extends InstructionDefinition {\r\n public " + name + "Ins(){\r\nsuper" + superCall + ";\r\n}" + methods + "}"; + fos.write(out.getBytes()); + fos.close(); + } + } + } catch (IOException ex) { + } finally { + try { + fis.close(); + } catch (IOException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex); + } + } + } - public void insertInstruction(int pos, AVM2Instruction instruction) { - if (pos < 0) { - pos = 0; - } - if (pos > code.size()) { - pos = code.size(); - } - int byteCount = instruction.getBytes().length; - if (pos == code.size()) { - instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytes().length; - } else { - instruction.offset = code.get(pos).offset; - } + public void removeInstruction(int pos, MethodBody body) { + if ((pos < 0) || (pos >= code.size())) { + throw new IndexOutOfBoundsException(); + } + int byteCount = code.get(pos).getBytes().length; + long remOffset = code.get(pos).offset; + for (int i = pos + 1; i < code.size(); i++) { + code.get(i).offset -= byteCount; + } - for (int i = 0; i < pos; i++) { + for (ABCException ex : body.exceptions) { + if (ex.start > remOffset) { + ex.start -= byteCount; + } + if (ex.end > remOffset) { + ex.end -= byteCount; + } + if (ex.target > remOffset) { + ex.target -= byteCount; + } + } + + + for (int i = 0; i < pos; i++) { + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target > remOffset) { + code.get(i).operands[0] -= byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; + if (target > remOffset) { + code.get(i).operands[k] -= byteCount; + } + } + } else { for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target >= instruction.offset) { - code.get(i).operands[j] += byteCount; - } - } + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target > remOffset) { + code.get(i).operands[j] -= byteCount; + } + } } - } - for (int i = pos; i < code.size(); i++) { + } + } + for (int i = pos + 1; i < code.size(); i++) { + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target < remOffset) { + code.get(i).operands[0] += byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; + if (target < remOffset) { + code.get(i).operands[k] += byteCount; + } + } + } else { for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target < instruction.offset) { - code.get(i).operands[j] -= byteCount; - } - } + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target < remOffset) { + code.get(i).operands[j] += byteCount; + } + } } - } + } + } - for (int i = pos + 1; i < code.size(); i++) { - code.get(i).offset += byteCount; - } - code.add(pos, instruction); - } + code.remove(pos); - private void removeFreeBlocks(ConstantPool constants, MethodBody body) throws ConvertException { - List offsets = new ArrayList(); - for (AVM2Instruction ins : code) { - offsets.addAll(ins.getOffsets()); - } - for (ABCException ex : body.exceptions) { - offsets.add((long) ex.start); - offsets.add((long) ex.end); - offsets.add((long) ex.target); - } + } - int clearedCount = 0; - loopip: - for (int ip = 0; ip < code.size(); ip++) { - AVM2Instruction ins = code.get(ip); - if (ins.definition instanceof JumpIns) { - int secondAddr = pos2adr(ip + 1); - int jumpAddr = secondAddr + ins.operands[0]; - int jumpPos = adr2pos(jumpAddr); - if (jumpPos <= ip) { - continue; - } - if (jumpPos > code.size()) { - continue; - } - for (int k = ip + 1; k < jumpPos; k++) { - if (offsets.contains((long) pos2adr(k))) { - continue loopip; - } - } - for (int k = ip; k < jumpPos; k++) { - removeInstruction(ip, body); - clearedCount++; - } - offsets.clear(); - for (AVM2Instruction ins2 : code) { - offsets.addAll(ins2.getOffsets()); - } - for (ABCException ex : body.exceptions) { - offsets.add((long) ex.start); - offsets.add((long) ex.end); - offsets.add((long) ex.target); - } - ip--; - //ip=jumpPos; + public void insertInstruction(int pos, AVM2Instruction instruction) { + if (pos < 0) { + pos = 0; + } + if (pos > code.size()) { + pos = code.size(); + } + int byteCount = instruction.getBytes().length; + if (pos == code.size()) { + instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytes().length; + } else { + instruction.offset = code.get(pos).offset; + } + + for (int i = 0; i < pos; i++) { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target >= instruction.offset) { + code.get(i).operands[j] += byteCount; + } } - } - if (clearedCount > 0) { - //System.out.println("Cleared " + clearedCount + " lines of code TO:"); - //System.out.println(toASMSource(constants)); - //System.exit(1); - } - } + } + } + for (int i = pos; i < code.size(); i++) { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target < instruction.offset) { + code.get(i).operands[j] -= byteCount; + } + } + } + } - public void clearSecureSWF(ConstantPool constants, MethodBody body) throws ConvertException { - if (code.size() > 4) { - AVM2Instruction first = code.get(0); - AVM2Instruction second = code.get(1); - boolean firstValue = false; - boolean secondValue = false; - boolean isSecure = true; - if (first.definition instanceof PushFalseIns) { - firstValue = false; - } else if (first.definition instanceof PushTrueIns) { - firstValue = true; + for (int i = pos + 1; i < code.size(); i++) { + code.get(i).offset += byteCount; + } + code.add(pos, instruction); + } + + private void removeFreeBlocks(ConstantPool constants, MethodBody body) throws ConvertException { + List offsets = new ArrayList(); + for (AVM2Instruction ins : code) { + offsets.addAll(ins.getOffsets()); + } + for (ABCException ex : body.exceptions) { + offsets.add((long) ex.start); + offsets.add((long) ex.end); + offsets.add((long) ex.target); + } + + int clearedCount = 0; + loopip: + for (int ip = 0; ip < code.size(); ip++) { + AVM2Instruction ins = code.get(ip); + if (ins.definition instanceof JumpIns) { + int secondAddr = pos2adr(ip + 1); + int jumpAddr = secondAddr + ins.operands[0]; + int jumpPos = adr2pos(jumpAddr); + if (jumpPos <= ip) { + continue; + } + if (jumpPos > code.size()) { + continue; + } + for (int k = ip + 1; k < jumpPos; k++) { + if (offsets.contains((long) pos2adr(k))) { + continue loopip; + } + } + for (int k = ip; k < jumpPos; k++) { + removeInstruction(ip, body); + clearedCount++; + } + offsets.clear(); + for (AVM2Instruction ins2 : code) { + offsets.addAll(ins2.getOffsets()); + } + for (ABCException ex : body.exceptions) { + offsets.add((long) ex.start); + offsets.add((long) ex.end); + offsets.add((long) ex.target); + } + ip--; + //ip=jumpPos; + } + } + if (clearedCount > 0) { + //System.out.println("Cleared " + clearedCount + " lines of code TO:"); + //System.out.println(toASMSource(constants)); + //System.exit(1); + } + } + + public void clearSecureSWF(ConstantPool constants, MethodBody body) throws ConvertException { + if (code.size() > 4) { + AVM2Instruction first = code.get(0); + AVM2Instruction second = code.get(1); + boolean firstValue = false; + boolean secondValue = false; + boolean isSecure = true; + if (first.definition instanceof PushFalseIns) { + firstValue = false; + } else if (first.definition instanceof PushTrueIns) { + firstValue = true; + } else { + isSecure = false; + } + if (isSecure) { + if (second.definition instanceof PushFalseIns) { + secondValue = false; + } else if (second.definition instanceof PushTrueIns) { + secondValue = true; } else { - isSecure = false; + isSecure = false; } if (isSecure) { - if (second.definition instanceof PushFalseIns) { - secondValue = false; - } else if (second.definition instanceof PushTrueIns) { - secondValue = true; - } else { - isSecure = false; - } - if (isSecure) { - AVM2Instruction third = code.get(2); - int pos = 2; - if (third.definition instanceof SwapIns) { - pos++; - boolean dup = firstValue; - firstValue = secondValue; - secondValue = dup; - } - AVM2Instruction firstSet = code.get(pos); - AVM2Instruction secondSet = code.get(pos + 1); - int trueIndex = -1; - int falseIndex = -1; - if (firstSet.definition instanceof SetLocalTypeIns) { - if (secondValue == true) { - trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - if (secondValue == false) { - falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - } else { - isSecure = false; - } - if (isSecure) { - if (secondSet.definition instanceof SetLocalTypeIns) { - if (firstValue == true) { - trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(firstSet); - } - if (firstValue == false) { - falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(firstSet); - } - - //Yes, secure - pos += 2; - for (int i = 0; i < pos; i++) { - code.get(i).ignored = true; - //removeInstruction(0, body); - } - System.out.println("trueIndex:" + trueIndex); - System.out.println("falseIndex:" + falseIndex); - boolean found = false; - do { - found = false; - for (int ip = pos; ip < code.size(); ip++) { - if (code.get(ip).ignored) continue; - if (code.get(ip).definition instanceof GetLocalTypeIns) { - int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); - if ((regIndex == trueIndex) || (regIndex == falseIndex)) { - found = true; - Stack myStack = new Stack(); - do { - AVM2Instruction ins = code.get(ip); - if (ins.ignored) { - ip++; - continue; - } else if (ins.definition instanceof GetLocalTypeIns) { - regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); - if (regIndex == trueIndex) myStack.push(true); - if (regIndex == falseIndex) myStack.push(false); - ip++; - ins.ignored = true; - } else if (ins.definition instanceof DupIns) { - Boolean b = myStack.pop(); - myStack.push(b); - myStack.push(b); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof PopIns) { - myStack.pop(); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof IfTrueIns) { - System.out.println("iftrue found"); - boolean val = myStack.pop(); - if (val) { - code.get(ip).definition = new JumpIns(); - System.out.println("changed to jump"); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof IfFalseIns) { - boolean val = myStack.pop(); - if (!val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof JumpIns) { - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - - } - - } while (myStack.size() > 0); - - /*for(int rem=code.size();rem>=0;rem--){ - if(code.get(rem).ignored){ - code.remove(rem); - } - } */ - break; - } + AVM2Instruction third = code.get(2); + int pos = 2; + if (third.definition instanceof SwapIns) { + pos++; + boolean dup = firstValue; + firstValue = secondValue; + secondValue = dup; + } + AVM2Instruction firstSet = code.get(pos); + AVM2Instruction secondSet = code.get(pos + 1); + int trueIndex = -1; + int falseIndex = -1; + if (firstSet.definition instanceof SetLocalTypeIns) { + if (secondValue == true) { + trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + if (secondValue == false) { + falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + } else { + isSecure = false; + } + if (isSecure) { + if (secondSet.definition instanceof SetLocalTypeIns) { + if (firstValue == true) { + trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(firstSet); + } + if (firstValue == false) { + falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(firstSet); + } + //Yes, secure + pos += 2; + for (int i = 0; i < pos; i++) { + code.get(i).ignored = true; + //removeInstruction(0, body); + } + System.out.println("trueIndex:" + trueIndex); + System.out.println("falseIndex:" + falseIndex); + boolean found = false; + do { + found = false; + for (int ip = pos; ip < code.size(); ip++) { + if (code.get(ip).ignored) { + continue; + } + if (code.get(ip).definition instanceof GetLocalTypeIns) { + int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); + if ((regIndex == trueIndex) || (regIndex == falseIndex)) { + found = true; + Stack myStack = new Stack(); + do { + AVM2Instruction ins = code.get(ip); + if (ins.ignored) { + ip++; + continue; + } else if (ins.definition instanceof GetLocalTypeIns) { + regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); + if (regIndex == trueIndex) { + myStack.push(true); + } + if (regIndex == falseIndex) { + myStack.push(false); + } + ip++; + ins.ignored = true; + } else if (ins.definition instanceof DupIns) { + Boolean b = myStack.pop(); + myStack.push(b); + myStack.push(b); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof PopIns) { + myStack.pop(); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof IfTrueIns) { + System.out.println("iftrue found"); + boolean val = myStack.pop(); + if (val) { + code.get(ip).definition = new JumpIns(); + System.out.println("changed to jump"); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof IfFalseIns) { + boolean val = myStack.pop(); + if (!val) { + code.get(ip).definition = new JumpIns(); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof JumpIns) { + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { } - } - } - while (found); - } else { - isSecure = false; + + } while (myStack.size() > 0); + + /*for(int rem=code.size();rem>=0;rem--){ + if(code.get(rem).ignored){ + code.remove(rem); + } + } */ + break; + } + + } } - } + } while (found); + } else { + isSecure = false; + } + } - } } - } - } + } + } + } - public void clearCode(ConstantPool constants, MethodBody body) throws ConvertException { + public void clearCode(ConstantPool constants, MethodBody body) throws ConvertException { - if (code.size() > 3) { - if (code.get(0).definition instanceof PushByteIns) { - if (code.get(1).definition instanceof PushByteIns) { - if (code.get(2).definition instanceof IfNeIns) { - if (code.get(0).operands[0] != code.get(1).operands[0]) { - int targetAddr = pos2adr(2) + code.get(2).getBytes().length + code.get(2).operands[0]; - int targetPos = adr2pos(targetAddr); - for (int i = 0; i < targetPos; i++) { - removeInstruction(0, body); - } - } - } - } + if (code.size() > 3) { + if (code.get(0).definition instanceof PushByteIns) { + if (code.get(1).definition instanceof PushByteIns) { + if (code.get(2).definition instanceof IfNeIns) { + if (code.get(0).operands[0] != code.get(1).operands[0]) { + int targetAddr = pos2adr(2) + code.get(2).getBytes().length + code.get(2).operands[0]; + int targetPos = adr2pos(targetAddr); + for (int i = 0; i < targetPos; i++) { + removeInstruction(0, body); + } + } + } } - } + } + } - removeFreeBlocks(constants, body); - //clearSecureSWF(constants, body); + removeFreeBlocks(constants, body); + //clearSecureSWF(constants, body); - } + } - private void handleRegister(CodeStats stats,int reg){ - if(reg+1>stats.maxlocal){ - stats.maxlocal=reg+1; - } - } + private void handleRegister(CodeStats stats, int reg) { + if (reg + 1 > stats.maxlocal) { + stats.maxlocal = reg + 1; + } + } - private boolean walkCode(CodeStats stats,int pos,int stack,int scope,ABC abc) { - while(posstats.maxstack) stats.maxstack=stack; - if(scope>stats.maxscope) stats.maxscope=scope; - if((ins.definition instanceof DXNSIns)||(ins.definition instanceof DXNSLateIns)){ - stats.has_set_dxns=true; - } - if(ins.definition instanceof NewActivationIns){ - stats.has_activation=true; - } - if(ins.definition instanceof SetLocalTypeIns){ - handleRegister(stats,((SetLocalTypeIns)ins.definition).getRegisterId(ins)); - }else{ - for(int i=0;i stats.maxstack) { + stats.maxstack = stack; + } + if (scope > stats.maxscope) { + stats.maxscope = scope; + } + if ((ins.definition instanceof DXNSIns) || (ins.definition instanceof DXNSLateIns)) { + stats.has_set_dxns = true; + } + if (ins.definition instanceof NewActivationIns) { + stats.has_activation = true; + } + if (ins.definition instanceof SetLocalTypeIns) { + handleRegister(stats, ((SetLocalTypeIns) ins.definition).getRegisterId(ins)); + } else { + for (int i = 0; i < ins.definition.operands.length; i++) { + if (ins.definition.operands[i] == DAT_REGISTER_INDEX) { + handleRegister(stats, ins.operands[i]); + } + } + } + if (ins.definition instanceof ReturnValueIns) { + //check stack=1 + return true; + } + if (ins.definition instanceof ReturnVoidIns) { + //check stack=0 + return true; + } + if (ins.definition instanceof JumpIns) { try { pos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); continue; } catch (ConvertException ex) { return false; } - }else - if(ins.definition instanceof IfTypeIns){ - try { + } else if (ins.definition instanceof IfTypeIns) { + try { int newpos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); walkCode(stats, newpos, stack, scope, abc); - } catch (ConvertException ex) { - return false; - } - } - if(ins.definition instanceof LookupSwitchIns){ - for(int i=0;i. */ - package com.jpexs.asdec.abc.avm2; import com.jpexs.asdec.abc.ABC; @@ -24,35 +23,33 @@ import com.jpexs.asdec.abc.ABC; * @author JPEXS */ public class CodeStats { - public int maxstack=0; - public int maxscope=0; - public int maxlocal=0; - public boolean has_set_dxns=false; - public boolean has_activation=false; + + public int maxstack = 0; + public int maxscope = 0; + public int maxlocal = 0; + public boolean has_set_dxns = false; + public boolean has_activation = false; public InstructionStats instructionStats[]; public String toString(ABC abc) { - String ret="Stats: maxstack="+maxstack+", maxscope="+maxscope+", maxlocal="+maxlocal+"\r\n"; - int i=0; - int ms=0; - for(InstructionStats stats:instructionStats){ - int deltastack=stats.ins.definition.getStackDelta(stats.ins, abc); - if(stats.stackpos>ms) ms=stats.stackpos; - ret+=""+i+":"+stats.stackpos+(deltastack>=0?"+"+deltastack:deltastack)+","+stats.scopepos+" "+stats.ins.toString(abc.constants)+"\r\n"; + String ret = "Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal + "\r\n"; + int i = 0; + int ms = 0; + for (InstructionStats stats : instructionStats) { + int deltastack = stats.ins.definition.getStackDelta(stats.ins, abc); + if (stats.stackpos > ms) { + ms = stats.stackpos; + } + ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(abc.constants) + "\r\n"; i++; } return ret; } - - public CodeStats(AVM2Code code) { - instructionStats=new InstructionStats[code.code.size()]; - for(int i=0;i. */ - package com.jpexs.asdec.abc.avm2; import com.jpexs.asdec.abc.types.Decimal; @@ -25,145 +24,143 @@ import java.io.OutputStream; import java.io.PrintStream; import java.util.Arrays; - public class ConstantPool { - public long constant_int[]; - public long constant_uint[]; - public double constant_double[]; - /* Only for some minor versions */ - public Decimal constant_decimal[]; - public String constant_string[]; - public Namespace constant_namespace[]; - public NamespaceSet constant_namespace_set[]; - public Multiname constant_multiname[]; - public int addInt(long value) { - constant_int = Arrays.copyOf(constant_int, constant_int.length + 1); - constant_int[constant_int.length - 1] = value; - return constant_int.length - 1; - } + public long constant_int[]; + public long constant_uint[]; + public double constant_double[]; + /* Only for some minor versions */ + public Decimal constant_decimal[]; + public String constant_string[]; + public Namespace constant_namespace[]; + public NamespaceSet constant_namespace_set[]; + public Multiname constant_multiname[]; - public int addUInt(long value) { - constant_uint = Arrays.copyOf(constant_uint, constant_uint.length + 1); - constant_uint[constant_uint.length - 1] = value; - return constant_uint.length - 1; - } + public int addInt(long value) { + constant_int = Arrays.copyOf(constant_int, constant_int.length + 1); + constant_int[constant_int.length - 1] = value; + return constant_int.length - 1; + } - public int addDouble(double value) { - constant_double = Arrays.copyOf(constant_double, constant_double.length + 1); - constant_double[constant_double.length - 1] = value; - return constant_double.length - 1; - } + public int addUInt(long value) { + constant_uint = Arrays.copyOf(constant_uint, constant_uint.length + 1); + constant_uint[constant_uint.length - 1] = value; + return constant_uint.length - 1; + } - public int addString(String value) { - constant_string = Arrays.copyOf(constant_string, constant_string.length + 1); - constant_string[constant_string.length - 1] = value; - return constant_string.length - 1; - } + public int addDouble(double value) { + constant_double = Arrays.copyOf(constant_double, constant_double.length + 1); + constant_double[constant_double.length - 1] = value; + return constant_double.length - 1; + } - public int getIntId(long value) { - for (int i = 1; i < constant_int.length; i++) { - if (constant_int[i] == value) { - return i; - } - } - return 0; - } + public int addString(String value) { + constant_string = Arrays.copyOf(constant_string, constant_string.length + 1); + constant_string[constant_string.length - 1] = value; + return constant_string.length - 1; + } - public int getUIntId(long value) { - for (int i = 1; i < constant_uint.length; i++) { - if (constant_uint[i] == value) { - return i; - } - } - return 0; - } + public int getIntId(long value) { + for (int i = 1; i < constant_int.length; i++) { + if (constant_int[i] == value) { + return i; + } + } + return 0; + } - public int getDoubleId(double value) { - for (int i = 1; i < constant_double.length; i++) { - if (constant_double[i] == value) { - return i; - } - } - return 0; - } + public int getUIntId(long value) { + for (int i = 1; i < constant_uint.length; i++) { + if (constant_uint[i] == value) { + return i; + } + } + return 0; + } - public int getStringId(String s) { - for (int i = 1; i < constant_string.length; i++) { - if (constant_string[i].equals(s)) { - return i; - } - } - return 0; - } + public int getDoubleId(double value) { + for (int i = 1; i < constant_double.length; i++) { + if (constant_double[i] == value) { + return i; + } + } + return 0; + } - public int getMultiNameId(String s) { - for (int i = 1; i < constant_multiname.length; i++) { - if (constant_multiname[i].getName(this).equals(s)) { - return i; - } - } - return 0; - } + public int getStringId(String s) { + for (int i = 1; i < constant_string.length; i++) { + if (constant_string[i].equals(s)) { + return i; + } + } + return 0; + } - public int forceGetStringId(String val){ - int id=getStringId(val); - if(id==0){ - id=addString(val); - } - return id; - } + public int getMultiNameId(String s) { + for (int i = 1; i < constant_multiname.length; i++) { + if (constant_multiname[i].getName(this).equals(s)) { + return i; + } + } + return 0; + } - public int forceGetIntId(long val){ - int id=getIntId(val); - if(id==0){ - id=addInt(val); - } - return id; - } + public int forceGetStringId(String val) { + int id = getStringId(val); + if (id == 0) { + id = addString(val); + } + return id; + } - public int forceGetUIntId(long val){ - int id=getUIntId(val); - if(id==0){ - id=addUInt(val); - } - return id; - } + public int forceGetIntId(long val) { + int id = getIntId(val); + if (id == 0) { + id = addInt(val); + } + return id; + } - public int forceGetDoubleId(double val){ - int id=getDoubleId(val); - if(id==0){ - id=addDouble(val); - } - return id; - } + public int forceGetUIntId(long val) { + int id = getUIntId(val); + if (id == 0) { + id = addUInt(val); + } + return id; + } - public void dump(OutputStream os) { - PrintStream output = new PrintStream(os); - String s = ""; - for (int i = 1; i < constant_int.length; i++) { - output.println("INT[" + i + "]=" + constant_int[i]); - } - for (int i = 1; i < constant_uint.length; i++) { - output.println("UINT[" + i + "]=" + constant_uint[i]); - } - for (int i = 1; i < constant_double.length; i++) { - output.println("Double[" + i + "]=" + constant_double[i]); - } - for (int i = 1; i < constant_string.length; i++) { - output.println("String[" + i + "]=" + constant_string[i]); - } - for (int i = 1; i < constant_namespace.length; i++) { - output.println("Namespace[" + i + "]=" + constant_namespace[i].toString(this)); - } - for (int i = 1; i < constant_namespace_set.length; i++) { - output.println("NamespaceSet[" + i + "]=" + constant_namespace_set[i].toString(this)); - } - - for (int i = 1; i < constant_multiname.length; i++) { - output.println("Multiname[" + i + "]=" + constant_multiname[i].toString(this)); - } - } + public int forceGetDoubleId(double val) { + int id = getDoubleId(val); + if (id == 0) { + id = addDouble(val); + } + return id; + } + public void dump(OutputStream os) { + PrintStream output = new PrintStream(os); + String s = ""; + for (int i = 1; i < constant_int.length; i++) { + output.println("INT[" + i + "]=" + constant_int[i]); + } + for (int i = 1; i < constant_uint.length; i++) { + output.println("UINT[" + i + "]=" + constant_uint[i]); + } + for (int i = 1; i < constant_double.length; i++) { + output.println("Double[" + i + "]=" + constant_double[i]); + } + for (int i = 1; i < constant_string.length; i++) { + output.println("String[" + i + "]=" + constant_string[i]); + } + for (int i = 1; i < constant_namespace.length; i++) { + output.println("Namespace[" + i + "]=" + constant_namespace[i].toString(this)); + } + for (int i = 1; i < constant_namespace_set.length; i++) { + output.println("NamespaceSet[" + i + "]=" + constant_namespace_set[i].toString(this)); + } + for (int i = 1; i < constant_multiname.length; i++) { + output.println("Multiname[" + i + "]=" + constant_multiname[i].toString(this)); + } + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/ConvertException.java b/trunk/src/com/jpexs/asdec/abc/avm2/ConvertException.java index c43acb94d..24f4bff21 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/ConvertException.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/ConvertException.java @@ -14,14 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; - public class ConvertException extends Exception { - public int line; - public ConvertException(String s,int line) { - super(s+" on line "+line); - this.line=line; - } + + public int line; + + public ConvertException(String s, int line) { + super(s + " on line " + line); + this.line = line; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/InstructionStats.java b/trunk/src/com/jpexs/asdec/abc/avm2/InstructionStats.java index d8134337f..d03aa8f4d 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/InstructionStats.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/InstructionStats.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -24,14 +23,13 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; * @author JPEXS */ public class InstructionStats { - public boolean seen=false; - public int stackpos=0; - public int scopepos=0; + + public boolean seen = false; + public int stackpos = 0; + public int scopepos = 0; public AVM2Instruction ins; public InstructionStats(AVM2Instruction ins) { this.ins = ins; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/InvalidInstructionArguments.java b/trunk/src/com/jpexs/asdec/abc/avm2/InvalidInstructionArguments.java index 7df6bb426..6ea0a0d0e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/InvalidInstructionArguments.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/InvalidInstructionArguments.java @@ -14,14 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; - public class InvalidInstructionArguments extends RuntimeException { - public InvalidInstructionArguments() { - super("Invalid method arguments"); - } - + public InvalidInstructionArguments() { + super("Invalid method arguments"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/LocalDataArea.java b/trunk/src/com/jpexs/asdec/abc/avm2/LocalDataArea.java index 7846eaec0..499f2524f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/LocalDataArea.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/LocalDataArea.java @@ -14,16 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; import java.util.HashMap; import java.util.Stack; - public class LocalDataArea { - public Stack operandStack = new Stack(); - public Stack scopeStack = new Stack(); - public HashMap localRegisters = new HashMap(); + public Stack operandStack = new Stack(); + public Stack scopeStack = new Stack(); + public HashMap localRegisters = new HashMap(); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/UnknownInstructionCode.java b/trunk/src/com/jpexs/asdec/abc/avm2/UnknownInstructionCode.java index fd651d121..454c79775 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/UnknownInstructionCode.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/UnknownInstructionCode.java @@ -14,15 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; - public class UnknownInstructionCode extends RuntimeException { - public int code; - public UnknownInstructionCode(int code) { - super("Unknown instruction code: 0x" + Integer.toHexString(code)); - this.code = code; - } + public int code; + + public UnknownInstructionCode(int code) { + super("Unknown instruction code: 0x" + Integer.toHexString(code)); + this.code = code; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/UnknownJumpException.java b/trunk/src/com/jpexs/asdec/abc/avm2/UnknownJumpException.java index d45968f5d..49a1c5b7f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/UnknownJumpException.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/UnknownJumpException.java @@ -14,29 +14,26 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.List; import java.util.Stack; - public class UnknownJumpException extends RuntimeException { - public Stack stack; - public int ip; - public List output; - public UnknownJumpException(Stack stack, int ip, List output) { - this.stack = stack; - this.ip = ip; - this.output = output; - } - - @Override - public String toString() { - return "Unknown jump to " + ip; - } + public Stack stack; + public int ip; + public List output; + public UnknownJumpException(Stack stack, int ip, List output) { + this.stack = stack; + this.ip = ip; + this.output = output; + } + @Override + public String toString() { + return "Unknown jump to " + ip; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java index 95460b080..2b917e1bd 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/Graph.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.flowgraph; import com.jpexs.asdec.abc.avm2.AVM2Code; @@ -40,179 +39,177 @@ import java.util.logging.Logger; */ public class Graph { - public GraphPart head; - public List ignored = new ArrayList(); - private int trueReg = -1; - private int falseReg = -1; + public GraphPart head; + public List ignored = new ArrayList(); + private int trueReg = -1; + private int falseReg = -1; - public Graph(AVM2Code code) { - int start = checkSWFSecureStart(code); - head=makeGraph(new Stack(), code, start, new ArrayList()); - } + public Graph(AVM2Code code) { + int start = checkSWFSecureStart(code); + head = makeGraph(new Stack(), code, start, new ArrayList()); + } - private int checkSWFSecureStart(AVM2Code code) { - if (code.code.size() < 2) { - return 0; - } - if (!((code.code.get(0).definition instanceof PushFalseIns) || (code.code.get(0).definition instanceof PushTrueIns))) { - return 0; - } - if (!((code.code.get(1).definition instanceof PushFalseIns) || (code.code.get(1).definition instanceof PushTrueIns))) { - return 0; - } - int pos = 2; - Stack myStack = new Stack(); - int ip = 0; - int setCount = 0; - while (ip < code.code.size()) { - if (code.code.get(ip).definition instanceof PushFalseIns) { - myStack.push(Boolean.FALSE); - } else if (code.code.get(ip).definition instanceof PushTrueIns) { - myStack.push(Boolean.TRUE); + private int checkSWFSecureStart(AVM2Code code) { + if (code.code.size() < 2) { + return 0; + } + if (!((code.code.get(0).definition instanceof PushFalseIns) || (code.code.get(0).definition instanceof PushTrueIns))) { + return 0; + } + if (!((code.code.get(1).definition instanceof PushFalseIns) || (code.code.get(1).definition instanceof PushTrueIns))) { + return 0; + } + int pos = 2; + Stack myStack = new Stack(); + int ip = 0; + int setCount = 0; + while (ip < code.code.size()) { + if (code.code.get(ip).definition instanceof PushFalseIns) { + myStack.push(Boolean.FALSE); + } else if (code.code.get(ip).definition instanceof PushTrueIns) { + myStack.push(Boolean.TRUE); + } else if (code.code.get(ip).definition instanceof SwapIns) { + Boolean b1 = myStack.pop(); + Boolean b2 = myStack.pop(); + myStack.push(b1); + myStack.push(b2); + } else if (code.code.get(ip).definition instanceof JumpIns) { + try { + ip = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); + } catch (ConvertException ex) { + Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, null, ex); + } + continue; + } else if (code.code.get(ip).definition instanceof SetLocalTypeIns) { + Boolean val = myStack.pop(); + if (val == true) { + trueReg = ((SetLocalTypeIns) code.code.get(ip).definition).getRegisterId(code.code.get(ip)); + } else { + falseReg = ((SetLocalTypeIns) code.code.get(ip).definition).getRegisterId(code.code.get(ip)); + } + setCount++; + if (setCount == 2) { + return ip + 1; + } + } + ip++; + } + return 0; + } + + private GraphPart makeGraph(Stack myStack, AVM2Code code, int start, List allBlocks) { + GraphPart ret = new GraphPart(start, -1); + ret.instanceCount = 1; + allBlocks.add(ret); + GraphPart actual = ret; + try { + int ip = start; + while (ip < code.code.size()) { + for (GraphPart block : allBlocks) { + if (block.containsIP(ip)) { + if (block.start < ip) { + int oldEnd = block.end; + block.end = ip - 1; + GraphPart newBlock = new GraphPart(ip, oldEnd); + newBlock.nextParts.addAll(block.nextParts); + newBlock.instanceCount = 1; + block.nextParts.clear(); + block.nextParts.add(newBlock); + allBlocks.add(newBlock); + block = newBlock; + } + block.instanceCount++; + if (start < ip) { + actual.end = ip - 1; + actual.nextParts.add(block); + return ret; + } else { + return block; + } + + } + } + boolean forceJump = false; + boolean forceSkip = false; + if (code.code.get(ip).definition instanceof IfTrueIns) { + if (!myStack.empty()) { + if (myStack.pop() == true) { + forceJump = true; + } else { + forceSkip = true; + } + } + } + if (code.code.get(ip).definition instanceof IfFalseIns) { + if (!myStack.empty()) { + if (myStack.pop() == false) { + forceJump = true; + } else { + forceSkip = true; + } + } + } + if (code.code.get(ip).definition instanceof GetLocalTypeIns) { + int locreg = ((GetLocalTypeIns) code.code.get(ip).definition).getRegisterId(code.code.get(ip)); + if (locreg == trueReg) { + myStack.push(Boolean.TRUE); + ignored.add(ip); + } + if (locreg == falseReg) { + myStack.push(Boolean.FALSE); + ignored.add(ip); + } + } else if (code.code.get(ip).definition instanceof PopIns) { + if (!myStack.empty()) { + myStack.pop(); + ignored.add(ip); + } } else if (code.code.get(ip).definition instanceof SwapIns) { - Boolean b1 = myStack.pop(); - Boolean b2 = myStack.pop(); - myStack.push(b1); - myStack.push(b2); - } else if (code.code.get(ip).definition instanceof JumpIns) { - try { - ip = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); - } catch (ConvertException ex) { - Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, null, ex); - } - continue; - } else if (code.code.get(ip).definition instanceof SetLocalTypeIns) { - Boolean val = myStack.pop(); - if (val == true) { - trueReg = ((SetLocalTypeIns) code.code.get(ip).definition).getRegisterId(code.code.get(ip)); - } else { - falseReg = ((SetLocalTypeIns) code.code.get(ip).definition).getRegisterId(code.code.get(ip)); - } - setCount++; - if (setCount == 2) { - return ip + 1; - } + if (myStack.size() >= 2) { + Boolean b1 = myStack.pop(); + Boolean b2 = myStack.pop(); + myStack.push(b1); + myStack.push(b2); + ignored.add(ip); + } + } else if (code.code.get(ip).definition instanceof DupIns) { + if (!myStack.empty()) { + Boolean b = myStack.pop(); + myStack.push(b); + myStack.push(b); + ignored.add(ip); + } + } else if ((code.code.get(ip).definition instanceof JumpIns) || forceJump) { + + int jumpIp = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); + actual.end = ip; + GraphPart newActual = makeGraph(myStack, code, jumpIp, allBlocks); + actual.nextParts.add(newActual); + return ret; + } else if (code.code.get(ip).definition instanceof IfTypeIns) { + if (forceSkip) { + ip++; + continue; + } + + actual.end = ip; + int jumpIp = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); + GraphPart onTrue = makeGraph(myStack, code, jumpIp, allBlocks); + actual.nextParts.add(onTrue); + GraphPart onFalse = makeGraph(myStack, code, ip + 1, allBlocks); + actual.nextParts.add(onFalse); + return ret; + } else if ((code.code.get(ip).definition instanceof ReturnValueIns) || (code.code.get(ip).definition instanceof ReturnVoidIns)) { + ip++; + break; } ip++; - } - return 0; - } - - - private GraphPart makeGraph(Stack myStack,AVM2Code code, int start, List allBlocks) { - GraphPart ret=new GraphPart(start,-1); - ret.instanceCount=1; - allBlocks.add(ret); - GraphPart actual=ret; - try { - int ip = start; - while (ip < code.code.size()) { - for (GraphPart block : allBlocks) { - if (block.containsIP(ip)) { - if(block.start= 2) { - Boolean b1 = myStack.pop(); - Boolean b2 = myStack.pop(); - myStack.push(b1); - myStack.push(b2); - ignored.add(ip); - } - } else if (code.code.get(ip).definition instanceof DupIns) { - if (!myStack.empty()) { - Boolean b = myStack.pop(); - myStack.push(b); - myStack.push(b); - ignored.add(ip); - } - } else if ((code.code.get(ip).definition instanceof JumpIns) || forceJump) { - - int jumpIp = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); - actual.end=ip; - GraphPart newActual=makeGraph(myStack,code,jumpIp,allBlocks); - actual.nextParts.add(newActual); - return ret; - } else if (code.code.get(ip).definition instanceof IfTypeIns) { - if (forceSkip) { - ip++; - continue; - } - - actual.end=ip; - int jumpIp = code.adr2pos(code.pos2adr(ip + 1) + code.code.get(ip).operands[0]); - GraphPart onTrue=makeGraph(myStack,code, jumpIp, allBlocks); - actual.nextParts.add(onTrue); - GraphPart onFalse=makeGraph(myStack,code, ip + 1, allBlocks); - actual.nextParts.add(onFalse); - return ret; - } else if ((code.code.get(ip).definition instanceof ReturnValueIns) || (code.code.get(ip).definition instanceof ReturnVoidIns)) { - ip++; - break; - } - ip++; - } - actual.end=ip-1; - return ret; - } catch (ConvertException ex) { - Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, null, ex); - } - return null; - } - + } + actual.end = ip - 1; + return ret; + } catch (ConvertException ex) { + Logger.getLogger(Graph.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/GraphPart.java b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/GraphPart.java index bcbb0ee19..dad381c25 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/GraphPart.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/flowgraph/GraphPart.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.flowgraph; import java.util.ArrayList; @@ -25,47 +24,48 @@ import java.util.List; * @author JPEXS */ public class GraphPart { - public int start=0; - public int end=0; - public int instanceCount=0; - public List nextParts=new ArrayList(); - public int posX=-1; - public int posY=-1; + public int start = 0; + public int end = 0; + public int instanceCount = 0; + public List nextParts = new ArrayList(); + public int posX = -1; + public int posY = -1; + public GraphPart(int start, int end) { + this.start = start; + this.end = end; + } - public GraphPart(int start,int end) { - this.start=start; - this.end=end; - } + @Override + public String toString() { + if (end < start) { + return "<->"; + } + return "" + (start + 1) + "-" + (end + 1) + (instanceCount > 1 ? "(" + instanceCount + " links)" : ""); + } - @Override - public String toString() { - if(end"; - } - return ""+(start+1)+"-"+(end+1)+(instanceCount>1?"("+instanceCount+" links)":""); - } + public boolean containsIP(int ip) { + return (ip >= start) && (ip <= end); + } + private boolean containsPart(GraphPart part, GraphPart what, List used) { + if (used.contains(part)) { + return false; + } + used.add(part); + for (GraphPart subpart : part.nextParts) { + if (subpart == what) { + return true; + } + if (containsPart(subpart, what, used)) { + return true; + } + } + return false; + } - - - public boolean containsIP(int ip){ - return (ip>=start)&&(ip<=end); - } - - - private boolean containsPart(GraphPart part,GraphPart what,List used){ - if(used.contains(part)) return false; - used.add(part); - for(GraphPart subpart:part.nextParts){ - if(subpart==what) return true; - if(containsPart(subpart,what,used)) return true; - } - return false; - } - - public boolean containsPart(GraphPart what){ - return containsPart(this,what,new ArrayList()); - } + public boolean containsPart(GraphPart what) { + return containsPart(this, what, new ArrayList()); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/AVM2Instruction.java index a445d0f2e..c4ef28cbe 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/AVM2Instruction.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions; import com.jpexs.asdec.abc.ABCOutputStream; @@ -26,198 +25,197 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; - public class AVM2Instruction { - public InstructionDefinition definition; - public int operands[]; - public long offset; - public byte bytes[]; - public String comment; - public boolean ignored = false; + public InstructionDefinition definition; + public int operands[]; + public long offset; + public byte bytes[]; + public String comment; + public boolean ignored = false; - public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) { - this.definition = definition; - this.operands = operands; - this.offset = offset; - this.bytes = bytes; - } + public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) { + this.definition = definition; + this.operands = operands; + this.offset = offset; + this.bytes = bytes; + } - public byte[] getBytes() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - ABCOutputStream aos = new ABCOutputStream(bos); - aos.write(definition.instructionCode); - for (int i = 0; i < definition.operands.length; i++) { - int opt = definition.operands[i] & 0xff00; - switch (opt) { - case AVM2Code.OPT_S24: - aos.writeS24(operands[i]); - break; - case AVM2Code.OPT_U30: - aos.writeU30(operands[i]); - break; - case AVM2Code.OPT_U8: - aos.writeU8(operands[i]); - break; - case AVM2Code.OPT_BYTE: - aos.writeU8(0xff & operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: + public byte[] getBytes() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + ABCOutputStream aos = new ABCOutputStream(bos); + aos.write(definition.instructionCode); + for (int i = 0; i < definition.operands.length; i++) { + int opt = definition.operands[i] & 0xff00; + switch (opt) { + case AVM2Code.OPT_S24: + aos.writeS24(operands[i]); + break; + case AVM2Code.OPT_U30: + aos.writeU30(operands[i]); + break; + case AVM2Code.OPT_U8: + aos.writeU8(operands[i]); + break; + case AVM2Code.OPT_BYTE: + aos.writeU8(0xff & operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: - aos.writeU30(operands[i]); //case count - for (int j = i + 1; j < operands.length; j++) { - aos.writeS24(operands[j]); - } - break; - } + aos.writeU30(operands[i]); //case count + for (int j = i + 1; j < operands.length; j++) { + aos.writeS24(operands[j]); + } + break; } - } catch (IOException ex) { - //ignored - } - return bos.toByteArray(); - } + } + } catch (IOException ex) { + //ignored + } + return bos.toByteArray(); + } - @Override - public String toString() { - String s = definition.instructionName; - for (int i = 0; i < operands.length; i++) { - s += " " + operands[i]; - } - return s; - } + @Override + public String toString() { + String s = definition.instructionName; + for (int i = 0; i < operands.length; i++) { + s += " " + operands[i]; + } + return s; + } - public List getOffsets() { - List ret = new ArrayList(); - String s = ""; - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_OFFSET: - ret.add(offset + operands[i] + getBytes().length); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - ret.add(offset + operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: - for (int j = i + 1; j < operands.length; j++) { - ret.add(offset + operands[j]); - } - break; - } + public List getOffsets() { + List ret = new ArrayList(); + String s = ""; + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_OFFSET: + ret.add(offset + operands[i] + getBytes().length); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + ret.add(offset + operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: + for (int j = i + 1; j < operands.length; j++) { + ret.add(offset + operands[j]); + } + break; + } - } - return ret; - } + } + return ret; + } - public List getParamsAsList(ConstantPool constants){ - List s = new ArrayList(); - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - s.add(constants.constant_multiname[operands[i]]); - break; - case AVM2Code.DAT_STRING_INDEX: - s.add(constants.constant_string[operands[i]]); - break; - case AVM2Code.DAT_INT_INDEX: - s.add(new Long(constants.constant_int[operands[i]])); - break; - case AVM2Code.DAT_UINT_INDEX: - s.add(new Long(constants.constant_uint[operands[i]])); - break; - case AVM2Code.DAT_DOUBLE_INDEX: - s.add(new Double(constants.constant_double[operands[i]])); - break; - case AVM2Code.DAT_OFFSET: - s.add(new Long(offset + operands[i] + getBytes().length)); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s.add(new Long(offset + operands[i])); - break; - case AVM2Code.OPT_CASE_OFFSETS: - s.add(new Long(operands[i])); - for (int j = i + 1; j < operands.length; j++) { - s.add(new Long(offset + operands[j])); - } - break; - default: - s.add(new Long(operands[i])); - } + public List getParamsAsList(ConstantPool constants) { + List s = new ArrayList(); + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + s.add(constants.constant_multiname[operands[i]]); + break; + case AVM2Code.DAT_STRING_INDEX: + s.add(constants.constant_string[operands[i]]); + break; + case AVM2Code.DAT_INT_INDEX: + s.add(new Long(constants.constant_int[operands[i]])); + break; + case AVM2Code.DAT_UINT_INDEX: + s.add(new Long(constants.constant_uint[operands[i]])); + break; + case AVM2Code.DAT_DOUBLE_INDEX: + s.add(new Double(constants.constant_double[operands[i]])); + break; + case AVM2Code.DAT_OFFSET: + s.add(new Long(offset + operands[i] + getBytes().length)); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s.add(new Long(offset + operands[i])); + break; + case AVM2Code.OPT_CASE_OFFSETS: + s.add(new Long(operands[i])); + for (int j = i + 1; j < operands.length; j++) { + s.add(new Long(offset + operands[j])); + } + break; + default: + s.add(new Long(operands[i])); + } - } - return s; - } + } + return s; + } - public String getParams(ConstantPool constants) { - String s = ""; - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - s += " m[" + operands[i] + "]\"" + Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants)) + "\""; - break; - case AVM2Code.DAT_STRING_INDEX: - s += " \"" + Helper.escapeString(constants.constant_string[operands[i]]) + "\""; - break; - case AVM2Code.DAT_INT_INDEX: - s += " " + constants.constant_int[operands[i]] + ""; - break; - case AVM2Code.DAT_UINT_INDEX: - s += " " + constants.constant_uint[operands[i]] + ""; - break; - case AVM2Code.DAT_DOUBLE_INDEX: - s += " " + constants.constant_double[operands[i]] + ""; - break; - case AVM2Code.DAT_OFFSET: - s += " "; - if (operands[i] > 0) { - //s += "+"; - }//operands[i] - s += "ofs" + Helper.formatAddress(offset + operands[i] + getBytes().length) + ""; - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s += " "; - if (operands[i] > 0) { - //s += "+"; - }//operands[i] - s += "ofs" + Helper.formatAddress(offset + operands[i]) + ""; - break; - case AVM2Code.OPT_CASE_OFFSETS: - s += " " + operands[i]; - for (int j = i + 1; j < operands.length; j++) { - s += " "; - if (operands[j] > 0) { - //s += "+"; - }//operands[j] - s += "ofs" + Helper.formatAddress(offset + operands[j]) + ""; - } - break; - default: - s += " " + operands[i]; - } + public String getParams(ConstantPool constants) { + String s = ""; + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + s += " m[" + operands[i] + "]\"" + Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants)) + "\""; + break; + case AVM2Code.DAT_STRING_INDEX: + s += " \"" + Helper.escapeString(constants.constant_string[operands[i]]) + "\""; + break; + case AVM2Code.DAT_INT_INDEX: + s += " " + constants.constant_int[operands[i]] + ""; + break; + case AVM2Code.DAT_UINT_INDEX: + s += " " + constants.constant_uint[operands[i]] + ""; + break; + case AVM2Code.DAT_DOUBLE_INDEX: + s += " " + constants.constant_double[operands[i]] + ""; + break; + case AVM2Code.DAT_OFFSET: + s += " "; + if (operands[i] > 0) { + //s += "+"; + }//operands[i] + s += "ofs" + Helper.formatAddress(offset + operands[i] + getBytes().length) + ""; + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s += " "; + if (operands[i] > 0) { + //s += "+"; + }//operands[i] + s += "ofs" + Helper.formatAddress(offset + operands[i]) + ""; + break; + case AVM2Code.OPT_CASE_OFFSETS: + s += " " + operands[i]; + for (int j = i + 1; j < operands.length; j++) { + s += " "; + if (operands[j] > 0) { + //s += "+"; + }//operands[j] + s += "ofs" + Helper.formatAddress(offset + operands[j]) + ""; + } + break; + default: + s += " " + operands[i]; + } - } - return s; - } + } + return s; + } - public String getComment() { - if (ignored) { - return " ;ignored"; - } - if ((comment == null) || comment.equals("")) { - return ""; - } - return " ;" + comment; - } + public String getComment() { + if (ignored) { + return " ;ignored"; + } + if ((comment == null) || comment.equals("")) { + return ""; + } + return " ;" + comment; + } - public String toString(ConstantPool constants) { - String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName; - s += getParams(constants) + getComment(); - return s; - } + public String toString(ConstantPool constants) { + String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName; + s += getParams(constants) + getComment(); + return s; + } - public String toStringNoAddress(ConstantPool constants) { - String s = definition.instructionName; - s += getParams(constants) + getComment(); - return s; - } + public String toStringNoAddress(ConstantPool constants) { + String s = definition.instructionName; + s += getParams(constants) + getComment(); + return s; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/IfTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/IfTypeIns.java index b1700325c..42cae9281 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/IfTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/IfTypeIns.java @@ -14,13 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions; - import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; +import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.Stack; - public interface IfTypeIns { - public abstract void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins); + + public abstract void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/InstructionDefinition.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/InstructionDefinition.java index 2779bb536..c32e48fbb 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/InstructionDefinition.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/InstructionDefinition.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -29,100 +28,95 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class InstructionDefinition { + protected String hilighOffset(String text, long offset) { + return Highlighting.hilighOffset(text, offset); + } + public int operands[]; + public String instructionName = ""; + public int instructionCode = 0; - protected String hilighOffset(String text, long offset) { - return Highlighting.hilighOffset(text, offset); - } + public InstructionDefinition(int instructionCode, String instructionName, int operands[]) { + this.instructionCode = instructionCode; + this.instructionName = instructionName; + this.operands = operands; + } - public int operands[]; - public String instructionName = ""; - public int instructionCode = 0; + @Override + public String toString() { + String s = instructionName; + for (int i = 0; i < operands.length; i++) { + if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { + s += " U30"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { + s += " U8"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { + s += " BYTE"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { + s += " S24"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { + s += " U30 S24,[S24]..."; + } + } + return s; + } + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); + } - public InstructionDefinition(int instructionCode, String instructionName, int operands[]) { - this.instructionCode = instructionCode; - this.instructionName = instructionName; - this.operands = operands; - } + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + } - @Override - public String toString() { - String s = instructionName; - for (int i = 0; i < operands.length; i++) { - if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { - s += " U30"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { - s += " U8"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { - s += " BYTE"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { - s += " S24"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { - s += " U30 S24,[S24]..."; - } - } - return s; - } + protected FullMultinameTreeItem resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { + TreeItem ns = null; + TreeItem name = null; + if (constants.constant_multiname[multinameIndex].needsName()) { + name = (TreeItem) stack.pop(); + } + if (constants.constant_multiname[multinameIndex].needsNs()) { + ns = (TreeItem) stack.pop(); + } + return new FullMultinameTreeItem(ins, multinameIndex, name, ns); + } - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new UnsupportedOperationException("Instruction "+instructionName+" not implemented"); - } + protected int resolvedCount(ConstantPool constants, int multinameIndex) { + int pos = 0; + if (constants.constant_multiname[multinameIndex].needsNs()) { + pos++; + } + if (constants.constant_multiname[multinameIndex].needsName()) { + pos++; + } + return pos; - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { + } - } + protected String resolveMultinameNoPop(int pos, Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { + String ns = ""; + String name = ""; + if (constants.constant_multiname[multinameIndex].needsNs()) { + ns = "[" + stack.get(pos) + "]"; + pos++; + } + if (constants.constant_multiname[multinameIndex].needsName()) { + name = stack.get(pos).toString(); + } else { + name = hilighOffset(constants.constant_multiname[multinameIndex].getName(constants), ins.offset); + } + return name + ns; + } - protected FullMultinameTreeItem resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { - TreeItem ns = null; - TreeItem name = null; - if (constants.constant_multiname[multinameIndex].needsName()) { - name = (TreeItem) stack.pop(); - } - if (constants.constant_multiname[multinameIndex].needsNs()) { - ns = (TreeItem) stack.pop(); - } - return new FullMultinameTreeItem(ins, multinameIndex, name, ns); - } + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } - protected int resolvedCount(ConstantPool constants, int multinameIndex) { - int pos = 0; - if (constants.constant_multiname[multinameIndex].needsNs()) { - pos++; - } - if (constants.constant_multiname[multinameIndex].needsName()) { - pos++; - } - return pos; - - } - - protected String resolveMultinameNoPop(int pos, Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { - String ns = ""; - String name = ""; - if (constants.constant_multiname[multinameIndex].needsNs()) { - ns = "[" + stack.get(pos) + "]"; - pos++; - } - if (constants.constant_multiname[multinameIndex].needsName()) { - name = stack.get(pos).toString(); - } else { - name = hilighOffset(constants.constant_multiname[multinameIndex].getName(constants), ins.offset); - } - return name + ns; - } - - public int getStackDelta(AVM2Instruction ins,ABC abc){ - return 0; - } - - public int getScopeStackDelta(AVM2Instruction ins,ABC abc){ - return 0; - } + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/SetTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/SetTypeIns.java index d12ff7d84..9187bfcfb 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/SetTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/SetTypeIns.java @@ -14,17 +14,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions; - import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import com.jpexs.asdec.abc.types.MethodInfo; import java.util.HashMap; import java.util.List; import java.util.Stack; - public interface SetTypeIns { - public abstract String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames); + + public abstract String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIIns.java index 4222a4f54..afe910e46 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; @@ -27,25 +26,22 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class AddIIns extends AddIns { - public AddIIns() { - instructionName = "add_i"; - instructionCode = 0xc5; - } + public AddIIns() { + instructionName = "add_i"; + instructionCode = 0xc5; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new AddTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new AddTreeItem(ins, v1, v2)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIns.java index fbb9dbd40..701c2b5fb 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/AddIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,44 +28,43 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class AddIns extends InstructionDefinition { - public AddIns() { - super(0xa0, "add", new int[]{}); - } + public AddIns() { + super(0xa0, "add", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() + ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - String s = o1.toString() + o2.toString(); - lda.operandStack.push(s); - } - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new AddTreeItem(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() + ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + String s = o1.toString() + o2.toString(); + lda.operandStack.push(s); } + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new AddTreeItem(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIIns.java index 6cc6f1f6b..1ee359959 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,40 +28,37 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DecrementIIns extends InstructionDefinition { - public DecrementIIns() { - super(0xc1, "decrement_i", new int[]{}); - } + public DecrementIIns() { + super(0xc1, "decrement_i", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.operandStack.push(obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.operandStack.push(obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.operandStack.push(obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { - stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop())); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIns.java index 46b51884f..8c93f3352 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,38 +28,37 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DecrementIns extends InstructionDefinition { - public DecrementIns() { - super(0x93, "decrement", new int[]{}); - } + public DecrementIns() { + super(0x93, "decrement", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.operandStack.push(obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.operandStack.push(obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.operandStack.push(obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { - stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop())); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DivideIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DivideIns.java index 126cca04d..595b2e545 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DivideIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/DivideIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,43 +28,42 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DivideIns extends InstructionDefinition { - public DivideIns() { - super(0xa3, "divide", new int[]{}); - } + public DivideIns() { + super(0xa3, "divide", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o2 = lda.operandStack.pop(); - Object o1 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() / ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot divide"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o2 = lda.operandStack.pop(); + Object o1 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() / ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot divide"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new DivideTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new DivideTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIIns.java index 9fc785e1a..59fcf7c63 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,20 +27,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IncrementIIns extends InstructionDefinition { - public IncrementIIns() { - super(0xc0, "increment_i", new int[]{}); - } + public IncrementIIns() { + super(0xc0, "increment_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc,HashMap localRegNames) { - stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop())); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIns.java index 08cc1cc7c..c5acb8a73 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/IncrementIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,20 +27,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IncrementIns extends InstructionDefinition { - public IncrementIns() { - super(0x91, "increment", new int[]{}); - } + public IncrementIns() { + super(0x91, "increment", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/ModuloIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/ModuloIns.java index aa8ddde03..d468049af 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/ModuloIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/ModuloIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,35 +28,34 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ModuloIns extends InstructionDefinition { - public ModuloIns() { - super(0xa4, "modulo", new int[]{}); - } + public ModuloIns() { + super(0xa4, "modulo", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o2).longValue() % ((Long) o1).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot modulo"); - } - } + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o2).longValue() % ((Long) o1).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot modulo"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new ModuloTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new ModuloTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIIns.java index ab7052afa..6a4375945 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class MultiplyIIns extends InstructionDefinition { - public MultiplyIIns() { - super(0xc7, "multiply_i", new int[]{}); - } + public MultiplyIIns() { + super(0xc7, "multiply_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new MultiplyTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new MultiplyTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIns.java index f1045b4bd..0d1ff5756 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/MultiplyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,43 +28,42 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class MultiplyIns extends InstructionDefinition { - public MultiplyIns() { - super(0xa2, "multiply", new int[]{}); - } + public MultiplyIns() { + super(0xa2, "multiply", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() * ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() * ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot multiply"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() * ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() * ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot multiply"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new MultiplyTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new MultiplyTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIIns.java index a4f3f9b82..1e3f42e9f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,21 +27,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NegateIIns extends InstructionDefinition { - public NegateIIns() { - super(0xc4, "negate_i", new int[]{}); - } + public NegateIIns() { + super(0xc4, "negate_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v = (TreeItem) stack.pop(); - stack.push(new NegTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v = (TreeItem) stack.pop(); + stack.push(new NegTreeItem(ins, v)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIns.java index 520bd7091..b0917bb65 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NegateIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,21 +27,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NegateIns extends InstructionDefinition { - public NegateIns() { - super(0x90, "negate", new int[]{}); - } + public NegateIns() { + super(0x90, "negate", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v = (TreeItem) stack.pop(); - stack.push(new NegTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v = (TreeItem) stack.pop(); + stack.push(new NegTreeItem(ins, v)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NotIns.java index 9c09d0fe3..0a7c7a2ee 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/NotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,21 +27,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NotIns extends InstructionDefinition { - public NotIns() { - super(0x96, "not", new int[]{}); - } + public NotIns() { + super(0x96, "not", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v = (TreeItem) stack.pop(); - stack.push(new NotTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v = (TreeItem) stack.pop(); + stack.push(new NotTreeItem(ins, v)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIIns.java index 0ca288720..867d68f78 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SubtractIIns extends InstructionDefinition { - public SubtractIIns() { - super(0xc6, "subtract_i", new int[]{}); - } + public SubtractIIns() { + super(0xc6, "subtract_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new SubtractTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new SubtractTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIns.java index b563592a7..c36ba8e0c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/arithmetic/SubtractIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.arithmetic; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SubtractIns extends InstructionDefinition { - public SubtractIns() { - super(0xa1, "subtract", new int[]{}); - } + public SubtractIns() { + super(0xa1, "subtract", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new SubtractTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new SubtractTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitAndIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitAndIns.java index 4f9d5c610..a1ff72daf 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitAndIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitAndIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class BitAndIns extends InstructionDefinition { - public BitAndIns() { - super(0xa8, "bitand", new int[]{}); - } + public BitAndIns() { + super(0xa8, "bitand", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 & value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 & value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new BitAndTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new BitAndTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitNotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitNotIns.java index 6dcff83f3..2943253c7 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitNotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,28 +28,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class BitNotIns extends InstructionDefinition { - public BitNotIns() { - super(0x97, "bitnot", new int[]{}); - } + public BitNotIns() { + super(0x97, "bitnot", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value = (Long) lda.operandStack.pop(); - Long ret = new Long(-value.longValue()); - lda.operandStack.push(ret); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value = (Long) lda.operandStack.pop(); + Long ret = new Long(-value.longValue()); + lda.operandStack.push(ret); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v = (TreeItem) stack.pop(); - stack.push(new BitNotTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v = (TreeItem) stack.pop(); + stack.push(new BitNotTreeItem(ins, v)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitOrIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitOrIns.java index 1036e676b..8696fc9cd 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitOrIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitOrIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class BitOrIns extends InstructionDefinition { - public BitOrIns() { - super(0xa9, "bitor", new int[]{}); - } + public BitOrIns() { + super(0xa9, "bitor", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 | value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 | value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new BitOrTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new BitOrTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitXorIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitXorIns.java index 54cc25c49..acdc9476d 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitXorIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/BitXorIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class BitXorIns extends InstructionDefinition { - public BitXorIns() { - super(0xaa, "bitxor", new int[]{}); - } + public BitXorIns() { + super(0xaa, "bitxor", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 ^ value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 ^ value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new BitXorTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new BitXorTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/LShiftIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/LShiftIns.java index b2a891077..c27d668cc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/LShiftIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/LShiftIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class LShiftIns extends InstructionDefinition { - public LShiftIns() { - super(0xa5, "lshift", new int[]{}); - } + public LShiftIns() { + super(0xa5, "lshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LShiftTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/RShiftIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/RShiftIns.java index 71847241c..461a0cc9f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/RShiftIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/RShiftIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class RShiftIns extends InstructionDefinition { - public RShiftIns() { - super(0xa6, "rshift", new int[]{}); - } + public RShiftIns() { + super(0xa6, "rshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new RShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new RShiftTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/URShiftIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/URShiftIns.java index 94971ac4b..2897b9357 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/URShiftIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/bitwise/URShiftIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.bitwise; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class URShiftIns extends InstructionDefinition { - public URShiftIns() { - super(0xa7, "urshift", new int[]{}); - } + public URShiftIns() { + super(0xa7, "urshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new URShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new URShiftTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/EqualsIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/EqualsIns.java index bb5b6b421..bd506233c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/EqualsIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/EqualsIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class EqualsIns extends InstructionDefinition { - public EqualsIns() { - super(0xab, "equals", new int[]{}); - } + public EqualsIns() { + super(0xab, "equals", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj1 = lda.operandStack.pop(); - Object obj2 = lda.operandStack.pop(); - Boolean res = obj1.equals(obj2); - lda.operandStack.push(res); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj1 = lda.operandStack.pop(); + Object obj2 = lda.operandStack.pop(); + Boolean res = obj1.equals(obj2); + lda.operandStack.push(res); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterEqualsIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterEqualsIns.java index 9a2b7d486..8cc841163 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterEqualsIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterEqualsIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GreaterEqualsIns extends InstructionDefinition { - public GreaterEqualsIns() { - super(0xb0, "greaterequals", new int[]{}); - } + public GreaterEqualsIns() { + super(0xb0, "greaterequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterThanIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterThanIns.java index 3f34146a0..26d099cbc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterThanIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/GreaterThanIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GreaterThanIns extends InstructionDefinition { - public GreaterThanIns() { - super(0xaf, "greaterthan", new int[]{}); - } + public GreaterThanIns() { + super(0xaf, "greaterthan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessEqualsIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessEqualsIns.java index 358995daa..834e7019b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessEqualsIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessEqualsIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class LessEqualsIns extends InstructionDefinition { - public LessEqualsIns() { - super(0xae, "lessequals", new int[]{}); - } + public LessEqualsIns() { + super(0xae, "lessequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessThanIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessThanIns.java index 3398ffc7e..cc34fd011 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessThanIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/LessThanIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class LessThanIns extends InstructionDefinition { - public LessThanIns() { - super(0xad, "lessthan", new int[]{}); - } + public LessThanIns() { + super(0xad, "lessthan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/StrictEqualsIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/StrictEqualsIns.java index 33ed130ff..b4fa9a7f1 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/StrictEqualsIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/comparsion/StrictEqualsIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.comparsion; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class StrictEqualsIns extends InstructionDefinition { - public StrictEqualsIns() { - super(0xac, "strictequals", new int[]{}); - } + public StrictEqualsIns() { + super(0xac, "strictequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java index ebf5fa843..76e31c039 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,41 +30,38 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConstructIns extends InstructionDefinition { - public ConstructIns() { - super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ConstructIns() { + super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object obj = lda.operandStack.pop(); - throw new RuntimeException("Cannot call constructor"); - //call construct property of obj - //push new instance - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object obj = lda.operandStack.pop(); + throw new RuntimeException("Cannot call constructor"); + //call construct property of obj + //push new instance + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - TreeItem obj = (TreeItem) stack.pop(); - stack.push(new ConstructTreeItem(ins, obj, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + TreeItem obj = (TreeItem) stack.pop(); + stack.push(new ConstructTreeItem(ins, obj, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0]-1+1; + return -ins.operands[0] - 1 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructPropIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructPropIns.java index d0ace4cec..9672d49d3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructPropIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructPropIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,51 +31,50 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConstructPropIns extends InstructionDefinition { - public ConstructPropIns() { - super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public ConstructPropIns() { + super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - throw new RuntimeException("Cannot construct property"); - //create property - //push new instance - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + throw new RuntimeException("Cannot construct property"); + //create property + //push new instance + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - - - stack.push(new ConstructPropTreeItem(ins, obj, multiname, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + + + stack.push(new ConstructPropTreeItem(ins, obj, multiname, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructSuperIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructSuperIns.java index 665e2a5e2..274213fc4 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructSuperIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/ConstructSuperIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,39 +30,38 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConstructSuperIns extends InstructionDefinition { - public ConstructSuperIns() { - super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ConstructSuperIns() { + super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object obj = lda.operandStack.pop(); - throw new RuntimeException("Cannot call super constructor"); - //call construct property of obj - //do not push anything - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object obj = lda.operandStack.pop(); + throw new RuntimeException("Cannot call super constructor"); + //call construct property of obj + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - TreeItem obj = (TreeItem) stack.pop(); - output.add(new ConstructSuperTreeItem(ins, obj, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + TreeItem obj = (TreeItem) stack.pop(); + output.add(new ConstructSuperTreeItem(ins, obj, args)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0]-1; + return -ins.operands[0] - 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewActivationIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewActivationIns.java index 5c6978db9..e0c52123c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewActivationIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewActivationIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewActivationIns extends InstructionDefinition { - public NewActivationIns() { - super(0x57, "newactivation", new int[]{}); - } + public NewActivationIns() { + super(0x57, "newactivation", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new NewActivationTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new NewActivationTreeItem(ins)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewArrayIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewArrayIns.java index 66a6e2d98..2db659a27 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewArrayIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewArrayIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,27 +29,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewArrayIns extends InstructionDefinition { - public NewArrayIns() { - super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public NewArrayIns() { + super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - stack.push(new NewArrayTreeItem(ins, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + stack.push(new NewArrayTreeItem(ins, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0]+1; + return -ins.operands[0] + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewCatchIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewCatchIns.java index 9c5111582..32fd22c36 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewCatchIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewCatchIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,23 +28,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewCatchIns extends InstructionDefinition { - public NewCatchIns() { - super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); - } + public NewCatchIns() { + super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int exInfo = ins.operands[0]; - stack.push(new ExceptionTreeItem(body.exceptions[exInfo])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int exInfo = ins.operands[0]; + stack.push(new ExceptionTreeItem(body.exceptions[exInfo])); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewClassIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewClassIns.java index d25aa9292..33f22cbae 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewClassIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewClassIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,24 +28,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewClassIns extends InstructionDefinition { - public NewClassIns() { - super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); - } + public NewClassIns() { + super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int clsIndex = ins.operands[0]; - String baseType = stack.pop().toString(constants,localRegNames); - stack.push(new UnparsedTreeItem(ins, "new "+ abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants) + ".class extends " + baseType)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int clsIndex = ins.operands[0]; + String baseType = stack.pop().toString(constants, localRegNames); + stack.push(new UnparsedTreeItem(ins, "new " + abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants) + ".class extends " + baseType)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewFunctionIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewFunctionIns.java index 36b7d612d..8f760f915 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewFunctionIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,30 +30,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewFunctionIns extends InstructionDefinition { - public NewFunctionIns() { - super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); - } + public NewFunctionIns() { + super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int methodIndex = ins.operands[0]; - MethodBody mybody = abc.findBody(methodIndex); - String bodyStr = ""; - String paramStr = ""; - if (mybody != null) { - bodyStr = Highlighting.hilighMethodEnd()+mybody.toString(false,isStatic, classIndex, abc, constants, method_info, true)+Highlighting.hilighMethodBegin(body.method_info); - paramStr = method_info[methodIndex].getParamStr(constants,mybody,abc); - } - stack.push(new NewFunctionTreeItem(ins, paramStr, method_info[methodIndex].getReturnTypeStr(constants), bodyStr)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int methodIndex = ins.operands[0]; + MethodBody mybody = abc.findBody(methodIndex); + String bodyStr = ""; + String paramStr = ""; + if (mybody != null) { + bodyStr = Highlighting.hilighMethodEnd() + mybody.toString(false, isStatic, classIndex, abc, constants, method_info, true) + Highlighting.hilighMethodBegin(body.method_info); + paramStr = method_info[methodIndex].getParamStr(constants, mybody, abc); + } + stack.push(new NewFunctionTreeItem(ins, paramStr, method_info[methodIndex].getReturnTypeStr(constants), bodyStr)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewObjectIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewObjectIns.java index a1199e27b..40f6f71fc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewObjectIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/construction/NewObjectIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.construction; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,28 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NewObjectIns extends InstructionDefinition { - public NewObjectIns() { - super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public NewObjectIns() { + super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - TreeItem value = (TreeItem) stack.pop(); - TreeItem name = (TreeItem) stack.pop(); - args.add(0, new NameValuePair(name, value)); - } - stack.push(new NewObjectTreeItem(ins, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + TreeItem value = (TreeItem) stack.pop(); + TreeItem name = (TreeItem) stack.pop(); + args.add(0, new NameValuePair(name, value)); + } + stack.push(new NewObjectTreeItem(ins, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0]*2+1; + return -ins.operands[0] * 2 + 1; } - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugFileIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugFileIns.java index cbdf77f92..39bd1b66a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugFileIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugFileIns.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.debug; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; - public class DebugFileIns extends InstructionDefinition { - public DebugFileIns() { - super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX}); - } - + public DebugFileIns() { + super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX}); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugIns.java index a4e2a63c9..f82be10f9 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugIns.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.debug; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; - public class DebugIns extends InstructionDefinition { - public DebugIns() { - super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30}); - } - + public DebugIns() { + super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30}); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugLineIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugLineIns.java index ebe4a33b2..26ec20b66 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugLineIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/debug/DebugLineIns.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.debug; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; - public class DebugLineIns extends InstructionDefinition { - public DebugLineIns() { - super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM}); - } - + public DebugLineIns() { + super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM}); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallIns.java index 694afc574..7a6428e94 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,42 +30,39 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallIns extends InstructionDefinition { - public CallIns() { - super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public CallIns() { + super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop(); - Object function = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown function"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop(); + Object function = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown function"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - TreeItem receiver = (TreeItem) stack.pop(); - TreeItem function = (TreeItem) stack.pop(); - stack.push(new CallTreeItem(ins, receiver, function, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + TreeItem receiver = (TreeItem) stack.pop(); + TreeItem function = (TreeItem) stack.pop(); + stack.push(new CallTreeItem(ins, receiver, function, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1-ins.operands[0]; + return -2 + 1 - ins.operands[0]; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallMethodIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallMethodIns.java index 1d76ad366..8adffd36a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallMethodIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallMethodIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,43 +30,40 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallMethodIns extends InstructionDefinition { - public CallMethodIns() { - super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallMethodIns() { + super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int methodIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - TreeItem receiver = (TreeItem) stack.pop(); - String methodName = method_info[methodIndex].getName(constants); - stack.push(new CallMethodTreeItem(ins, receiver, methodName, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + TreeItem receiver = (TreeItem) stack.pop(); + String methodName = method_info[methodIndex].getName(constants); + stack.push(new CallMethodTreeItem(ins, receiver, methodName, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1-ins.operands[1]; + return -1 + 1 - ins.operands[1]; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropLexIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropLexIns.java index 7b7cb15bd..96e6cacdd 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropLexIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.CallPropertyTreeItem; @@ -29,36 +28,35 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallPropLexIns extends CallPropertyIns { - public CallPropLexIns() { - instructionName = "callproplex"; - instructionCode = 0x4c; - } + public CallPropLexIns() { + instructionName = "callproplex"; + instructionCode = 0x4c; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem receiver = (TreeItem) stack.pop(); - - stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem receiver = (TreeItem) stack.pop(); + + stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropVoidIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropVoidIns.java index f861e97f8..a37808f86 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,53 +31,52 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallPropVoidIns extends InstructionDefinition { - public CallPropVoidIns() { - super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallPropVoidIns() { + super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //same as callproperty + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //same as callproperty - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown property"); - //do not push anything - } + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown property"); + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - - TreeItem receiver = (TreeItem) stack.pop(); - - output.add(new CallPropertyTreeItem(ins, true, receiver, multiname, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + + TreeItem receiver = (TreeItem) stack.pop(); + + output.add(new CallPropertyTreeItem(ins, true, receiver, multiname, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropertyIns.java index f6e2a3f99..a9d4f3073 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallPropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,51 +31,50 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallPropertyIns extends InstructionDefinition { - public CallPropertyIns() { - super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallPropertyIns() { + super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown property"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown property"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - - TreeItem receiver = (TreeItem) stack.pop(); - - stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + + TreeItem receiver = (TreeItem) stack.pop(); + + stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallStaticIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallStaticIns.java index 0c93e9f4f..2ec6b64ab 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallStaticIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallStaticIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,43 +30,40 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallStaticIns extends InstructionDefinition { - public CallStaticIns() { - super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallStaticIns() { + super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown static method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown static method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int methodIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - TreeItem receiver = (TreeItem) stack.pop(); - String methodName = method_info[methodIndex].getName(constants); - stack.push(new CallStaticTreeItem(ins, receiver, methodName, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + TreeItem receiver = (TreeItem) stack.pop(); + String methodName = method_info[methodIndex].getName(constants); + stack.push(new CallStaticTreeItem(ins, receiver, methodName, args)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1-ins.operands[1]; + return -1 + 1 - ins.operands[1]; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperIns.java index e80ec999d..46f400c3a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,50 +31,49 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallSuperIns extends InstructionDefinition { - public CallSuperIns() { - super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallSuperIns() { + super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object receiver = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown super method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object receiver = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown super method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem receiver = (TreeItem) stack.pop(); - - stack.push(new CallSuperTreeItem(ins, false, receiver, multiname, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem receiver = (TreeItem) stack.pop(); + + stack.push(new CallSuperTreeItem(ins, false, receiver, multiname, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperVoidIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperVoidIns.java index ed9f3ca82..beb5fa129 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperVoidIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/executing/CallSuperVoidIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.executing; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,51 +31,50 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CallSuperVoidIns extends InstructionDefinition { - public CallSuperVoidIns() { - super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallSuperVoidIns() { + super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object receiver = lda.operandStack.pop(); - throw new RuntimeException("Call to unknown super method"); - //do not push anything - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object receiver = lda.operandStack.pop(); + throw new RuntimeException("Call to unknown super method"); + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add((TreeItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem receiver = (TreeItem) stack.pop(); - - output.add(new CallSuperTreeItem(ins, true, receiver, multiname, args)); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-ins.operands[1]-1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add((TreeItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem receiver = (TreeItem) stack.pop(); + + output.add(new CallSuperTreeItem(ins, true, receiver, multiname, args)); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfEqIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfEqIns.java index 3b73e83dc..4c1b455c2 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfEqIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfEqIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,30 +30,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfEqIns extends InstructionDefinition implements IfTypeIns { - public IfEqIns() { - super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfEqIns() { + super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new NeqTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new NeqTreeItem(ins, v1, v2)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfFalseIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfFalseIns.java index 9383fbe54..3d3e1e24e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfFalseIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfFalseIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,25 +29,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfFalseIns extends InstructionDefinition implements IfTypeIns { - public IfFalseIns() { - super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfFalseIns() { + super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new NotTreeItem(ins, v1)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new NotTreeItem(ins, v1)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - //String v1 = stack.pop().toString(); - //stack.push("(" + v1 + ")"); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGeIns.java index 778a0179e..869aebb4e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfGeIns extends InstructionDefinition implements IfTypeIns { - public IfGeIns() { - super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfGeIns() { + super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGtIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGtIns.java index 88daa475a..1d955b7ca 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGtIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfGtIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfGtIns extends InstructionDefinition implements IfTypeIns { - public IfGtIns() { - super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfGtIns() { + super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLeIns.java index 430ad8eca..8d8727405 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfLeIns extends InstructionDefinition implements IfTypeIns { - public IfLeIns() { - super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfLeIns() { + super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLtIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLtIns.java index 6b0b633ac..5a33abcaa 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLtIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfLtIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfLtIns extends InstructionDefinition implements IfTypeIns { - public IfLtIns() { - super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfLtIns() { + super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGeIns.java index 3f9706993..d17ac5c0d 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfNGeIns extends InstructionDefinition implements IfTypeIns { - public IfNGeIns() { - super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNGeIns() { + super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGtIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGtIns.java index 59425d54b..d18779eff 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGtIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNGtIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfNGtIns extends InstructionDefinition implements IfTypeIns { - public IfNGtIns() { - super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNGtIns() { + super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLeIns.java index 2add2c5d4..710df5d66 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfNLeIns extends InstructionDefinition implements IfTypeIns { - public IfNLeIns() { - super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNLeIns() { + super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLtIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLtIns.java index 8643d7bb0..149092181 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLtIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNLtIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfNLtIns extends InstructionDefinition implements IfTypeIns { - public IfNLtIns() { - super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNLtIns() { + super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNeIns.java index 34da02f98..fc625ca62 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfNeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfNeIns extends InstructionDefinition implements IfTypeIns { - public IfNeIns() { - super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNeIns() { + super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new NeqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new NeqTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictEqIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictEqIns.java index bb63e16ff..88b06b5a8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictEqIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictEqIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { - public IfStrictEqIns() { - super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfStrictEqIns() { + super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new StrictNeqTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new StrictNeqTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictNeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictNeIns.java index 69c73c933..4dd55f076 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictNeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfStrictNeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,27 +30,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { - public IfStrictNeIns() { - super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfStrictNeIns() { + super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new StrictNeqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new StrictNeqTreeItem(ins, v1, v2)); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v2 = (TreeItem) stack.pop(); - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v2 = (TreeItem) stack.pop(); + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfTrueIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfTrueIns.java index 99e112ec9..fd4ada8c5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfTrueIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/IfTrueIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,25 +29,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IfTrueIns extends InstructionDefinition implements IfTypeIns { - public IfTrueIns() { - super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfTrueIns() { + super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - //String v1 = stack.pop().toString(); - //stack.push("(" + v1 + ")"); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - TreeItem v1 = (TreeItem) stack.pop(); - stack.push(new NotTreeItem(ins, v1)); - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + TreeItem v1 = (TreeItem) stack.pop(); + stack.push(new NotTreeItem(ins, v1)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/JumpIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/JumpIns.java index 12c5f2d34..bdfed5a68 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/JumpIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/JumpIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns; @@ -29,19 +28,17 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class JumpIns extends InstructionDefinition implements IfTypeIns { - public JumpIns() { - super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); - } + public JumpIns() { + super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new BooleanTreeItem(ins, Boolean.TRUE));// + ins.operands[0]); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new BooleanTreeItem(ins, Boolean.TRUE));// + ins.operands[0]); + } - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - - } + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/LookupSwitchIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/LookupSwitchIns.java index d9968d1c5..b8934ffd0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/LookupSwitchIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/jumps/LookupSwitchIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.jumps; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,21 +27,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class LookupSwitchIns extends InstructionDefinition { - public LookupSwitchIns() { - super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); - } + public LookupSwitchIns() { + super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int defaultOffset = ins.operands[0]; - int caseCount = ins.operands[1]; - //stack.push("switch(...)"); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int defaultOffset = ins.operands[0]; + int caseCount = ins.operands[1]; + //stack.push("switch(...)"); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIIns.java index 097862fec..aba622434 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,35 +28,34 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DecLocalIIns extends InstructionDefinition { - public DecLocalIIns() { - super(0xc3, "declocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public DecLocalIIns() { + super(0xc3, "declocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); - Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); + Object obj = lda.localRegisters.get(locRegIndex); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int regIndex = ins.operands[0]; - output.add(new DecLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int regIndex = ins.operands[0]; + output.add(new DecLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIns.java index c8bc09eeb..edf586157 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/DecLocalIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,36 +28,34 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DecLocalIns extends InstructionDefinition { - public DecLocalIns() { - super(0x94, "declocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public DecLocalIns() { + super(0x94, "declocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); - Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); + Object obj = lda.localRegisters.get(locRegIndex); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int regIndex = ins.operands[0]; - output.add(new DecLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int regIndex = ins.operands[0]; + output.add(new DecLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal0Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal0Ins.java index 51fbeafeb..5396b532c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,32 +29,31 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLocal0Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal0Ins() { - super(0xd0, "getlocal_0", new int[]{}); - } + public GetLocal0Ins() { + super(0xd0, "getlocal_0", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - if (isStatic) { - stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants).getName(constants))); - } else { - stack.push(new ThisTreeItem()); - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + if (isStatic) { + stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants).getName(constants))); + } else { + stack.push(new ThisTreeItem()); + } + } - public int getRegisterId(AVM2Instruction par0) { - return 0; - } + public int getRegisterId(AVM2Instruction par0) { + return 0; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal1Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal1Ins.java index 6e59a715c..36030027b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal1Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal1Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,28 +28,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLocal1Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal1Ins() { - super(0xd1, "getlocal_1", new int[]{}); - } + public GetLocal1Ins() { + super(0xd1, "getlocal_1", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(1)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(1)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new LocalRegTreeItem(ins, 1, localRegs.get(1))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new LocalRegTreeItem(ins, 1, localRegs.get(1))); + } - public int getRegisterId(AVM2Instruction par0) { - return 1; - } + public int getRegisterId(AVM2Instruction par0) { + return 1; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal2Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal2Ins.java index 0cff112ba..961636ccf 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal2Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal2Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,28 +28,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLocal2Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal2Ins() { - super(0xd2, "getlocal_2", new int[]{}); - } + public GetLocal2Ins() { + super(0xd2, "getlocal_2", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(2)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(2)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new LocalRegTreeItem(ins, 2, localRegs.get(2))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new LocalRegTreeItem(ins, 2, localRegs.get(2))); + } - public int getRegisterId(AVM2Instruction par0) { - return 2; - } + public int getRegisterId(AVM2Instruction par0) { + return 2; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal3Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal3Ins.java index 7bbfae323..b19452000 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal3Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocal3Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,27 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLocal3Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal3Ins() { - super(0xd3, "getlocal_3", new int[]{}); - } + public GetLocal3Ins() { + super(0xd3, "getlocal_3", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(3)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(3)); + } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new LocalRegTreeItem(ins, 3, localRegs.get(3))); + } + public int getRegisterId(AVM2Instruction par0) { + return 3; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new LocalRegTreeItem(ins, 3, localRegs.get(3))); - } - - public int getRegisterId(AVM2Instruction par0) { - return 3; - } - - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalIns.java index 1c0e85756..67acc01ac 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,31 +29,28 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLocalIns extends InstructionDefinition implements GetLocalTypeIns { - public GetLocalIns() { - super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public GetLocalIns() { + super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get((int)(long)(Long)arguments.get(0))); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get((int) (long) (Long) arguments.get(0))); + } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int regIndex = ins.operands[0]; + stack.push(new LocalRegTreeItem(ins, regIndex, localRegs.get(regIndex))); + } + public int getRegisterId(AVM2Instruction ins) { + return ins.operands[0]; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int regIndex = ins.operands[0]; - stack.push(new LocalRegTreeItem(ins, regIndex, localRegs.get(regIndex))); - } - - public int getRegisterId(AVM2Instruction ins) { - return ins.operands[0]; - } - - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalTypeIns.java index bc2171501..47936bced 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -14,12 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; - public interface GetLocalTypeIns { - public abstract int getRegisterId(AVM2Instruction ins); + + public abstract int getRegisterId(AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIIns.java index 8e04bdb9f..2c8dc99f4 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,16 +27,15 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IncLocalIIns extends InstructionDefinition { - public IncLocalIIns() { - super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public IncLocalIIns() { + super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int regIndex = ins.operands[0]; - output.add(new IncLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int regIndex = ins.operands[0]; + output.add(new IncLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIns.java index a99d14afe..1443a572a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/IncLocalIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,16 +27,15 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IncLocalIns extends InstructionDefinition { - public IncLocalIns() { - super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public IncLocalIns() { + super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int regIndex = ins.operands[0]; - output.add(new IncLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int regIndex = ins.operands[0]; + output.add(new IncLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/KillIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/KillIns.java index f740f3ff6..4bb55983b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/KillIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/KillIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -27,15 +26,14 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class KillIns extends InstructionDefinition { - public KillIns() { - super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public KillIns() { + super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - //kill local register - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + //kill local register + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal0Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal0Ins.java index 86e0e35c7..0d3b0289a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal0Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal0Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,41 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetLocal0Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns { - public SetLocal0Ins() { - super(0xd4, "setlocal_0", new int[]{}); - } + public SetLocal0Ins() { + super(0xd4, "setlocal_0", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.localRegisters.put(0,lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.localRegisters.put(0, lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); - localRegs.put(0, val); - if (val instanceof NewActivationTreeItem) return; - if (val instanceof FindPropertyTreeItem) return; - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, 0, val)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); + localRegs.put(0, val); + if (val instanceof NewActivationTreeItem) { + return; + } + if (val instanceof FindPropertyTreeItem) { + return; + } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, 0, val)); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return TreeItem.localRegName(localRegNames,0); - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return TreeItem.localRegName(localRegNames, 0); + } - public int getRegisterId(AVM2Instruction ins) { - return 0; - } + public int getRegisterId(AVM2Instruction ins) { + return 0; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal1Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal1Ins.java index a20d1dab9..d965f5ea6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal1Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal1Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,41 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetLocal1Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns { - public SetLocal1Ins() { - super(0xd5, "setlocal_1", new int[]{}); - } + public SetLocal1Ins() { + super(0xd5, "setlocal_1", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.localRegisters.put(1,lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.localRegisters.put(1, lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); - localRegs.put(1, val); - if (val instanceof NewActivationTreeItem) return; - if (val instanceof FindPropertyTreeItem) return; - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, 1, val)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); + localRegs.put(1, val); + if (val instanceof NewActivationTreeItem) { + return; + } + if (val instanceof FindPropertyTreeItem) { + return; + } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, 1, val)); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return TreeItem.localRegName(localRegNames,1); - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return TreeItem.localRegName(localRegNames, 1); + } - public int getRegisterId(AVM2Instruction ins) { - return 1; - } + public int getRegisterId(AVM2Instruction ins) { + return 1; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal2Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal2Ins.java index 55a697c89..99de46fae 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal2Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal2Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,41 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetLocal2Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns { - public SetLocal2Ins() { - super(0xd6, "setlocal_2", new int[]{}); - } + public SetLocal2Ins() { + super(0xd6, "setlocal_2", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.localRegisters.put(2,lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.localRegisters.put(2, lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); - localRegs.put(2, val); - if (val instanceof NewActivationTreeItem) return; - if (val instanceof FindPropertyTreeItem) return; - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, 2, val)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); + localRegs.put(2, val); + if (val instanceof NewActivationTreeItem) { + return; + } + if (val instanceof FindPropertyTreeItem) { + return; + } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, 2, val)); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return TreeItem.localRegName(localRegNames,2); - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return TreeItem.localRegName(localRegNames, 2); + } - public int getRegisterId(AVM2Instruction ins) { - return 2; - } + public int getRegisterId(AVM2Instruction ins) { + return 2; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal3Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal3Ins.java index ac56f62e4..fe49c6060 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal3Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocal3Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,41 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetLocal3Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns { - public SetLocal3Ins() { - super(0xd7, "setlocal_3", new int[]{}); - } + public SetLocal3Ins() { + super(0xd7, "setlocal_3", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.localRegisters.put(3,lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.localRegisters.put(3, lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); - localRegs.put(3, val); - if (val instanceof NewActivationTreeItem) return; - if (val instanceof FindPropertyTreeItem) return; - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, 3, val)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); + localRegs.put(3, val); + if (val instanceof NewActivationTreeItem) { + return; + } + if (val instanceof FindPropertyTreeItem) { + return; + } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, 3, val)); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return TreeItem.localRegName(localRegNames,3); - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return TreeItem.localRegName(localRegNames, 3); + } - public int getRegisterId(AVM2Instruction ins) { - return 3; - } + public int getRegisterId(AVM2Instruction ins) { + return 3; + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalIns.java index f0072f4b1..40360b85b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -33,39 +32,41 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetLocalIns extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns { - public SetLocalIns() { - super(0x63, "setlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public SetLocalIns() { + super(0x63, "setlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.localRegisters.put((int)(long)(Long)arguments.get(0),lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.localRegisters.put((int) (long) (Long) arguments.get(0), lda.operandStack.pop()); + } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); + localRegs.put(ins.operands[0], val); + if (val instanceof NewActivationTreeItem) { + return; + } + if (val instanceof FindPropertyTreeItem) { + return; + } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, ins.operands[0], val)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); - localRegs.put(ins.operands[0], val); - if (val instanceof NewActivationTreeItem) return; - if (val instanceof FindPropertyTreeItem) return; - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, ins.operands[0], val)); - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return TreeItem.localRegName(localRegNames, ins.operands[0]); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return TreeItem.localRegName(localRegNames,ins.operands[0]); - } + public int getRegisterId(AVM2Instruction ins) { + return ins.operands[0]; + } - public int getRegisterId(AVM2Instruction ins) { - return ins.operands[0]; - } - - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalTypeIns.java index cd949cc54..ea43a43c0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -14,12 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.localregs; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; - public interface SetLocalTypeIns { - public abstract int getRegisterId(AVM2Instruction ins); + + public abstract int getRegisterId(AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/DeletePropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/DeletePropertyIns.java index 9f650a797..5875f6781 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/DeletePropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -32,45 +31,42 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DeletePropertyIns extends InstructionDefinition { - public DeletePropertyIns() { - super(0x6a, "deleteproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public DeletePropertyIns() { + super(0x6a, "deleteproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop(); - //push true if removed - throw new RuntimeException("Cannot remove property"); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop(); + //push true if removed + throw new RuntimeException("Cannot remove property"); - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - stack.add(new BooleanTreeItem(ins, Boolean.TRUE));//property successfully deleted - output.add(new DeletePropertyTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + stack.add(new BooleanTreeItem(ins, Boolean.TRUE));//property successfully deleted + output.add(new DeletePropertyTreeItem(ins, obj, multiname)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-1+1; + int ret = -1 + 1; int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyIns.java index 9baafd9c0..afe4a8175 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,41 +30,38 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class FindPropertyIns extends InstructionDefinition { - public FindPropertyIns() { - super(0x5e, "findproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public FindPropertyIns() { + super(0x5e, "findproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - throw new RuntimeException("Cannot find property"); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + throw new RuntimeException("Cannot find property"); - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyTreeItem(ins, multiname)); //resolve right object - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyTreeItem(ins, multiname)); //resolve right object + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=1; + int ret = 1; int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyStrictIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyStrictIns.java index 47f77077c..bdd520cc9 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyStrictIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/FindPropertyStrictIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,36 +30,35 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class FindPropertyStrictIns extends InstructionDefinition { - public FindPropertyStrictIns() { - super(0x5d, "findpropstrict", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public FindPropertyStrictIns() { + super(0x5d, "findpropstrict", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - throw new RuntimeException("Cannot find property"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + throw new RuntimeException("Cannot find property"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyTreeItem(ins, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyTreeItem(ins, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetDescendantsIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetDescendantsIns.java index 9bcc663fc..11c1556b6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetDescendantsIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,38 +30,37 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetDescendantsIns extends InstructionDefinition { - public GetDescendantsIns() { - super(0x59, "getdescentants", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetDescendantsIns() { + super(0x59, "getdescentants", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - Object obj = lda.operandStack.pop(); - throw new RuntimeException("getdescentants not working"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + Object obj = lda.operandStack.pop(); + throw new RuntimeException("getdescentants not working"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - stack.push(new GetDescendantsTreeItem(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + stack.push(new GetDescendantsTreeItem(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalScopeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalScopeIns.java index 9dcb0c17f..c15c6efed 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,27 +27,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetGlobalScopeIns extends InstructionDefinition { - public GetGlobalScopeIns() { - super(0x64, "getglobalscope", new int[]{}); - } + public GetGlobalScopeIns() { + super(0x64, "getglobalscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new RuntimeException("getglobalscope not working"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new RuntimeException("getglobalscope not working"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(scopeStack.get(0)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(scopeStack.get(0)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalSlotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalSlotIns.java index d6271d650..72a05bff3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,35 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetGlobalSlotIns extends InstructionDefinition { - public GetGlobalSlotIns() { - super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public GetGlobalSlotIns() { + super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int slotIndex = ins.operands[0]; - TreeItem obj = (TreeItem) scopeStack.get(0); //scope - Multiname slotname = null; - if (obj instanceof ExceptionTreeItem) { - slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; - } else { - - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getMultiName(constants); - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int slotIndex = ins.operands[0]; + TreeItem obj = (TreeItem) scopeStack.get(0); //scope + Multiname slotname = null; + if (obj instanceof ExceptionTreeItem) { + slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; + } else { + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getMultiName(constants); + } } - } - stack.push(new GetSlotTreeItem(ins, obj, slotname)); - } + + } + } + stack.push(new GetSlotTreeItem(ins, obj, slotname)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetLexIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetLexIns.java index b37cffaa5..200d3bd8f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetLexIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetLexIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,24 +29,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetLexIns extends InstructionDefinition { - public GetLexIns() { - super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetLexIns() { + super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - Multiname multiname = constants.constant_multiname[multinameIndex]; - stack.push(new GetLexTreeItem(ins, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + Multiname multiname = constants.constant_multiname[multinameIndex]; + stack.push(new GetLexTreeItem(ins, multiname)); + } @Override public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { return 1; //multiname may not be runtime } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetPropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetPropertyIns.java index 65d128a3f..e62d46430 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetPropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetPropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,29 +29,28 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetPropertyIns extends InstructionDefinition { - public GetPropertyIns() { - super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetPropertyIns() { + super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - stack.push(new GetPropertyTreeItem(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-1+1; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + stack.push(new GetPropertyTreeItem(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetScopeObjectIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetScopeObjectIns.java index 80bb4d565..a7ac0d8f5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetScopeObjectIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetScopeObjectIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,28 +27,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetScopeObjectIns extends InstructionDefinition { + public GetScopeObjectIns() { + super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); + } - public GetScopeObjectIns() { - super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int index = ins.operands[0]; - /* System.out.println("Getting scope object"+index+":"); - for(TreeItem ti:scopeStack){ - System.out.println(ti.toString(constants)); - }*/ - stack.push(scopeStack.get(index)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int index = ins.operands[0]; + /* System.out.println("Getting scope object"+index+":"); + for(TreeItem ti:scopeStack){ + System.out.println(ti.toString(constants)); + }*/ + stack.push(scopeStack.get(index)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSlotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSlotIns.java index c9cdb2c12..3381a6336 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSlotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSlotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -32,38 +31,35 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetSlotIns extends InstructionDefinition { - public GetSlotIns() { - super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public GetSlotIns() { + super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int slotIndex = ins.operands[0]; - TreeItem obj = (TreeItem) stack.pop(); //scope - Multiname slotname = null; - if (obj instanceof ExceptionTreeItem) { - slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; - } else { - - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getMultiName(constants); - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int slotIndex = ins.operands[0]; + TreeItem obj = (TreeItem) stack.pop(); //scope + Multiname slotname = null; + if (obj instanceof ExceptionTreeItem) { + slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; + } else { + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getMultiName(constants); + } } - } - stack.push(new GetSlotTreeItem(ins, obj, slotname)); - } + + } + } + stack.push(new GetSlotTreeItem(ins, obj, slotname)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSuperIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSuperIns.java index 2a3b4dc15..1187ef9af 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSuperIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/GetSuperIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,33 +29,30 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class GetSuperIns extends InstructionDefinition { - public GetSuperIns() { - super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetSuperIns() { + super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - stack.push(new GetSuperTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + stack.push(new GetSuperTreeItem(ins, obj, multiname)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-1+1; + int ret = -1 + 1; int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNext2Ins.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNext2Ins.java index 0efa82ccd..241860980 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNext2Ins.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNext2Ins.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.avm2.AVM2Code; +import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -29,18 +28,17 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class HasNext2Ins extends InstructionDefinition { - public HasNext2Ins() { - super(0x32, "hasnext2", new int[]{AVM2Code.OPT_U8, AVM2Code.OPT_U8}); - } + public HasNext2Ins() { + super(0x32, "hasnext2", new int[]{AVM2Code.OPT_U8, AVM2Code.OPT_U8}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int objectReg = ins.operands[0]; - int indexReg = ins.operands[1]; - //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); - stack.push(new InTreeItem(ins, new LocalRegTreeItem(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int objectReg = ins.operands[0]; + int indexReg = ins.operands[1]; + //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); + stack.push(new InTreeItem(ins, new LocalRegTreeItem(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNextIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNextIns.java index bc70dc98c..9887fb2a2 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNextIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/HasNextIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,25 +27,22 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class HasNextIns extends InstructionDefinition { - public HasNextIns() { - super(0x1f, "hasnext", new int[]{}); - } + public HasNextIns() { + super(0x1f, "hasnext", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem curIndex = (TreeItem) stack.pop(); - TreeItem obj = (TreeItem) stack.pop(); - stack.push(new InTreeItem(ins, curIndex, obj)); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem curIndex = (TreeItem) stack.pop(); + TreeItem obj = (TreeItem) stack.pop(); + stack.push(new InTreeItem(ins, curIndex, obj)); - } + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InIns.java index 8b5396b67..a45839534 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,24 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class InIns extends InstructionDefinition { - public InIns() { - super(0xb4, "in", new int[]{}); - } + public InIns() { + super(0xb4, "in", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem obj = (TreeItem) stack.pop(); - TreeItem name = (TreeItem) stack.pop(); - stack.push(new InTreeItem(ins, name, obj)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem obj = (TreeItem) stack.pop(); + TreeItem name = (TreeItem) stack.pop(); + stack.push(new InTreeItem(ins, name, obj)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InitPropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InitPropertyIns.java index a386daba5..81a91c94b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InitPropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/InitPropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,31 +29,30 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class InitPropertyIns extends InstructionDefinition { - public InitPropertyIns() { - super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public InitPropertyIns() { + super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; - TreeItem val = (TreeItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - output.add(new InitPropertyTreeItem(ins, obj, multiname, val)); - } + TreeItem val = (TreeItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + output.add(new InitPropertyTreeItem(ins, obj, multiname, val)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-2; + int ret = -2; int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/LabelIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/LabelIns.java index 538023235..73e31b7e6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/LabelIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/LabelIns.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; - public class LabelIns extends InstructionDefinition { //this can be target of branch - public LabelIns() { - super(0x09, "label", new int[]{}); - } - + public LabelIns() { + super(0x09, "label", new int[]{}); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextNameIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextNameIns.java index a421156f8..a0156cb6b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextNameIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextNameIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -27,25 +26,22 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NextNameIns extends InstructionDefinition { - public NextNameIns() { - super(0x1e, "nextname", new int[]{}); - } + public NextNameIns() { + super(0x1e, "nextname", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem index = stack.pop(); - TreeItem obj = stack.pop(); - //stack.push(obj + ".nextName(" + index + ")"); - stack.push(index); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem index = stack.pop(); + TreeItem obj = stack.pop(); + //stack.push(obj + ".nextName(" + index + ")"); + stack.push(index); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextValueIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextValueIns.java index e77a4abdb..67f75fb0d 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextValueIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NextValueIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -27,25 +26,22 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class NextValueIns extends InstructionDefinition { - public NextValueIns() { - super(0x23, "nextvalue", new int[]{}); - } + public NextValueIns() { + super(0x23, "nextvalue", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem index = stack.pop(); - TreeItem obj = stack.pop(); - //stack.push(obj + ".nextValue(" + index + ")"); - stack.push(index); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem index = stack.pop(); + TreeItem obj = stack.pop(); + //stack.push(obj + ".nextValue(" + index + ")"); + stack.push(index); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NopIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NopIns.java index 54630ffd2..a0217ceae 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NopIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/NopIns.java @@ -14,16 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; - public class NopIns extends InstructionDefinition { - public NopIns() { - super(0x02, "nop", new int[]{}); - } - + public NopIns() { + super(0x02, "nop", new int[]{}); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnValueIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnValueIns.java index cd7a613d1..b5ed60f1f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnValueIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnValueIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ReturnValueIns extends InstructionDefinition { - public ReturnValueIns() { - super(0x48, "returnvalue", new int[]{}); - } + public ReturnValueIns() { + super(0x48, "returnvalue", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - output.add(new ReturnValueTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + output.add(new ReturnValueTreeItem(ins, (TreeItem) stack.pop())); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnVoidIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnVoidIns.java index a88f46f45..fbeaefbe5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnVoidIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ReturnVoidIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import com.jpexs.asdec.abc.avm2.treemodel.ReturnVoidTreeItem; @@ -27,15 +26,14 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ReturnVoidIns extends InstructionDefinition { - public ReturnVoidIns() { - super(0x47, "returnvoid", new int[]{}); - } + public ReturnVoidIns() { + super(0x47, "returnvoid", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - output.add(new ReturnVoidTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + output.add(new ReturnVoidTreeItem(ins)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetGlobalSlotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetGlobalSlotIns.java index ad950c48d..ab4afc483 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetGlobalSlotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetGlobalSlotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,26 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIns { - public SetGlobalSlotIns() { - super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public SetGlobalSlotIns() { + super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - output.add(new SetGlobalSlotTreeItem(ins, ins.operands[0], (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + output.add(new SetGlobalSlotTreeItem(ins, ins.operands[0], (TreeItem) stack.pop())); + } - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - return "globalslot" + ins.operands[0]; - } + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + return "globalslot" + ins.operands[0]; + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetPropertyIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetPropertyIns.java index 236283f62..2a5c5e933 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetPropertyIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetPropertyIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,38 +30,39 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetPropertyIns extends InstructionDefinition implements SetTypeIns { - public SetPropertyIns() { - super(0x61, "setproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public SetPropertyIns() { + super(0x61, "setproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - TreeItem value = (TreeItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - output.add(new SetPropertyTreeItem(ins, obj, multiname, value)); - } - - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(0, stack, constants, multinameIndex, ins); - TreeItem obj = stack.get(1 + resolvedCount(constants, multinameIndex)); //pod vrcholem - if ((!obj.toString().equals(""))) multiname = "." + multiname; - return obj + multiname; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-2; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + TreeItem value = (TreeItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + output.add(new SetPropertyTreeItem(ins, obj, multiname, value)); + } + + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + String multiname = resolveMultinameNoPop(0, stack, constants, multinameIndex, ins); + TreeItem obj = stack.get(1 + resolvedCount(constants, multinameIndex)); //pod vrcholem + if ((!obj.toString().equals(""))) { + multiname = "." + multiname; + } + return obj + multiname; + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSlotIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSlotIns.java index 6ff871e5a..6a71fcfcc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSlotIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSlotIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -34,62 +33,59 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetSlotIns extends InstructionDefinition implements SetTypeIns { - public SetSlotIns() { - super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public SetSlotIns() { + super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int slotIndex = ins.operands[0]; - TreeItem value = (TreeItem) stack.pop(); - TreeItem obj = (TreeItem) stack.pop(); //scopeId + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int slotIndex = ins.operands[0]; + TreeItem value = (TreeItem) stack.pop(); + TreeItem obj = (TreeItem) stack.pop(); //scopeId - if (obj instanceof ExceptionTreeItem) { + if (obj instanceof ExceptionTreeItem) { + return; + } + //if(value.startsWith("catched ")) return; + Multiname slotname = null; + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getMultiName(constants); + } + } + + } + + //if new activation sets params of the function + if (obj instanceof NewActivationTreeItem) { + if (localRegNames.containsValue(slotname.getName(constants))) { return; - } - //if(value.startsWith("catched ")) return; - Multiname slotname = null; - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getMultiName(constants); - } + } + } + + output.add(new SetSlotTreeItem(ins, obj, slotname, value)); + } + + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + int slotIndex = ins.operands[0]; + ////String obj = stack.get(1); + String slotname = ""; + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getMultiName(constants).getName(constants); } + } - } - - //if new activation sets params of the function - if(obj instanceof NewActivationTreeItem){ - if(localRegNames.containsValue(slotname.getName(constants))){ - return; - } - } - - output.add(new SetSlotTreeItem(ins, obj, slotname, value)); - } - - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - int slotIndex = ins.operands[0]; - ////String obj = stack.get(1); - String slotname = ""; - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getMultiName(constants).getName(constants); - } - } - - } - return slotname; - } + } + return slotname; + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -2; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSuperIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSuperIns.java index cbd793ac2..42c2d8ae0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSuperIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/SetSuperIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,38 +30,37 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SetSuperIns extends InstructionDefinition implements SetTypeIns { - public SetSuperIns() { - super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public SetSuperIns() { + super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - - TreeItem value = (TreeItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - TreeItem obj = (TreeItem) stack.pop(); - output.add(new SetSuperTreeItem(ins, value, obj, multiname)); - } - - public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body,HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(1, stack, constants, multinameIndex, ins); - String obj = stack.get(1 + resolvedCount(constants, multinameIndex)).toString(constants,localRegNames); - return obj + ".super." + multiname; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret=-2; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { int multinameIndex = ins.operands[0]; - if(abc.constants.constant_multiname[multinameIndex].needsName()){ + + TreeItem value = (TreeItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + TreeItem obj = (TreeItem) stack.pop(); + output.add(new SetSuperTreeItem(ins, value, obj, multiname)); + } + + public String getObject(Stack stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + String multiname = resolveMultinameNoPop(1, stack, constants, multinameIndex, ins); + String obj = stack.get(1 + resolvedCount(constants, multinameIndex)).toString(constants, localRegNames); + return obj + ".super." + multiname; + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { ret--; } - if(abc.constants.constant_multiname[multinameIndex].needsNs()){ + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { ret--; } return ret; diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ThrowIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ThrowIns.java index c9b7e239a..82f7c3c90 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ThrowIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/other/ThrowIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.other; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -29,22 +28,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ThrowIns extends InstructionDefinition { - public ThrowIns() { - super(0x03, "throw", new int[]{}); - } + public ThrowIns() { + super(0x03, "throw", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc,HashMap localRegNames) { - output.add(new ThrowTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames) { + output.add(new ThrowTreeItem(ins, (TreeItem) stack.pop())); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/DupIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/DupIns.java index 58fe28db1..4554e472d 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/DupIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/DupIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,32 +27,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DupIns extends InstructionDefinition { - public DupIns() { - super(0x2a, "dup", new int[]{}); - } + public DupIns() { + super(0x2a, "dup", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj); - lda.operandStack.push(obj); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj); + lda.operandStack.push(obj); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem v = (TreeItem) stack.pop(); - stack.push(v); - stack.push(v); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem v = (TreeItem) stack.pop(); + stack.push(v); + stack.push(v); - } + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+2; + return -1 + 2; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopIns.java index a6a85a54f..d771f4d27 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,52 +27,37 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PopIns extends InstructionDefinition { - public PopIns() { - super(0x29, "pop", new int[]{}); - } + public PopIns() { + super(0x29, "pop", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.pop(); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.pop(); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - if (stack.size() > 0) - { - TreeItem top=stack.pop(); - if(top instanceof CallPropertyTreeItem) - { - output.add(top); - }else - if(top instanceof CallSuperTreeItem) - { - output.add(top); - }else - if(top instanceof CallStaticTreeItem) - { - output.add(top); - } - else - if(top instanceof CallMethodTreeItem) - { - output.add(top); - } - else - if(top instanceof CallTreeItem) - { - output.add(top); - } - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + if (stack.size() > 0) { + TreeItem top = stack.pop(); + if (top instanceof CallPropertyTreeItem) { + output.add(top); + } else if (top instanceof CallSuperTreeItem) { + output.add(top); + } else if (top instanceof CallStaticTreeItem) { + output.add(top); + } else if (top instanceof CallMethodTreeItem) { + output.add(top); + } else if (top instanceof CallTreeItem) { + output.add(top); + } + } + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java index 4ffa60d50..c4851541c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PopScopeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -31,47 +30,44 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PopScopeIns extends InstructionDefinition { - public PopScopeIns() { - super(0x1d, "popscope", new int[]{}); - } + public PopScopeIns() { + super(0x1d, "popscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.scopeStack.pop(); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.scopeStack.pop(); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc,HashMap localRegNames) { - TreeItem scope = (TreeItem) scopeStack.pop(); - for (int i = output.size() - 1; i >= 0; i--) { - if (output.get(i) instanceof WithTreeItem) { - WithTreeItem wti = (WithTreeItem) output.get(i); - if (wti.scope == scope) { - wti.items = new ArrayList(); - for (int k = i + 1; k < output.size(); k++) { - //output.subList(i+1, output.size()); - wti.items.add(output.get(k)); - } - while (output.size() > i + 1) { - output.remove(i + 1); - } - /*int count=output.size()-1-(i+1); - for(int c=0;c localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames) { + TreeItem scope = (TreeItem) scopeStack.pop(); + for (int i = output.size() - 1; i >= 0; i--) { + if (output.get(i) instanceof WithTreeItem) { + WithTreeItem wti = (WithTreeItem) output.get(i); + if (wti.scope == scope) { + wti.items = new ArrayList(); + for (int k = i + 1; k < output.size(); k++) { + //output.subList(i+1, output.size()); + wti.items.add(output.get(k)); + } + while (output.size() > i + 1) { + output.remove(i + 1); + } + /*int count=output.size()-1-(i+1); + for(int c=0;c. */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,29 +29,24 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushByteIns extends InstructionDefinition { - public PushByteIns() { - super(0x24, "pushbyte", new int[]{AVM2Code.OPT_BYTE}); - } + public PushByteIns() { + super(0x24, "pushbyte", new int[]{AVM2Code.OPT_BYTE}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushDoubleIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushDoubleIns.java index 4689eb192..1161c87b6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushDoubleIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushDoubleIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,24 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushDoubleIns extends InstructionDefinition { - public PushDoubleIns() { - super(0x2f, "pushdouble", new int[]{AVM2Code.DAT_DOUBLE_INDEX}); - } + public PushDoubleIns() { + super(0x2f, "pushdouble", new int[]{AVM2Code.DAT_DOUBLE_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new FloatValueTreeItem(ins, constants.constant_double[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new FloatValueTreeItem(ins, constants.constant_double[ins.operands[0]])); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushFalseIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushFalseIns.java index 895559381..6d2377384 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushFalseIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushFalseIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,24 +28,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushFalseIns extends InstructionDefinition { - public PushFalseIns() { - super(0x27, "pushfalse", new int[]{}); - } + public PushFalseIns() { + super(0x27, "pushfalse", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(Boolean.FALSE); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(Boolean.FALSE); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new BooleanTreeItem(ins, Boolean.FALSE)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new BooleanTreeItem(ins, Boolean.FALSE)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushIntIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushIntIns.java index e04661f61..4b5d633cd 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushIntIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushIntIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,24 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushIntIns extends InstructionDefinition { - public PushIntIns() { - super(0x2d, "pushint", new int[]{AVM2Code.DAT_INT_INDEX}); - } + public PushIntIns() { + super(0x2d, "pushint", new int[]{AVM2Code.DAT_INT_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new IntegerValueTreeItem(ins, constants.constant_int[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IntegerValueTreeItem(ins, constants.constant_int[ins.operands[0]])); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNamespaceIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNamespaceIns.java index e89ce9c7b..2e05b13a5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNamespaceIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNamespaceIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,19 +29,18 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushNamespaceIns extends InstructionDefinition { - public PushNamespaceIns() { - super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); - } + public PushNamespaceIns() { + super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc,HashMap localRegNames) { - stack.push(new NameSpaceTreeItem(ins, ins.operands[0])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames) { + stack.push(new NameSpaceTreeItem(ins, ins.operands[0])); + } -@Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNanIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNanIns.java index bc69cbc49..37565762c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNanIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNanIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,19 +27,18 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushNanIns extends InstructionDefinition { - public PushNanIns() { - super(0x28, "pushnan", new int[]{}); - } + public PushNanIns() { + super(0x28, "pushnan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new NanTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new NanTreeItem(ins)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNullIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNullIns.java index d7c2ae4ce..bd49337f1 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNullIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushNullIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,19 +27,18 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushNullIns extends InstructionDefinition { - public PushNullIns() { - super(0x20, "pushnull", new int[]{}); - } + public PushNullIns() { + super(0x20, "pushnull", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new NullTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new NullTreeItem(ins)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushScopeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushScopeIns.java index 0656f94f6..25a35b26c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushScopeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushScopeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,24 +27,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushScopeIns extends InstructionDefinition { - public PushScopeIns() { - super(0x30, "pushscope", new int[]{}); - } + public PushScopeIns() { + super(0x30, "pushscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.scopeStack.push(lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.scopeStack.push(lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - scopeStack.push(stack.pop()); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + scopeStack.push(stack.pop()); + } -@Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } @@ -54,6 +52,4 @@ public class PushScopeIns extends InstructionDefinition { public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushShortIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushShortIns.java index acafa40eb..e3e75150b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushShortIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushShortIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,24 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushShortIns extends InstructionDefinition { - public PushShortIns() { - super(0x25, "pushshort", new int[]{AVM2Code.OPT_U30}); - } + public PushShortIns() { + super(0x25, "pushshort", new int[]{AVM2Code.OPT_U30}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushStringIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushStringIns.java index 56e05d77f..2d444b791 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushStringIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushStringIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,24 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushStringIns extends InstructionDefinition { - public PushStringIns() { - super(0x2c, "pushstring", new int[]{AVM2Code.DAT_STRING_INDEX}); - } + public PushStringIns() { + super(0x2c, "pushstring", new int[]{AVM2Code.DAT_STRING_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new StringTreeItem(ins, constants.constant_string[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new StringTreeItem(ins, constants.constant_string[ins.operands[0]])); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushTrueIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushTrueIns.java index bdc4eaf10..00a5089bc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushTrueIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushTrueIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,24 +28,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushTrueIns extends InstructionDefinition { - public PushTrueIns() { - super(0x26, "pushtrue", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(Boolean.TRUE); - } + public PushTrueIns() { + super(0x26, "pushtrue", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new BooleanTreeItem(ins, Boolean.TRUE)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(Boolean.TRUE); + } - @Override + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new BooleanTreeItem(ins, Boolean.TRUE)); + } + + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUIntIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUIntIns.java index fd935a2de..bda044d05 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUIntIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUIntIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,24 +29,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushUIntIns extends InstructionDefinition { - public PushUIntIns() { - super(0x2e, "pushuint", new int[]{AVM2Code.DAT_UINT_INDEX}); - } + public PushUIntIns() { + super(0x2e, "pushuint", new int[]{AVM2Code.DAT_UINT_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new IntegerValueTreeItem(ins, constants.constant_uint[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new IntegerValueTreeItem(ins, constants.constant_uint[ins.operands[0]])); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUndefinedIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUndefinedIns.java index 10dd90329..696909f7e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUndefinedIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushUndefinedIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,19 +27,18 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushUndefinedIns extends InstructionDefinition { - public PushUndefinedIns() { - super(0x21, "pushundefined", new int[]{}); - } + public PushUndefinedIns() { + super(0x21, "pushundefined", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new UndefinedTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new UndefinedTreeItem(ins)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java index bc808be58..40a36e63f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/PushWithIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -29,21 +28,20 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class PushWithIns extends InstructionDefinition { - public PushWithIns() { - super(0x1c, "pushwith", new int[]{}); - } + public PushWithIns() { + super(0x1c, "pushwith", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc,HashMap localRegNames) { - TreeItem w = (TreeItem) stack.pop(); - scopeStack.push(w); - output.add(new WithTreeItem(ins, w)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames) { + TreeItem w = (TreeItem) stack.pop(); + scopeStack.push(w); + output.add(new WithTreeItem(ins, w)); + } -@Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } @@ -52,6 +50,4 @@ public class PushWithIns extends InstructionDefinition { public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { return 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/SwapIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/SwapIns.java index 4ede49d25..f622062eb 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/SwapIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/stack/SwapIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.stack; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,35 +28,32 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class SwapIns extends InstructionDefinition { - public SwapIns() { - super(0x2b, "swap", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj1 = lda.operandStack.pop(); - Object obj2 = lda.operandStack.pop(); - lda.operandStack.push(obj1); - lda.operandStack.push(obj2); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc,HashMap localRegNames) { - - TreeItem o1 = stack.pop(); - TreeItem o2 = stack.pop(); - stack.push(o1); - stack.push(o2); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+2; + public SwapIns() { + super(0x2b, "swap", new int[]{}); } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj1 = lda.operandStack.pop(); + Object obj2 = lda.operandStack.pop(); + lda.operandStack.push(obj1); + lda.operandStack.push(obj2); + } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames) { + + TreeItem o1 = stack.pop(); + TreeItem o2 = stack.pop(); + stack.push(o1); + stack.push(o2); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 2; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ApplyTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ApplyTypeIns.java index 60044f7bd..007427adc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ApplyTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ApplyTypeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -28,39 +27,36 @@ import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import com.jpexs.asdec.abc.types.MethodInfo; import java.util.*; - public class ApplyTypeIns extends InstructionDefinition { - public ApplyTypeIns() { - super(0x53,"applytype",new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ApplyTypeIns() { + super(0x53, "applytype", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int argCount = (int) ((Long) arguments.get(0)).longValue(); - List params = new ArrayList(); - for (int i = 0;i - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int argCount = (int) ((Long) arguments.get(0)).longValue(); + List params = new ArrayList(); + for (int i = 0; i < argCount; i++) { + params.add(lda.operandStack.pop()); + } + Collections.reverse(params); + //TODO: pop type and push type + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int argCount = ins.operands[0]; - List params = new ArrayList(); - for (int i = 0;i localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int argCount = ins.operands[0]; + List params = new ArrayList(); + for (int i = 0; i < argCount; i++) { + params.add(stack.pop()); + } + Collections.reverse(params); + stack.push(new ApplyTypeTreeItem(ins, stack.pop(), params)); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0]+1; + return -ins.operands[0] + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeIns.java index d391eb403..bcd97c9a3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -31,34 +30,31 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class AsTypeIns extends InstructionDefinition { - public AsTypeIns() { - super(0x86, "astype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public AsTypeIns() { + super(0x86, "astype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long typeIndex = (Long) arguments.get(0); - Object obj = lda.operandStack.pop(); - //if multiname[typeIndex]==obj - lda.operandStack.push(obj); - //else push null + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long typeIndex = (Long) arguments.get(0); + Object obj = lda.operandStack.pop(); + //if multiname[typeIndex]==obj + lda.operandStack.push(obj); + //else push null - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem val = (TreeItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem val = (TreeItem) stack.pop(); - stack.push(new AsTypeTreeItem(ins, val, new FullMultinameTreeItem(ins, ins.operands[0]))); - } + stack.push(new AsTypeTreeItem(ins, val, new FullMultinameTreeItem(ins, ins.operands[0]))); + } @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeLateIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeLateIns.java index 754062927..7ea5ccfed 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeLateIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/AsTypeLateIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,31 +28,30 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class AsTypeLateIns extends InstructionDefinition { - public AsTypeLateIns() { - super(0x87, "astypelate", new int[]{}); - } + public AsTypeLateIns() { + super(0x87, "astypelate", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object objClass = lda.operandStack.pop(); - Object obj = lda.operandStack.pop(); - //if obj.class=objClass - lda.operandStack.push(obj); - //else push null - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object objClass = lda.operandStack.pop(); + Object obj = lda.operandStack.pop(); + //if obj.class=objClass + lda.operandStack.push(obj); + //else push null + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem cls = (TreeItem) stack.pop(); - TreeItem val = (TreeItem) stack.pop(); - stack.push(new AsTypeTreeItem(ins, val, cls)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem cls = (TreeItem) stack.pop(); + TreeItem val = (TreeItem) stack.pop(); + stack.push(new AsTypeTreeItem(ins, val, cls)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceAIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceAIns.java index 4f04f73fb..17ddd7102 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceAIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceAIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,34 +28,33 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; +public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns { -public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns{ - - public CoerceAIns() { - super(0x82, "coerce_a", new int[]{}); - } - - public String getTargetType(){ - return "*"; - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //coerce any type - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), "*")); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public CoerceAIns() { + super(0x82, "coerce_a", new int[]{}); + } + + public String getTargetType() { + return "*"; + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //coerce any type + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), "*")); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "*"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "*"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceIns.java index 6e2a2acb7..f857d4974 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; @@ -30,32 +29,31 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CoerceIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public CoerceIns() { - super(0x80, "coerce", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public CoerceIns() { + super(0x80, "coerce", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - //push and pop coerced value to specified type - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + //push and pop coerced value to specified type + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), constants.constant_multiname[multinameIndex].getName(constants))); - } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - int multinameIndex = ins.operands[0]; - return constants.constant_multiname[multinameIndex].getName(constants); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), constants.constant_multiname[multinameIndex].getName(constants))); + } - @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + int multinameIndex = ins.operands[0]; + return constants.constant_multiname[multinameIndex].getName(constants); + } + + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java index 8be12080b..7d51aedc4 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,5 +24,6 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; * @author JPEXS */ public interface CoerceOrConvertTypeIns { - public String getTargetType(ConstantPool constants,AVM2Instruction ins); + + public String getTargetType(ConstantPool constants, AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceSIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceSIns.java index 92103f4cd..5ca8eb0e6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceSIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/CoerceSIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,31 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CoerceSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public CoerceSIns() { - super(0x85, "coerce_s", new int[]{}); - } - - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj.toString()); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), "string")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public CoerceSIns() { + super(0x85, "coerce_s", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj.toString()); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new CoerceTreeItem(ins, (TreeItem) stack.pop(), "string")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "String"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "String"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertBIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertBIns.java index 425e7996a..0c3916113 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertBIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertBIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,40 +28,39 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertBIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertBIns() { - super(0x76, "convert_b", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - boolean bval = false; - if (value instanceof Boolean) { - bval = (Boolean) value; - } else if (value instanceof Long) { - bval = ((Long) value).longValue() != 0; - } else if (value instanceof String) { - bval = !((String) value).equals(""); - } else { - bval = true; - } - lda.operandStack.push(new Boolean(bval)); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "boolean")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertBIns() { + super(0x76, "convert_b", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + boolean bval = false; + if (value instanceof Boolean) { + bval = (Boolean) value; + } else if (value instanceof Long) { + bval = ((Long) value).longValue() != 0; + } else if (value instanceof String) { + bval = !((String) value).equals(""); + } else { + bval = true; + } + lda.operandStack.push(new Boolean(bval)); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "boolean")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "Boolean"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "Boolean"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertDIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertDIns.java index d35282aa1..d2388c427 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertDIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertDIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,48 +28,47 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertDIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertDIns() { - super(0x75, "convert_d", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - double ret = 0; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { - ret = 1; - } else { - ret = 0; - } - } else if (value instanceof Long) { - ret = ((Long) value).longValue(); - } else if (value instanceof Double) { - ret = ((Double) value).doubleValue(); - } else if (value instanceof String) { - ret = Double.parseDouble((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(new Double(ret)); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "double")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertDIns() { + super(0x75, "convert_d", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + double ret = 0; + if (value == null) { + ret = 0; + } else if (value instanceof Boolean) { + if (((Boolean) value).booleanValue()) { + ret = 1; + } else { + ret = 0; + } + } else if (value instanceof Long) { + ret = ((Long) value).longValue(); + } else if (value instanceof Double) { + ret = ((Double) value).doubleValue(); + } else if (value instanceof String) { + ret = Double.parseDouble((String) value); + } else { + ret = 1; //must call toPrimitive + } + lda.operandStack.push(new Double(ret)); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "double")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "Number"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "Number"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertIIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertIIns.java index de83aa912..907490a0a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertIIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertIIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,46 +28,45 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertIIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertIIns() { - super(0x73, "convert_i", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - long ret = 0; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { - ret = 1; - } else { - ret = 0; - } - } else if (value instanceof Long) { - ret = ((Long) value).longValue(); - } else if (value instanceof String) { - ret = Long.parseLong((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(new Long(ret)); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "int")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertIIns() { + super(0x73, "convert_i", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + long ret = 0; + if (value == null) { + ret = 0; + } else if (value instanceof Boolean) { + if (((Boolean) value).booleanValue()) { + ret = 1; + } else { + ret = 0; + } + } else if (value instanceof Long) { + ret = ((Long) value).longValue(); + } else if (value instanceof String) { + ret = Long.parseLong((String) value); + } else { + ret = 1; //must call toPrimitive + } + lda.operandStack.push(new Long(ret)); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "int")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "int"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "int"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertOIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertOIns.java index 8cf9c3e48..23538207e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertOIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertOIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,29 +28,28 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertOIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertOIns() { - super(0x77, "convert_o", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //throw if pop is not object - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "Object")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertOIns() { + super(0x77, "convert_o", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //throw if pop is not object + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "Object")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "Object"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "Object"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertSIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertSIns.java index fa29fd895..3f1e936ff 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertSIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertSIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,30 +28,29 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertSIns() { - super(0x70, "convert_s", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj.toString()); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "string")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertSIns() { + super(0x70, "convert_s", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj.toString()); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "string")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "String"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "String"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertUIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertUIns.java index d75028653..32c35ce2a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertUIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/ConvertUIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,29 +28,28 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class ConvertUIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertUIns() { - super(0x74, "convert_u", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new UnsupportedOperationException("Cannot convert to uint "); - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "uint")); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + public ConvertUIns() { + super(0x74, "convert_u", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new UnsupportedOperationException("Cannot convert to uint "); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new ConvertTreeItem(ins, (TreeItem) stack.pop(), "uint")); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + public String getTargetType(ConstantPool constants, AVM2Instruction ins) { + return "uint"; } - - public String getTargetType(ConstantPool constants,AVM2Instruction ins){ - return "uint"; - } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/InstanceOfIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/InstanceOfIns.java index 3d144119e..86d8f68de 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/InstanceOfIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/InstanceOfIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class InstanceOfIns extends InstructionDefinition { - public InstanceOfIns() { - super(0xb1, "instanceof", new int[]{}); - } + public InstanceOfIns() { + super(0xb1, "instanceof", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem type = (TreeItem) stack.pop(); - TreeItem value = (TreeItem) stack.pop(); - stack.push(new InstanceOfTreeItem(ins, value, type)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem type = (TreeItem) stack.pop(); + TreeItem value = (TreeItem) stack.pop(); + stack.push(new InstanceOfTreeItem(ins, value, type)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeIns.java index 6dc54fce0..e39cfb745 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.AVM2Code; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -30,22 +29,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IsTypeIns extends InstructionDefinition { - public IsTypeIns() { - super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public IsTypeIns() { + super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - int multinameIndex = ins.operands[0]; - TreeItem value = (TreeItem) stack.pop(); - stack.push(new IsTypeTreeItem(ins, value, new FullMultinameTreeItem(ins, multinameIndex))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + int multinameIndex = ins.operands[0]; + TreeItem value = (TreeItem) stack.pop(); + stack.push(new IsTypeTreeItem(ins, value, new FullMultinameTreeItem(ins, multinameIndex))); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; //may not be runtime multiname + return -1 + 1; //may not be runtime multiname } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeLateIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeLateIns.java index f465e8e05..5c921892e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeLateIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/IsTypeLateIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,22 +27,21 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class IsTypeLateIns extends InstructionDefinition { - public IsTypeLateIns() { - super(0xb3, "istypelate", new int[]{}); - } + public IsTypeLateIns() { + super(0xb3, "istypelate", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem type = (TreeItem) stack.pop(); - TreeItem value = (TreeItem) stack.pop(); - stack.push(new IsTypeTreeItem(ins, value, type)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem type = (TreeItem) stack.pop(); + TreeItem value = (TreeItem) stack.pop(); + stack.push(new IsTypeTreeItem(ins, value, type)); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2+1; + return -2 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/TypeOfIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/TypeOfIns.java index ed92695e5..9b7529d4c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/TypeOfIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/types/TypeOfIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.types; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; @@ -28,20 +27,19 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class TypeOfIns extends InstructionDefinition { - public TypeOfIns() { - super(0x95, "typeof", new int[]{}); - } + public TypeOfIns() { + super(0x95, "typeof", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new TypeOfTreeItem(ins, (TreeItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new TypeOfTreeItem(ins, (TreeItem) stack.pop())); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/CheckFilterIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/CheckFilterIns.java index 806127897..907746014 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/CheckFilterIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/CheckFilterIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.xml; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -28,25 +27,23 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class CheckFilterIns extends InstructionDefinition { - public CheckFilterIns() { - super(0x78, "checkfilter", new int[]{}); - } + public CheckFilterIns() { + super(0x78, "checkfilter", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //if pop() is not XML|XMLList throw - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //if pop() is not XML|XMLList throw + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + } - } - -@Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSIns.java index 59abb5133..a1658abf5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSIns.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.xml; import com.jpexs.asdec.abc.avm2.AVM2Code; @@ -23,19 +22,17 @@ import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition; import java.util.List; - public class DXNSIns extends InstructionDefinition { - public DXNSIns() { - super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); - } + public DXNSIns() { + super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int strIndex = (int) ((Long) arguments.get(0)).longValue(); - String s = constants.constant_string[strIndex]; - System.out.println("Set default XML space " + s); - - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int strIndex = (int) ((Long) arguments.get(0)).longValue(); + String s = constants.constant_string[strIndex]; + System.out.println("Set default XML space " + s); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java index bff373a77..34cb11b5e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/DXNSLateIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.xml; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,26 +28,25 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class DXNSLateIns extends InstructionDefinition { - public DXNSLateIns() { - super(0x07, "dxnslate", new int[]{}); - } + public DXNSLateIns() { + super(0x07, "dxnslate", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - System.out.println("Set default XML space " + s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + System.out.println("Set default XML space " + s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - TreeItem xmlns = stack.pop(); - stack.push(new UnparsedTreeItem(ins, "XMLNS:" + xmlns.toString(constants,localRegNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + TreeItem xmlns = stack.pop(); + stack.push(new UnparsedTreeItem(ins, "XMLNS:" + xmlns.toString(constants, localRegNames))); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { return -1; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java index b37895e1d..48d51481f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXAttrIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.xml; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,27 +28,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class EscXAttrIns extends InstructionDefinition { - public EscXAttrIns() { - super(0x72, "esc_xattr", new int[]{}); - } + public EscXAttrIns() { + super(0x72, "esc_xattr", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - //escape - lda.operandStack.push(s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + //escape + lda.operandStack.push(s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new UnparsedTreeItem(ins, "esc_xattr(" + stack.pop().toString(constants,localRegNames) + ")")); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new UnparsedTreeItem(ins, "esc_xattr(" + stack.pop().toString(constants, localRegNames) + ")")); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXElemIns.java b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXElemIns.java index 2795749af..daf739f0b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXElemIns.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/instructions/xml/EscXElemIns.java @@ -14,10 +14,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.instructions.xml; - import com.jpexs.asdec.abc.ABC; +import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.LocalDataArea; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; @@ -29,27 +28,26 @@ import java.util.HashMap; import java.util.List; import java.util.Stack; - public class EscXElemIns extends InstructionDefinition { - public EscXElemIns() { - super(0x71, "esc_xelem", new int[]{}); - } + public EscXElemIns() { + super(0x71, "esc_xelem", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - //escape - lda.operandStack.push(s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + //escape + lda.operandStack.push(s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { - stack.push(new UnparsedTreeItem(ins, "esc_xelem(" + stack.pop().toString(constants,localRegNames) + ")")); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc, HashMap localRegNames) { + stack.push(new UnparsedTreeItem(ins, "esc_xelem(" + stack.pop().toString(constants, localRegNames) + ")")); + } - @Override + @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1+1; + return -1 + 1; } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ASM3Parser.java b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ASM3Parser.java index e0a4fe1d1..0991eb39a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ASM3Parser.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ASM3Parser.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.parser; import com.jpexs.asdec.abc.avm2.AVM2Code; @@ -28,284 +27,287 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; - public class ASM3Parser { - private static class OffsetItem { + private static class OffsetItem { - public String label = ""; - public long insPosition; - public int insOperandIndex; + public String label = ""; + public long insPosition; + public int insOperandIndex; - public OffsetItem(String label, long insOffset, int insOperandIndex) { - this.label = label; - this.insPosition = insOffset; - this.insOperandIndex = insOperandIndex; - } - } + public OffsetItem(String label, long insOffset, int insOperandIndex) { + this.label = label; + this.insPosition = insOffset; + this.insOperandIndex = insOperandIndex; + } + } - private static class CaseOffsetItem extends OffsetItem { + private static class CaseOffsetItem extends OffsetItem { - public CaseOffsetItem(String label, long insOffset, int insOperandIndex) { - super(label, insOffset, insOperandIndex); - } - } + public CaseOffsetItem(String label, long insOffset, int insOperandIndex) { + super(label, insOffset, insOperandIndex); + } + } - private static class LabelItem { + private static class LabelItem { - public String label = ""; - public int offset; + public String label = ""; + public int offset; - public LabelItem(String label, int offset) { - this.label = label; - this.offset = offset; - } - } + public LabelItem(String label, int offset) { + this.label = label; + this.offset = offset; + } + } - public static AVM2Code parse(InputStream is, ConstantPool constants,MethodBody body) throws IOException, ParseException { - return parse(is, constants, null,body); - } + public static AVM2Code parse(InputStream is, ConstantPool constants, MethodBody body) throws IOException, ParseException { + return parse(is, constants, null, body); + } - public static AVM2Code parse(InputStream is, ConstantPool constants, MissingSymbolHandler missingHandler,MethodBody body) throws IOException, ParseException { - AVM2Code code = new AVM2Code(); + public static AVM2Code parse(InputStream is, ConstantPool constants, MissingSymbolHandler missingHandler, MethodBody body) throws IOException, ParseException { + AVM2Code code = new AVM2Code(); - List offsetItems = new ArrayList(); - List labelItems = new ArrayList(); - List exceptions=new ArrayList(); - List exceptionIndices=new ArrayList(); - int offset = 0; + List offsetItems = new ArrayList(); + List labelItems = new ArrayList(); + List exceptions = new ArrayList(); + List exceptionIndices = new ArrayList(); + int offset = 0; - Flasm3Lexer lexer = new Flasm3Lexer(is); + Flasm3Lexer lexer = new Flasm3Lexer(is); - ParsedSymbol symb; - AVM2Instruction lastIns = null; - do { - symb = lexer.yylex(); - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_START){ - int exIndex=(Integer)symb.value; - int listIndex=exceptionIndices.indexOf(exIndex); - if(listIndex==-1){ - throw new ParseException("Undefinex exception index", lexer.yyline()); - } - exceptions.get(listIndex).start=offset; - continue; + ParsedSymbol symb; + AVM2Instruction lastIns = null; + do { + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_START) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); } - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_END){ - int exIndex=(Integer)symb.value; - int listIndex=exceptionIndices.indexOf(exIndex); - if(listIndex==-1){ - throw new ParseException("Undefinex exception index", lexer.yyline()); - } - exceptions.get(listIndex).end=offset; - continue; + exceptions.get(listIndex).start = offset; + continue; + } + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_END) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); } - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_TARGET){ - int exIndex=(Integer)symb.value; - int listIndex=exceptionIndices.indexOf(exIndex); - if(listIndex==-1){ - throw new ParseException("Undefinex exception index", lexer.yyline()); - } - exceptions.get(listIndex).target=offset; - continue; + exceptions.get(listIndex).end = offset; + continue; + } + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_TARGET) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); } - if (symb.type == ParsedSymbol.TYPE_EOF) break; - if (symb.type == ParsedSymbol.TYPE_COMMENT) { - if (lastIns != null) { - lastIns.comment = (String) symb.value; - } - continue; + exceptions.get(listIndex).target = offset; + continue; + } + if (symb.type == ParsedSymbol.TYPE_EOF) { + break; + } + if (symb.type == ParsedSymbol.TYPE_COMMENT) { + if (lastIns != null) { + lastIns.comment = (String) symb.value; } - if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) { - if(((String)symb.value).toLowerCase().equals("exception")){ - ParsedSymbol exIndex = lexer.yylex(); - if (exIndex.type != ParsedSymbol.TYPE_INTEGER) { - throw new ParseException("Index expected", lexer.yyline()); - } - ParsedSymbol exName = lexer.yylex(); - if (exName.type != ParsedSymbol.TYPE_MULTINAME) { - throw new ParseException("Multiname expected", lexer.yyline()); - } - ParsedSymbol exType = lexer.yylex(); - if (exType.type != ParsedSymbol.TYPE_MULTINAME) { - throw new ParseException("Multiname expected", lexer.yyline()); - } - ABCException ex=new ABCException(); - ex.name_index=(int) (long) (Long)exName.value; - ex.type_index=(int) (long) (Long)exType.value; - exceptions.add(ex); - exceptionIndices.add((int)(long)(Long)exIndex.value); - continue; - } - boolean insFound = false; - for (InstructionDefinition def : AVM2Code.instructionSet) { - if (def.instructionName.equals((String) symb.value)) { - insFound = true; - List operandsList = new ArrayList(); - - for (int i = 0; i < def.operands.length; i++) { - ParsedSymbol parsedOperand = lexer.yylex(); - switch (def.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_MULTINAME) { - operandsList.add((int) (long) (Long) parsedOperand.value); - } else { - throw new ParseException("Multiname expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_STRING_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_STRING) { - int sid = constants.getStringId((String) parsedOperand.value); - if (sid == 0) { - if ((missingHandler != null) && (missingHandler.missingString((String) parsedOperand.value))) { - sid = constants.addString((String) parsedOperand.value); - } else { - throw new ParseException("Unknown String", lexer.yyline()); - } - } - operandsList.add(sid); - } else { - throw new ParseException("String expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_INT_INDEX: - - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - long intVal = (Long) parsedOperand.value; - int iid = constants.getIntId(intVal); - if (iid == 0) { - if ((missingHandler != null) && (missingHandler.missingInt(intVal))) { - iid = constants.addInt(intVal); - } else { - throw new ParseException("Unknown int", lexer.yyline()); - } - } - operandsList.add(iid); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_UINT_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - long intVal = (Long) parsedOperand.value; - int iid = constants.getUIntId(intVal); - if (iid == 0) { - if ((missingHandler != null) && (missingHandler.missingUInt(intVal))) { - iid = constants.addUInt(intVal); - } else { - throw new ParseException("Unknown uint", lexer.yyline()); - } - } - operandsList.add(iid); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_DOUBLE_INDEX: - if ((parsedOperand.type == ParsedSymbol.TYPE_INTEGER) || (parsedOperand.type == ParsedSymbol.TYPE_FLOAT)) { - - double doubleVal = 0; - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) - doubleVal = (Long) parsedOperand.value; - if (parsedOperand.type == ParsedSymbol.TYPE_FLOAT) - doubleVal = (Double) parsedOperand.value; - int did = constants.getDoubleId(doubleVal); - if (did == 0) { - if ((missingHandler != null) && (missingHandler.missingDouble(doubleVal))) { - did = constants.addDouble(doubleVal); - } else { - throw new ParseException("Unknown double", lexer.yyline()); - } - } - operandsList.add(did); - } else { - throw new ParseException("Float value expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_OFFSET: - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new OffsetItem((String) parsedOperand.value, code.code.size(), i)); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i)); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - break; - case AVM2Code.OPT_CASE_OFFSETS: - - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - int patCount = (int) (long) (Long) parsedOperand.value; - operandsList.add(patCount); - - for (int c = 0; c <= patCount; c++) { - parsedOperand = lexer.yylex(); - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1))); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - } - } else { - throw new ParseException("Case count expected", lexer.yyline()); - } - break; - default: - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - operandsList.add((int) (long) (Long) parsedOperand.value); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - } - } - - int operands[] = new int[operandsList.size()]; - for (int i = 0; i < operandsList.size(); i++) { - operands[i] = operandsList.get(i); - } - lastIns = new AVM2Instruction(offset, def, operands, new byte[0]); - code.code.add(lastIns); - offset += lastIns.getBytes().length; - break; - } - } - if (!insFound) { - throw new ParseException("Invalid instruction name:" + (String) symb.value, lexer.yyline()); - } - } else if (symb.type == ParsedSymbol.TYPE_LABEL) { - labelItems.add(new LabelItem((String) symb.value, offset)); - - } else { - throw new ParseException("Unexpected symbol", lexer.yyline()); + continue; + } + if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) { + if (((String) symb.value).toLowerCase().equals("exception")) { + ParsedSymbol exIndex = lexer.yylex(); + if (exIndex.type != ParsedSymbol.TYPE_INTEGER) { + throw new ParseException("Index expected", lexer.yyline()); + } + ParsedSymbol exName = lexer.yylex(); + if (exName.type != ParsedSymbol.TYPE_MULTINAME) { + throw new ParseException("Multiname expected", lexer.yyline()); + } + ParsedSymbol exType = lexer.yylex(); + if (exType.type != ParsedSymbol.TYPE_MULTINAME) { + throw new ParseException("Multiname expected", lexer.yyline()); + } + ABCException ex = new ABCException(); + ex.name_index = (int) (long) (Long) exName.value; + ex.type_index = (int) (long) (Long) exType.value; + exceptions.add(ex); + exceptionIndices.add((int) (long) (Long) exIndex.value); + continue; } - } while (symb.type != ParsedSymbol.TYPE_EOF); + boolean insFound = false; + for (InstructionDefinition def : AVM2Code.instructionSet) { + if (def.instructionName.equals((String) symb.value)) { + insFound = true; + List operandsList = new ArrayList(); - code.compact(); + for (int i = 0; i < def.operands.length; i++) { + ParsedSymbol parsedOperand = lexer.yylex(); + switch (def.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_MULTINAME) { + operandsList.add((int) (long) (Long) parsedOperand.value); + } else { + throw new ParseException("Multiname expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_STRING_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_STRING) { + int sid = constants.getStringId((String) parsedOperand.value); + if (sid == 0) { + if ((missingHandler != null) && (missingHandler.missingString((String) parsedOperand.value))) { + sid = constants.addString((String) parsedOperand.value); + } else { + throw new ParseException("Unknown String", lexer.yyline()); + } + } + operandsList.add(sid); + } else { + throw new ParseException("String expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_INT_INDEX: - for (OffsetItem oi : offsetItems) { - for (LabelItem li : labelItems) { - if (oi.label.equals(li.label)) { - AVM2Instruction ins = code.code.get((int) oi.insPosition); - int relOffset = 0; - if (oi instanceof CaseOffsetItem) { - relOffset = li.offset - (int) ins.offset; - } else { - relOffset = li.offset - ((int) ins.offset + ins.getBytes().length); - } - ins.operands[oi.insOperandIndex] = relOffset; - } + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + long intVal = (Long) parsedOperand.value; + int iid = constants.getIntId(intVal); + if (iid == 0) { + if ((missingHandler != null) && (missingHandler.missingInt(intVal))) { + iid = constants.addInt(intVal); + } else { + throw new ParseException("Unknown int", lexer.yyline()); + } + } + operandsList.add(iid); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_UINT_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + long intVal = (Long) parsedOperand.value; + int iid = constants.getUIntId(intVal); + if (iid == 0) { + if ((missingHandler != null) && (missingHandler.missingUInt(intVal))) { + iid = constants.addUInt(intVal); + } else { + throw new ParseException("Unknown uint", lexer.yyline()); + } + } + operandsList.add(iid); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_DOUBLE_INDEX: + if ((parsedOperand.type == ParsedSymbol.TYPE_INTEGER) || (parsedOperand.type == ParsedSymbol.TYPE_FLOAT)) { + + double doubleVal = 0; + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + doubleVal = (Long) parsedOperand.value; + } + if (parsedOperand.type == ParsedSymbol.TYPE_FLOAT) { + doubleVal = (Double) parsedOperand.value; + } + int did = constants.getDoubleId(doubleVal); + if (did == 0) { + if ((missingHandler != null) && (missingHandler.missingDouble(doubleVal))) { + did = constants.addDouble(doubleVal); + } else { + throw new ParseException("Unknown double", lexer.yyline()); + } + } + operandsList.add(did); + } else { + throw new ParseException("Float value expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_OFFSET: + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new OffsetItem((String) parsedOperand.value, code.code.size(), i)); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i)); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + break; + case AVM2Code.OPT_CASE_OFFSETS: + + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + int patCount = (int) (long) (Long) parsedOperand.value; + operandsList.add(patCount); + + for (int c = 0; c <= patCount; c++) { + parsedOperand = lexer.yylex(); + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1))); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + } + } else { + throw new ParseException("Case count expected", lexer.yyline()); + } + break; + default: + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + operandsList.add((int) (long) (Long) parsedOperand.value); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + } + } + + int operands[] = new int[operandsList.size()]; + for (int i = 0; i < operandsList.size(); i++) { + operands[i] = operandsList.get(i); + } + lastIns = new AVM2Instruction(offset, def, operands, new byte[0]); + code.code.add(lastIns); + offset += lastIns.getBytes().length; + break; + } } - } - body.exceptions=new ABCException[exceptions.size()]; - for(int e=0;e. */ - package com.jpexs.asdec.abc.avm2.parser; - /** - * This class is a scanner generated by - * JFlex 1.4.3 - * on 19.9.10 10:36 from the specification file + * This class is a scanner generated by JFlex + * 1.4.3 on 19.9.10 10:36 from the specification file * D:/Dokumenty/Programovani/JavaSE/ASDec/trunk/src/com/jpexs/asdec/abc/avm2/parser/flasm3.flex */ public final class Flasm3Lexer { - /** This character denotes the end of file */ - public static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 16384; - - /** lexical states */ - public static final int STRING = 2; - public static final int YYINITIAL = 0; - public static final int PARAMETERS = 4; - - /** - * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l - * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l - * at the beginning of a line - * l is of the form l = 2*k, k a non negative integer - */ - private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1, 2, 2 - }; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\12\1\4\1\2\1\0\1\4\1\1\16\12\4\0\1\40\1\0"+ - "\1\43\1\0\1\11\2\0\1\46\3\0\1\23\1\0\1\17\1\20"+ - "\1\0\1\16\3\47\4\24\2\7\1\15\1\3\5\0\4\11\1\21"+ - "\25\11\1\6\1\25\1\10\1\0\1\14\1\0\1\36\1\44\1\27"+ - "\1\41\1\22\1\45\1\42\1\13\1\32\3\13\1\5\1\34\1\33"+ - "\1\30\1\13\1\37\1\35\1\31\3\13\1\26\2\13\4\0\41\12"+ - "\2\0\4\11\4\0\1\11\2\0\1\12\7\0\1\11\4\0\1\11"+ - "\5\0\27\11\1\0\37\11\1\0\u013f\11\31\0\162\11\4\0\14\11"+ - "\16\0\5\11\11\0\1\11\21\0\130\12\5\0\23\12\12\0\1\11"+ - "\13\0\1\11\1\0\3\11\1\0\1\11\1\0\24\11\1\0\54\11"+ - "\1\0\46\11\1\0\5\11\4\0\202\11\1\0\4\12\3\0\105\11"+ - "\1\0\46\11\2\0\2\11\6\0\20\11\41\0\46\11\2\0\1\11"+ - "\7\0\47\11\11\0\21\12\1\0\27\12\1\0\3\12\1\0\1\12"+ - "\1\0\2\12\1\0\1\12\13\0\33\11\5\0\3\11\15\0\4\12"+ - "\14\0\6\12\13\0\32\11\5\0\13\11\16\12\7\0\12\12\4\0"+ - "\2\11\1\12\143\11\1\0\1\11\10\12\1\0\6\12\2\11\2\12"+ - "\1\0\4\12\2\11\12\12\3\11\2\0\1\11\17\0\1\12\1\11"+ - "\1\12\36\11\33\12\2\0\3\11\60\0\46\11\13\12\1\11\u014f\0"+ - "\3\12\66\11\2\0\1\12\1\11\20\12\2\0\1\11\4\12\3\0"+ - "\12\11\2\12\2\0\12\12\21\0\3\12\1\0\10\11\2\0\2\11"+ - "\2\0\26\11\1\0\7\11\1\0\1\11\3\0\4\11\2\0\1\12"+ - "\1\11\7\12\2\0\2\12\2\0\3\12\11\0\1\12\4\0\2\11"+ - "\1\0\3\11\2\12\2\0\12\12\4\11\15\0\3\12\1\0\6\11"+ - "\4\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11\1\0\2\11"+ - "\1\0\2\11\2\0\1\12\1\0\5\12\4\0\2\12\2\0\3\12"+ - "\13\0\4\11\1\0\1\11\7\0\14\12\3\11\14\0\3\12\1\0"+ - "\11\11\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11\1\0"+ - "\5\11\2\0\1\12\1\11\10\12\1\0\3\12\1\0\3\12\2\0"+ - "\1\11\17\0\2\11\2\12\2\0\12\12\1\0\1\11\17\0\3\12"+ - "\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11"+ - "\1\0\5\11\2\0\1\12\1\11\6\12\3\0\2\12\2\0\3\12"+ - "\10\0\2\12\4\0\2\11\1\0\3\11\4\0\12\12\1\0\1\11"+ - "\20\0\1\12\1\11\1\0\6\11\3\0\3\11\1\0\4\11\3\0"+ - "\2\11\1\0\1\11\1\0\2\11\3\0\2\11\3\0\3\11\3\0"+ - "\10\11\1\0\3\11\4\0\5\12\3\0\3\12\1\0\4\12\11\0"+ - "\1\12\17\0\11\12\11\0\1\11\7\0\3\12\1\0\10\11\1\0"+ - "\3\11\1\0\27\11\1\0\12\11\1\0\5\11\4\0\7\12\1\0"+ - "\3\12\1\0\4\12\7\0\2\12\11\0\2\11\4\0\12\12\22\0"+ - "\2\12\1\0\10\11\1\0\3\11\1\0\27\11\1\0\12\11\1\0"+ - "\5\11\2\0\1\12\1\11\7\12\1\0\3\12\1\0\4\12\7\0"+ - "\2\12\7\0\1\11\1\0\2\11\4\0\12\12\22\0\2\12\1\0"+ - "\10\11\1\0\3\11\1\0\27\11\1\0\20\11\4\0\6\12\2\0"+ - "\3\12\1\0\4\12\11\0\1\12\10\0\2\11\4\0\12\12\22\0"+ - "\2\12\1\0\22\11\3\0\30\11\1\0\11\11\1\0\1\11\2\0"+ - "\7\11\3\0\1\12\4\0\6\12\1\0\1\12\1\0\10\12\22\0"+ - "\2\12\15\0\60\11\1\12\2\11\7\12\4\0\10\11\10\12\1\0"+ - "\12\12\47\0\2\11\1\0\1\11\2\0\2\11\1\0\1\11\2\0"+ - "\1\11\6\0\4\11\1\0\7\11\1\0\3\11\1\0\1\11\1\0"+ - "\1\11\2\0\2\11\1\0\4\11\1\12\2\11\6\12\1\0\2\12"+ - "\1\11\2\0\5\11\1\0\1\11\1\0\6\12\2\0\12\12\2\0"+ - "\2\11\42\0\1\11\27\0\2\12\6\0\12\12\13\0\1\12\1\0"+ - "\1\12\1\0\1\12\4\0\2\12\10\11\1\0\42\11\6\0\24\12"+ - "\1\0\2\12\4\11\4\0\10\12\1\0\44\12\11\0\1\12\71\0"+ - "\42\11\1\0\5\11\1\0\2\11\1\0\7\12\3\0\4\12\6\0"+ - "\12\12\6\0\6\11\4\12\106\0\46\11\12\0\51\11\7\0\132\11"+ - "\5\0\104\11\5\0\122\11\6\0\7\11\1\0\77\11\1\0\1\11"+ - "\1\0\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\47\11"+ - "\1\0\1\11\1\0\4\11\2\0\37\11\1\0\1\11\1\0\4\11"+ - "\2\0\7\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0\7\11"+ - "\1\0\27\11\1\0\37\11\1\0\1\11\1\0\4\11\2\0\7\11"+ - "\1\0\47\11\1\0\23\11\16\0\11\12\56\0\125\11\14\0\u026c\11"+ - "\2\0\10\11\12\0\32\11\5\0\113\11\3\0\3\11\17\0\15\11"+ - "\1\0\4\11\3\12\13\0\22\11\3\12\13\0\22\11\2\12\14\0"+ - "\15\11\1\0\3\11\1\0\2\12\14\0\64\11\40\12\3\0\1\11"+ - "\3\0\2\11\1\12\2\0\12\12\41\0\3\12\2\0\12\12\6\0"+ - "\130\11\10\0\51\11\1\12\126\0\35\11\3\0\14\12\4\0\14\12"+ - "\12\0\12\12\36\11\2\0\5\11\u038b\0\154\11\224\0\234\11\4\0"+ - "\132\11\6\0\26\11\2\0\6\11\2\0\46\11\2\0\6\11\2\0"+ - "\10\11\1\0\1\11\1\0\1\11\1\0\1\11\1\0\37\11\2\0"+ - "\65\11\1\0\7\11\1\0\1\11\3\0\3\11\1\0\7\11\3\0"+ - "\4\11\2\0\6\11\4\0\15\11\5\0\3\11\1\0\7\11\17\0"+ - "\4\12\32\0\5\12\20\0\2\11\23\0\1\11\13\0\4\12\6\0"+ - "\6\12\1\0\1\11\15\0\1\11\40\0\22\11\36\0\15\12\4\0"+ - "\1\12\3\0\6\12\27\0\1\11\4\0\1\11\2\0\12\11\1\0"+ - "\1\11\3\0\5\11\6\0\1\11\1\0\1\11\1\0\1\11\1\0"+ - "\4\11\1\0\3\11\1\0\7\11\3\0\3\11\5\0\5\11\26\0"+ - "\44\11\u0e81\0\3\11\31\0\11\11\6\12\1\0\5\11\2\0\5\11"+ - "\4\0\126\11\2\0\2\12\2\0\3\11\1\0\137\11\5\0\50\11"+ - "\4\0\136\11\21\0\30\11\70\0\20\11\u0200\0\u19b6\11\112\0\u51a6\11"+ - "\132\0\u048d\11\u0773\0\u2ba4\11\u215c\0\u012e\11\2\0\73\11\225\0\7\11"+ - "\14\0\5\11\5\0\1\11\1\12\12\11\1\0\15\11\1\0\5\11"+ - "\1\0\1\11\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11"+ - "\22\0\100\11\2\0\66\11\50\0\15\11\3\0\20\12\20\0\4\12"+ - "\17\0\2\11\30\0\3\11\31\0\1\11\6\0\5\11\1\0\207\11"+ - "\2\0\1\12\4\0\1\11\13\0\12\12\7\0\32\11\4\0\1\11"+ - "\1\0\32\11\12\0\132\11\3\0\6\11\2\0\6\11\2\0\6\11"+ - "\2\0\3\11\3\0\2\11\3\0\2\11\22\0\3\12\4\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\3\0\2\1\1\2\1\1\1\2\1\3\2\4\1\1"+ - "\1\5\2\6\1\7\1\10\1\11\1\10\1\11\2\1"+ - "\1\12\1\0\1\13\1\2\1\14\2\15\1\16\1\17"+ - "\1\20\1\21\1\22\1\23\1\24\1\25\1\0\1\26"+ - "\1\0\1\26\1\0\1\2\1\15\1\0\1\26\1\0"+ - "\1\2\1\0\1\2\1\27\15\2\1\0\2\2\2\0"+ - "\2\2\1\30\1\2\6\0\1\31\1\32"; - - private static int [] zzUnpackAction() { - int [] result = new int[81]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118"+ - "\0\u0140\0\u0168\0\170\0\u0190\0\170\0\u01b8\0\170\0\u01e0"+ - "\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\170\0\360"+ - "\0\170\0\u02f8\0\170\0\u0320\0\u0348\0\170\0\170\0\170"+ - "\0\170\0\170\0\170\0\170\0\170\0\u0370\0\u0398\0\u03c0"+ - "\0\u0280\0\u02d0\0\u03e8\0\170\0\u0410\0\u0438\0\u0438\0\u0460"+ - "\0\u0488\0\u04b0\0\170\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578"+ - "\0\u05a0\0\u05c8\0\u05f0\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8"+ - "\0\u06e0\0\u0708\0\u0730\0\u0758\0\u0780\0\u07a8\0\u07d0\0\170"+ - "\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898\0\u08c0\0\u08e8\0\170"+ - "\0\170"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[81]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); - } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); - - private static final String ZZ_TRANS_PACKED_0 = - "\4\4\1\5\1\6\3\4\1\7\1\4\1\6\1\7"+ - "\4\4\1\7\1\10\3\4\12\6\1\5\2\6\1\4"+ - "\2\6\2\4\1\11\1\12\1\13\22\11\1\14\15\11"+ - "\1\15\4\11\1\4\1\16\1\17\1\20\1\4\1\21"+ - "\1\4\1\22\1\4\1\23\1\4\2\23\1\4\1\24"+ - "\1\25\1\26\2\23\1\4\1\22\1\4\12\23\1\4"+ - "\2\23\1\27\2\23\1\4\1\22\54\0\1\5\33\0"+ - "\1\5\14\0\1\6\1\0\1\6\1\0\2\30\2\6"+ - "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0"+ - "\12\6\1\0\2\6\1\0\2\6\1\0\1\6\5\0"+ - "\1\30\1\0\1\30\1\0\4\30\1\31\1\30\2\0"+ - "\2\30\1\0\1\30\1\0\12\30\1\0\2\30\1\0"+ - "\2\30\1\0\1\30\5\0\1\6\1\0\1\6\1\0"+ - "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0"+ - "\1\6\1\0\1\32\11\6\1\0\2\6\1\0\2\6"+ - "\1\0\1\6\1\11\2\0\22\11\1\0\15\11\1\0"+ - "\4\11\2\0\1\13\45\0\2\33\1\0\13\33\1\34"+ - "\5\33\1\35\1\36\3\33\1\37\2\33\1\40\2\33"+ - "\1\41\3\33\1\42\1\43\1\44\1\45\1\34\2\0"+ - "\1\17\45\0\1\20\2\0\45\20\5\0\1\23\1\46"+ - "\1\23\1\0\4\23\1\0\1\23\2\0\2\23\1\0"+ - "\1\23\1\0\12\23\1\0\2\23\1\0\2\23\1\0"+ - "\1\23\7\0\1\22\6\0\1\22\1\0\1\47\2\50"+ - "\1\0\1\22\22\0\1\22\5\0\1\23\1\0\1\23"+ - "\1\0\4\23\1\0\1\23\2\0\2\23\1\0\1\23"+ - "\1\0\12\23\1\0\2\23\1\0\2\23\1\0\1\23"+ - "\7\0\1\51\6\0\1\51\1\0\1\47\2\50\1\0"+ - "\1\51\22\0\1\51\7\0\1\22\6\0\1\51\1\0"+ - "\1\52\3\0\1\22\22\0\1\22\7\0\1\47\6\0"+ - "\1\47\5\0\1\47\22\0\1\47\5\0\1\6\1\0"+ - "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30"+ - "\1\6\1\0\1\6\1\0\1\6\1\53\10\6\1\0"+ - "\2\6\1\0\2\6\1\0\1\6\16\0\1\35\5\0"+ - "\1\35\22\0\1\35\16\0\1\54\5\0\1\54\22\0"+ - "\1\54\7\0\1\55\6\0\1\55\5\0\1\55\22\0"+ - "\1\55\7\0\1\47\6\0\1\47\2\0\2\50\1\0"+ - "\1\47\22\0\1\47\7\0\1\56\6\0\1\56\1\57"+ - "\3\0\1\57\1\56\22\0\1\56\5\0\1\6\1\0"+ - "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30"+ - "\1\60\1\0\1\6\1\0\12\6\1\0\2\6\1\0"+ - "\2\6\1\0\1\6\7\0\1\55\1\61\5\0\1\55"+ - "\5\0\1\55\22\0\1\55\7\0\1\56\6\0\1\56"+ - "\5\0\1\56\22\0\1\56\5\0\1\6\1\0\1\6"+ - "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6"+ - "\1\0\1\6\1\0\2\6\1\62\7\6\1\0\2\6"+ - "\1\0\2\6\1\0\1\6\43\0\1\63\11\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\3\6\1\64\6\6"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\4\6\1\65\5\6"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\5\6\1\66\4\6"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\6\6\1\67\3\6"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\70\1\0\1\6\1\0\3\6\1\71\3\6"+ - "\1\72\2\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31"+ - "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\6\6"+ - "\1\73\3\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31"+ - "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\10\6"+ - "\1\74\1\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31"+ - "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6"+ - "\1\75\6\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31"+ - "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\12\6"+ - "\1\0\1\76\1\6\1\0\2\6\1\0\1\6\5\0"+ - "\1\6\1\0\1\6\1\0\2\30\2\6\1\31\1\6"+ - "\2\0\1\30\1\6\1\0\1\6\1\0\11\6\1\77"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\10\6\1\100\1\6"+ - "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6"+ - "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0"+ - "\1\30\1\6\1\0\1\6\1\0\12\6\1\101\2\6"+ - "\1\0\2\6\1\0\1\6\5\0\1\6\1\0\1\6"+ - "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6"+ - "\1\0\1\6\1\0\12\6\1\0\1\6\1\102\1\0"+ - "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0"+ - "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0"+ - "\1\6\1\0\11\6\1\103\1\0\2\6\1\0\2\6"+ - "\1\0\1\6\7\0\1\104\6\0\1\105\5\0\1\104"+ - "\22\0\1\104\5\0\1\6\1\0\1\6\1\0\2\30"+ - "\2\6\1\31\1\6\2\0\1\30\1\106\1\0\1\6"+ - "\1\0\12\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31"+ - "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6"+ - "\1\107\6\6\1\0\2\6\1\0\2\6\1\0\1\6"+ - "\7\0\1\104\5\0\1\110\1\104\5\0\1\104\22\0"+ - "\1\104\15\0\1\110\37\0\1\6\1\0\1\6\1\0"+ - "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0"+ - "\1\6\1\0\3\6\1\111\6\6\1\0\2\6\1\0"+ - "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0"+ - "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0"+ - "\1\6\1\0\12\6\1\112\2\6\1\0\2\6\1\0"+ - "\1\6\5\0\1\6\1\0\1\6\1\0\2\30\2\6"+ - "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0"+ - "\12\6\1\113\2\6\1\0\2\6\1\0\1\6\7\0"+ - "\1\114\6\0\1\115\5\0\1\114\22\0\1\114\7\0"+ - "\1\116\6\0\1\117\5\0\1\116\22\0\1\116\7\0"+ - "\1\114\5\0\1\120\1\114\5\0\1\114\22\0\1\114"+ - "\15\0\1\120\41\0\1\116\5\0\1\121\1\116\5\0"+ - "\1\116\22\0\1\116\15\0\1\121\32\0"; - - private static int [] zzUnpackTrans() { - int [] result = new int[2320]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackTrans(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do result[j++] = value; while (--count > 0); - } - return j; - } - - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\3\0\1\11\6\1\1\11\1\1\1\11\1\1\1\11"+ - "\7\1\1\11\1\0\1\11\1\1\1\11\2\1\10\11"+ - "\1\0\1\1\1\0\1\1\1\0\1\1\1\11\1\0"+ - "\1\1\1\0\1\1\1\0\1\1\1\11\15\1\1\0"+ - "\2\1\2\0\2\1\1\11\1\1\6\0\2\11"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[81]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; - - /** denotes if the user-EOF-code has already been executed */ - private boolean zzEOFDone; - - /* user code: */ - - StringBuffer string = new StringBuffer(); - boolean isMultiname=false; - long multinameId=0; - - - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public Flasm3Lexer() { - - } - - public int yychar() { - return yychar; - } - - public int yyline() { - return yyline+1; - } - - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public Flasm3Lexer(java.io.Reader in) { - this.zzReader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public Flasm3Lexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1738) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { - - /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); - - /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzStartRead = 0; - } - - /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); - - if (numRead > 0) { - zzEndRead+= numRead; - return false; - } - // unlikely but not impossible: read 0 characters, but not at end of stream - if (numRead == 0) { - int c = zzReader.read(); - if (c == -1) { - return true; - } else { - zzBuffer[zzEndRead++] = (char) c; - return false; - } - } - - // numRead < 0 - return true; - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) - zzReader.close(); - } - - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEOFDone = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } - - - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - public void yypushback(int number) { - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - - zzMarkedPos -= number; - } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public ParsedSymbol yylex() throws java.io.IOException, ParseException { - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; - - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; - - while (true) { - zzMarkedPosL = zzMarkedPos; - - yychar+= zzMarkedPosL-zzStartRead; - - boolean zzR = false; - for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; - zzCurrentPosL++) { - switch (zzBufferL[zzCurrentPosL]) { - case '\u000B': - case '\u000C': - case '\u0085': - case '\u2028': - case '\u2029': - yyline++; - yycolumn = 0; - zzR = false; - break; - case '\r': - yyline++; - yycolumn = 0; - zzR = true; - break; - case '\n': - if (zzR) - zzR = false; - else { - yyline++; - yycolumn = 0; - } - break; - default: - zzR = false; - yycolumn++; - } + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * lexical states + */ + public static final int STRING = 2; + public static final int YYINITIAL = 0; + public static final int PARAMETERS = 4; + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the + * beginning of a line l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2 + }; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\12\1\4\1\2\1\0\1\4\1\1\16\12\4\0\1\40\1\0" + + "\1\43\1\0\1\11\2\0\1\46\3\0\1\23\1\0\1\17\1\20" + + "\1\0\1\16\3\47\4\24\2\7\1\15\1\3\5\0\4\11\1\21" + + "\25\11\1\6\1\25\1\10\1\0\1\14\1\0\1\36\1\44\1\27" + + "\1\41\1\22\1\45\1\42\1\13\1\32\3\13\1\5\1\34\1\33" + + "\1\30\1\13\1\37\1\35\1\31\3\13\1\26\2\13\4\0\41\12" + + "\2\0\4\11\4\0\1\11\2\0\1\12\7\0\1\11\4\0\1\11" + + "\5\0\27\11\1\0\37\11\1\0\u013f\11\31\0\162\11\4\0\14\11" + + "\16\0\5\11\11\0\1\11\21\0\130\12\5\0\23\12\12\0\1\11" + + "\13\0\1\11\1\0\3\11\1\0\1\11\1\0\24\11\1\0\54\11" + + "\1\0\46\11\1\0\5\11\4\0\202\11\1\0\4\12\3\0\105\11" + + "\1\0\46\11\2\0\2\11\6\0\20\11\41\0\46\11\2\0\1\11" + + "\7\0\47\11\11\0\21\12\1\0\27\12\1\0\3\12\1\0\1\12" + + "\1\0\2\12\1\0\1\12\13\0\33\11\5\0\3\11\15\0\4\12" + + "\14\0\6\12\13\0\32\11\5\0\13\11\16\12\7\0\12\12\4\0" + + "\2\11\1\12\143\11\1\0\1\11\10\12\1\0\6\12\2\11\2\12" + + "\1\0\4\12\2\11\12\12\3\11\2\0\1\11\17\0\1\12\1\11" + + "\1\12\36\11\33\12\2\0\3\11\60\0\46\11\13\12\1\11\u014f\0" + + "\3\12\66\11\2\0\1\12\1\11\20\12\2\0\1\11\4\12\3\0" + + "\12\11\2\12\2\0\12\12\21\0\3\12\1\0\10\11\2\0\2\11" + + "\2\0\26\11\1\0\7\11\1\0\1\11\3\0\4\11\2\0\1\12" + + "\1\11\7\12\2\0\2\12\2\0\3\12\11\0\1\12\4\0\2\11" + + "\1\0\3\11\2\12\2\0\12\12\4\11\15\0\3\12\1\0\6\11" + + "\4\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11\1\0\2\11" + + "\1\0\2\11\2\0\1\12\1\0\5\12\4\0\2\12\2\0\3\12" + + "\13\0\4\11\1\0\1\11\7\0\14\12\3\11\14\0\3\12\1\0" + + "\11\11\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11\1\0" + + "\5\11\2\0\1\12\1\11\10\12\1\0\3\12\1\0\3\12\2\0" + + "\1\11\17\0\2\11\2\12\2\0\12\12\1\0\1\11\17\0\3\12" + + "\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11" + + "\1\0\5\11\2\0\1\12\1\11\6\12\3\0\2\12\2\0\3\12" + + "\10\0\2\12\4\0\2\11\1\0\3\11\4\0\12\12\1\0\1\11" + + "\20\0\1\12\1\11\1\0\6\11\3\0\3\11\1\0\4\11\3\0" + + "\2\11\1\0\1\11\1\0\2\11\3\0\2\11\3\0\3\11\3\0" + + "\10\11\1\0\3\11\4\0\5\12\3\0\3\12\1\0\4\12\11\0" + + "\1\12\17\0\11\12\11\0\1\11\7\0\3\12\1\0\10\11\1\0" + + "\3\11\1\0\27\11\1\0\12\11\1\0\5\11\4\0\7\12\1\0" + + "\3\12\1\0\4\12\7\0\2\12\11\0\2\11\4\0\12\12\22\0" + + "\2\12\1\0\10\11\1\0\3\11\1\0\27\11\1\0\12\11\1\0" + + "\5\11\2\0\1\12\1\11\7\12\1\0\3\12\1\0\4\12\7\0" + + "\2\12\7\0\1\11\1\0\2\11\4\0\12\12\22\0\2\12\1\0" + + "\10\11\1\0\3\11\1\0\27\11\1\0\20\11\4\0\6\12\2\0" + + "\3\12\1\0\4\12\11\0\1\12\10\0\2\11\4\0\12\12\22\0" + + "\2\12\1\0\22\11\3\0\30\11\1\0\11\11\1\0\1\11\2\0" + + "\7\11\3\0\1\12\4\0\6\12\1\0\1\12\1\0\10\12\22\0" + + "\2\12\15\0\60\11\1\12\2\11\7\12\4\0\10\11\10\12\1\0" + + "\12\12\47\0\2\11\1\0\1\11\2\0\2\11\1\0\1\11\2\0" + + "\1\11\6\0\4\11\1\0\7\11\1\0\3\11\1\0\1\11\1\0" + + "\1\11\2\0\2\11\1\0\4\11\1\12\2\11\6\12\1\0\2\12" + + "\1\11\2\0\5\11\1\0\1\11\1\0\6\12\2\0\12\12\2\0" + + "\2\11\42\0\1\11\27\0\2\12\6\0\12\12\13\0\1\12\1\0" + + "\1\12\1\0\1\12\4\0\2\12\10\11\1\0\42\11\6\0\24\12" + + "\1\0\2\12\4\11\4\0\10\12\1\0\44\12\11\0\1\12\71\0" + + "\42\11\1\0\5\11\1\0\2\11\1\0\7\12\3\0\4\12\6\0" + + "\12\12\6\0\6\11\4\12\106\0\46\11\12\0\51\11\7\0\132\11" + + "\5\0\104\11\5\0\122\11\6\0\7\11\1\0\77\11\1\0\1\11" + + "\1\0\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\47\11" + + "\1\0\1\11\1\0\4\11\2\0\37\11\1\0\1\11\1\0\4\11" + + "\2\0\7\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0\7\11" + + "\1\0\27\11\1\0\37\11\1\0\1\11\1\0\4\11\2\0\7\11" + + "\1\0\47\11\1\0\23\11\16\0\11\12\56\0\125\11\14\0\u026c\11" + + "\2\0\10\11\12\0\32\11\5\0\113\11\3\0\3\11\17\0\15\11" + + "\1\0\4\11\3\12\13\0\22\11\3\12\13\0\22\11\2\12\14\0" + + "\15\11\1\0\3\11\1\0\2\12\14\0\64\11\40\12\3\0\1\11" + + "\3\0\2\11\1\12\2\0\12\12\41\0\3\12\2\0\12\12\6\0" + + "\130\11\10\0\51\11\1\12\126\0\35\11\3\0\14\12\4\0\14\12" + + "\12\0\12\12\36\11\2\0\5\11\u038b\0\154\11\224\0\234\11\4\0" + + "\132\11\6\0\26\11\2\0\6\11\2\0\46\11\2\0\6\11\2\0" + + "\10\11\1\0\1\11\1\0\1\11\1\0\1\11\1\0\37\11\2\0" + + "\65\11\1\0\7\11\1\0\1\11\3\0\3\11\1\0\7\11\3\0" + + "\4\11\2\0\6\11\4\0\15\11\5\0\3\11\1\0\7\11\17\0" + + "\4\12\32\0\5\12\20\0\2\11\23\0\1\11\13\0\4\12\6\0" + + "\6\12\1\0\1\11\15\0\1\11\40\0\22\11\36\0\15\12\4\0" + + "\1\12\3\0\6\12\27\0\1\11\4\0\1\11\2\0\12\11\1\0" + + "\1\11\3\0\5\11\6\0\1\11\1\0\1\11\1\0\1\11\1\0" + + "\4\11\1\0\3\11\1\0\7\11\3\0\3\11\5\0\5\11\26\0" + + "\44\11\u0e81\0\3\11\31\0\11\11\6\12\1\0\5\11\2\0\5\11" + + "\4\0\126\11\2\0\2\12\2\0\3\11\1\0\137\11\5\0\50\11" + + "\4\0\136\11\21\0\30\11\70\0\20\11\u0200\0\u19b6\11\112\0\u51a6\11" + + "\132\0\u048d\11\u0773\0\u2ba4\11\u215c\0\u012e\11\2\0\73\11\225\0\7\11" + + "\14\0\5\11\5\0\1\11\1\12\12\11\1\0\15\11\1\0\5\11" + + "\1\0\1\11\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11" + + "\22\0\100\11\2\0\66\11\50\0\15\11\3\0\20\12\20\0\4\12" + + "\17\0\2\11\30\0\3\11\31\0\1\11\6\0\5\11\1\0\207\11" + + "\2\0\1\12\4\0\1\11\13\0\12\12\7\0\32\11\4\0\1\11" + + "\1\0\32\11\12\0\132\11\3\0\6\11\2\0\6\11\2\0\6\11" + + "\2\0\3\11\3\0\2\11\3\0\2\11\22\0\3\12\4\0"; + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ACTION_PACKED_0 = + "\3\0\2\1\1\2\1\1\1\2\1\3\2\4\1\1" + + "\1\5\2\6\1\7\1\10\1\11\1\10\1\11\2\1" + + "\1\12\1\0\1\13\1\2\1\14\2\15\1\16\1\17" + + "\1\20\1\21\1\22\1\23\1\24\1\25\1\0\1\26" + + "\1\0\1\26\1\0\1\2\1\15\1\0\1\26\1\0" + + "\1\2\1\0\1\2\1\27\15\2\1\0\2\2\2\0" + + "\2\2\1\30\1\2\6\0\1\31\1\32"; + + private static int[] zzUnpackAction() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118" + + "\0\u0140\0\u0168\0\170\0\u0190\0\170\0\u01b8\0\170\0\u01e0" + + "\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\170\0\360" + + "\0\170\0\u02f8\0\170\0\u0320\0\u0348\0\170\0\170\0\170" + + "\0\170\0\170\0\170\0\170\0\170\0\u0370\0\u0398\0\u03c0" + + "\0\u0280\0\u02d0\0\u03e8\0\170\0\u0410\0\u0438\0\u0438\0\u0460" + + "\0\u0488\0\u04b0\0\170\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578" + + "\0\u05a0\0\u05c8\0\u05f0\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8" + + "\0\u06e0\0\u0708\0\u0730\0\u0758\0\u0780\0\u07a8\0\u07d0\0\170" + + "\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898\0\u08c0\0\u08e8\0\170" + + "\0\170"; + + private static int[] zzUnpackRowMap() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + private static final String ZZ_TRANS_PACKED_0 = + "\4\4\1\5\1\6\3\4\1\7\1\4\1\6\1\7" + + "\4\4\1\7\1\10\3\4\12\6\1\5\2\6\1\4" + + "\2\6\2\4\1\11\1\12\1\13\22\11\1\14\15\11" + + "\1\15\4\11\1\4\1\16\1\17\1\20\1\4\1\21" + + "\1\4\1\22\1\4\1\23\1\4\2\23\1\4\1\24" + + "\1\25\1\26\2\23\1\4\1\22\1\4\12\23\1\4" + + "\2\23\1\27\2\23\1\4\1\22\54\0\1\5\33\0" + + "\1\5\14\0\1\6\1\0\1\6\1\0\2\30\2\6" + + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" + + "\12\6\1\0\2\6\1\0\2\6\1\0\1\6\5\0" + + "\1\30\1\0\1\30\1\0\4\30\1\31\1\30\2\0" + + "\2\30\1\0\1\30\1\0\12\30\1\0\2\30\1\0" + + "\2\30\1\0\1\30\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\1\32\11\6\1\0\2\6\1\0\2\6" + + "\1\0\1\6\1\11\2\0\22\11\1\0\15\11\1\0" + + "\4\11\2\0\1\13\45\0\2\33\1\0\13\33\1\34" + + "\5\33\1\35\1\36\3\33\1\37\2\33\1\40\2\33" + + "\1\41\3\33\1\42\1\43\1\44\1\45\1\34\2\0" + + "\1\17\45\0\1\20\2\0\45\20\5\0\1\23\1\46" + + "\1\23\1\0\4\23\1\0\1\23\2\0\2\23\1\0" + + "\1\23\1\0\12\23\1\0\2\23\1\0\2\23\1\0" + + "\1\23\7\0\1\22\6\0\1\22\1\0\1\47\2\50" + + "\1\0\1\22\22\0\1\22\5\0\1\23\1\0\1\23" + + "\1\0\4\23\1\0\1\23\2\0\2\23\1\0\1\23" + + "\1\0\12\23\1\0\2\23\1\0\2\23\1\0\1\23" + + "\7\0\1\51\6\0\1\51\1\0\1\47\2\50\1\0" + + "\1\51\22\0\1\51\7\0\1\22\6\0\1\51\1\0" + + "\1\52\3\0\1\22\22\0\1\22\7\0\1\47\6\0" + + "\1\47\5\0\1\47\22\0\1\47\5\0\1\6\1\0" + + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" + + "\1\6\1\0\1\6\1\0\1\6\1\53\10\6\1\0" + + "\2\6\1\0\2\6\1\0\1\6\16\0\1\35\5\0" + + "\1\35\22\0\1\35\16\0\1\54\5\0\1\54\22\0" + + "\1\54\7\0\1\55\6\0\1\55\5\0\1\55\22\0" + + "\1\55\7\0\1\47\6\0\1\47\2\0\2\50\1\0" + + "\1\47\22\0\1\47\7\0\1\56\6\0\1\56\1\57" + + "\3\0\1\57\1\56\22\0\1\56\5\0\1\6\1\0" + + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" + + "\1\60\1\0\1\6\1\0\12\6\1\0\2\6\1\0" + + "\2\6\1\0\1\6\7\0\1\55\1\61\5\0\1\55" + + "\5\0\1\55\22\0\1\55\7\0\1\56\6\0\1\56" + + "\5\0\1\56\22\0\1\56\5\0\1\6\1\0\1\6" + + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" + + "\1\0\1\6\1\0\2\6\1\62\7\6\1\0\2\6" + + "\1\0\2\6\1\0\1\6\43\0\1\63\11\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\3\6\1\64\6\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\4\6\1\65\5\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\5\6\1\66\4\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\6\6\1\67\3\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\70\1\0\1\6\1\0\3\6\1\71\3\6" + + "\1\72\2\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\6\6" + + "\1\73\3\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\10\6" + + "\1\74\1\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" + + "\1\75\6\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\12\6" + + "\1\0\1\76\1\6\1\0\2\6\1\0\1\6\5\0" + + "\1\6\1\0\1\6\1\0\2\30\2\6\1\31\1\6" + + "\2\0\1\30\1\6\1\0\1\6\1\0\11\6\1\77" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\10\6\1\100\1\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\12\6\1\101\2\6" + + "\1\0\2\6\1\0\1\6\5\0\1\6\1\0\1\6" + + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" + + "\1\0\1\6\1\0\12\6\1\0\1\6\1\102\1\0" + + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\11\6\1\103\1\0\2\6\1\0\2\6" + + "\1\0\1\6\7\0\1\104\6\0\1\105\5\0\1\104" + + "\22\0\1\104\5\0\1\6\1\0\1\6\1\0\2\30" + + "\2\6\1\31\1\6\2\0\1\30\1\106\1\0\1\6" + + "\1\0\12\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" + + "\1\107\6\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\7\0\1\104\5\0\1\110\1\104\5\0\1\104\22\0" + + "\1\104\15\0\1\110\37\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\3\6\1\111\6\6\1\0\2\6\1\0" + + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\12\6\1\112\2\6\1\0\2\6\1\0" + + "\1\6\5\0\1\6\1\0\1\6\1\0\2\30\2\6" + + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" + + "\12\6\1\113\2\6\1\0\2\6\1\0\1\6\7\0" + + "\1\114\6\0\1\115\5\0\1\114\22\0\1\114\7\0" + + "\1\116\6\0\1\117\5\0\1\116\22\0\1\116\7\0" + + "\1\114\5\0\1\120\1\114\5\0\1\114\22\0\1\114" + + "\15\0\1\120\41\0\1\116\5\0\1\121\1\116\5\0" + + "\1\116\22\0\1\116\15\0\1\121\32\0"; + + private static int[] zzUnpackTrans() { + int[] result = new int[2320]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state + * aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\3\0\1\11\6\1\1\11\1\1\1\11\1\1\1\11" + + "\7\1\1\11\1\0\1\11\1\1\1\11\2\1\10\11" + + "\1\0\1\1\1\0\1\1\1\0\1\1\1\11\1\0" + + "\1\1\1\0\1\1\1\0\1\1\1\11\15\1\1\0" + + "\2\1\2\0\2\1\1\11\1\1\6\0\2\11"; + + private static int[] zzUnpackAttribute() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is the source of + * the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read from + * input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + /** + * denotes if the user-EOF-code has already been executed + */ + private boolean zzEOFDone; + + /* user code: */ + StringBuffer string = new StringBuffer(); + boolean isMultiname = false; + long multinameId = 0; + + /** + * Create an empty lexer, yyrset will be called later to reset and assign the + * reader + */ + public Flasm3Lexer() { + } + + public int yychar() { + return yychar; + } + + public int yyline() { + return yyline + 1; + } + + /** + * Creates a new scanner There is also a java.io.InputStream version of this + * constructor. + * + * @param in the java.io.Reader to read input from. + */ + public Flasm3Lexer(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. There is also java.io.Reader version of this + * constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public Flasm3Lexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1738) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do { + map[j++] = value; + } while (--count > 0); + } + return map; + } + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); + + /* translate stored positions */ + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzStartRead = 0; } - if (zzR) { - // peek one character ahead if it is \n (if we have counted one line too much) - boolean zzPeek; - if (zzMarkedPosL < zzEndReadL) - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - else if (zzAtEOF) - zzPeek = false; - else { - boolean eof = zzRefill(); - zzEndReadL = zzEndRead; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - if (eof) - zzPeek = false; - else - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } - if (zzPeek) yyline--; + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; } - zzAction = -1; - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = ZZ_LEXSTATE[zzLexicalState]; + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); + if (numRead > 0) { + zzEndRead += numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } - zzForAction: { - while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; + // numRead < 0 + return true; + } + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) { + zzReader.close(); + } + } + + /** + * Resets the scanner to read from a new input stream. Does not close the old + * reader. + * + * All internal variables are reset, the old input stream cannot be + * reused (internal buffer is discarded and lost). Lexical state is set to + * ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); + } + + /** + * Returns the character at position pos from the matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. A value from 0 to + * yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of yypushback(int) and a + * match-all fallback rule) this method will only be called with things that + * "Can't Possibly Happen". If this method is called, something is seriously + * wrong (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done in error fallback + * rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. This number must + * not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) { + zzScanError(ZZ_PUSHBACK_2BIG); + } + + zzMarkedPos -= number; + } + + /** + * Resumes scanning until the next regular expression is matched, the end of + * input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public ParsedSymbol yylex() throws java.io.IOException, ParseException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar += zzMarkedPosL - zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) { + zzR = false; + } else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; } - else { - zzInput = zzBufferL[zzCurrentPosL++]; + } + + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } else if (zzAtEOF) { + zzPeek = false; + } else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) { + zzPeek = false; + } else { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; + if (zzPeek) { + yyline--; + } + } + zzAction = -1; - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - } + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) { + zzInput = zzBufferL[zzCurrentPosL++]; + } else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) { + break zzForAction; + } + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) { + break zzForAction; + } + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 8: { + return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + } + case 27: + break; + case 21: { + string.append('\''); + } + case 28: + break; + case 9: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + } + case 29: + break; + case 26: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_TARGET, Integer.parseInt(s.substring(16, s.length() - 1))); + } + case 30: + break; + case 3: { + string.append(yytext()); + } + case 31: + break; + case 13: { + char val = (char) Integer.parseInt(yytext().substring(1), 8); + string.append(val); + } + case 32: + break; + case 25: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_START, Integer.parseInt(s.substring(15, s.length() - 1))); + } + case 33: + break; + case 5: { + yybegin(PARAMETERS); + // length also includes the trailing quote + if (isMultiname) { + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + } else { + return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); + } + } + case 34: + break; + case 6: { + yybegin(YYINITIAL); + } + case 35: + break; + case 2: { + yybegin(PARAMETERS); + return new ParsedSymbol(ParsedSymbol.TYPE_INSTRUCTION_NAME, yytext()); + } + case 36: + break; + case 17: { + string.append('\r'); + } + case 37: + break; + case 24: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_END, Integer.parseInt(s.substring(13, s.length() - 1))); + } + case 38: + break; + case 7: { + return new ParsedSymbol(ParsedSymbol.TYPE_COMMENT, yytext().substring(1)); + } + case 39: + break; + case 19: { + string.append('\b'); + } + case 40: + break; + case 11: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_LABEL, s.substring(0, s.length() - 1)); + } + case 41: + break; + case 4: { + throw new ParseException("Unterminated string at end of line", yyline + 1); + } + case 42: + break; + case 10: { + isMultiname = false; + yybegin(STRING); + string.setLength(0); + } + case 43: + break; + case 15: { + string.append('\t'); + } + case 44: + break; + case 22: { + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + } + case 45: + break; + case 14: { + string.append('\\'); + } + case 46: + break; + case 12: { + throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); + } + case 47: + break; + case 23: { + isMultiname = true; + String s = yytext(); + multinameId = Long.parseLong(s.substring(2, s.length() - 2)); + yybegin(STRING); + string.setLength(0); + } + case 48: + break; + case 16: { + string.append('\n'); + } + case 49: + break; + case 20: { + string.append('\f'); + } + case 50: + break; + case 18: { + string.append('\"'); + } + case 51: + break; + case 1: { + } + case 52: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return new ParsedSymbol(ParsedSymbol.TYPE_EOF); + } + } else { + zzScanError(ZZ_NO_MATCH); + } + } } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 8: - { return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER,yytext()); - } - case 27: break; - case 21: - { string.append( '\'' ); - } - case 28: break; - case 9: - { return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER,new Long(Long.parseLong((yytext())))); - } - case 29: break; - case 26: - { String s=yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_TARGET,Integer.parseInt(s.substring(16,s.length()-1))); - } - case 30: break; - case 3: - { string.append( yytext() ); - } - case 31: break; - case 13: - { char val = (char) Integer.parseInt(yytext().substring(1),8); - string.append( val ); - } - case 32: break; - case 25: - { String s=yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_START,Integer.parseInt(s.substring(15,s.length()-1))); - } - case 33: break; - case 5: - { yybegin(PARAMETERS); - // length also includes the trailing quote - if(isMultiname){ - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME,new Long(multinameId)); - }else{ - return new ParsedSymbol(ParsedSymbol.TYPE_STRING,string.toString()); - } - } - case 34: break; - case 6: - { yybegin(YYINITIAL); - } - case 35: break; - case 2: - { yybegin(PARAMETERS); - return new ParsedSymbol(ParsedSymbol.TYPE_INSTRUCTION_NAME,yytext()); - } - case 36: break; - case 17: - { string.append( '\r' ); - } - case 37: break; - case 24: - { String s=yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_END,Integer.parseInt(s.substring(13,s.length()-1))); - } - case 38: break; - case 7: - { return new ParsedSymbol(ParsedSymbol.TYPE_COMMENT,yytext().substring(1)); - } - case 39: break; - case 19: - { string.append( '\b' ); - } - case 40: break; - case 11: - { String s=yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_LABEL,s.substring(0,s.length()-1)); - } - case 41: break; - case 4: - { throw new ParseException("Unterminated string at end of line",yyline+1); - } - case 42: break; - case 10: - { isMultiname=false; - yybegin(STRING); - string.setLength(0); - } - case 43: break; - case 15: - { string.append( '\t' ); - } - case 44: break; - case 22: - { return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT,new Double(Double.parseDouble((yytext())))); - } - case 45: break; - case 14: - { string.append( '\\' ); - } - case 46: break; - case 12: - { throw new ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); - } - case 47: break; - case 23: - { isMultiname=true; - String s=yytext(); - multinameId=Long.parseLong(s.substring(2,s.length()-2)); - yybegin(STRING); - string.setLength(0); - } - case 48: break; - case 16: - { string.append( '\n' ); - } - case 49: break; - case 20: - { string.append( '\f' ); - } - case 50: break; - case 18: - { string.append( '\"' ); - } - case 51: break; - case 1: - { - } - case 52: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { - return new ParsedSymbol(ParsedSymbol.TYPE_EOF); - } - } - else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } - - + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/parser/MissingSymbolHandler.java b/trunk/src/com/jpexs/asdec/abc/avm2/parser/MissingSymbolHandler.java index f8f2ef6a6..36468f07b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/parser/MissingSymbolHandler.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/parser/MissingSymbolHandler.java @@ -14,17 +14,15 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.parser; - public interface MissingSymbolHandler { - public boolean missingString(String value); - public boolean missingInt(long value); + public boolean missingString(String value); - public boolean missingUInt(long value); + public boolean missingInt(long value); - public boolean missingDouble(double value); + public boolean missingUInt(long value); + public boolean missingDouble(double value); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParseException.java b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParseException.java index 963de9a7c..5bb220841 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParseException.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParseException.java @@ -14,17 +14,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.parser; - public class ParseException extends Exception { - public long line; - public String text; - public ParseException(String text, long line) { - super("ParseException:" + text + " on line " + line); - this.line = line; - this.text = text; - } + public long line; + public String text; + + public ParseException(String text, long line) { + super("ParseException:" + text + " on line " + line); + this.line = line; + this.text = text; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParsedSymbol.java b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParsedSymbol.java index 5b57a28d0..7f62cb7af 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParsedSymbol.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/parser/ParsedSymbol.java @@ -14,34 +14,31 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.parser; - public class ParsedSymbol { - public int type; - public Object value; - public static final int TYPE_STRING = 1; - public static final int TYPE_MULTINAME = 2; - public static final int TYPE_INSTRUCTION_NAME = 3; - public static final int TYPE_INTEGER = 4; - public static final int TYPE_FLOAT = 5; - public static final int TYPE_IDENTIFIER = 6; - public static final int TYPE_EOF = 7; - public static final int TYPE_LABEL = 8; - public static final int TYPE_COMMENT = 9; - public static final int TYPE_EXCEPTION_START=10; - public static final int TYPE_EXCEPTION_END=11; - public static final int TYPE_EXCEPTION_TARGET=12; + public int type; + public Object value; + public static final int TYPE_STRING = 1; + public static final int TYPE_MULTINAME = 2; + public static final int TYPE_INSTRUCTION_NAME = 3; + public static final int TYPE_INTEGER = 4; + public static final int TYPE_FLOAT = 5; + public static final int TYPE_IDENTIFIER = 6; + public static final int TYPE_EOF = 7; + public static final int TYPE_LABEL = 8; + public static final int TYPE_COMMENT = 9; + public static final int TYPE_EXCEPTION_START = 10; + public static final int TYPE_EXCEPTION_END = 11; + public static final int TYPE_EXCEPTION_TARGET = 12; - public ParsedSymbol(int type, Object value) { - this.type = type; - this.value = value; - } - - public ParsedSymbol(int type) { - this.type = type; - } + public ParsedSymbol(int type, Object value) { + this.type = type; + this.value = value; + } + public ParsedSymbol(int type) { + this.type = type; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ApplyTypeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ApplyTypeTreeItem.java index 0a14389c4..97f25a049 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ApplyTypeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ApplyTypeTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,34 +21,30 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class ApplyTypeTreeItem extends TreeItem { - public TreeItem object; - public List params; - public ApplyTypeTreeItem(AVM2Instruction instruction, TreeItem object, List params) { - super(instruction, PRECEDENCE_PRIMARY); - this.params=params; - this.object=object; - } + public TreeItem object; + public List params; + public ApplyTypeTreeItem(AVM2Instruction instruction, TreeItem object, List params) { + super(instruction, PRECEDENCE_PRIMARY); + this.params = params; + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret=object.toString(constants,localRegNames); - if(!params.isEmpty()) - { - ret+=hilight(".<"); - for(int i=0;i0){ - ret+=hilight(","); - } - ret+=params.get(i).toString(constants,localRegNames); - } - ret+=hilight(">"); - } - return ret; - } - + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = object.toString(constants, localRegNames); + if (!params.isEmpty()) { + ret += hilight(".<"); + for (int i = 0; i < params.size(); i++) { + if (i > 0) { + ret += hilight(","); + } + ret += params.get(i).toString(constants, localRegNames); + } + ret += hilight(">"); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BooleanTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BooleanTreeItem.java index 9f622a313..17bc46119 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BooleanTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BooleanTreeItem.java @@ -14,37 +14,33 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class BooleanTreeItem extends TreeItem { - public Boolean value; + public Boolean value; - public BooleanTreeItem(AVM2Instruction instruction, Boolean value) { - super(instruction, PRECEDENCE_PRIMARY); - this.value = value; - } + public BooleanTreeItem(AVM2Instruction instruction, Boolean value) { + super(instruction, PRECEDENCE_PRIMARY); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return value.toString(); - } - - @Override - public boolean isFalse() { - return value == false; - } - - @Override - public boolean isTrue() { - return value == true; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return value.toString(); + } + @Override + public boolean isFalse() { + return value == false; + } + @Override + public boolean isTrue() { + return value == true; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BreakTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BreakTreeItem.java index 09789b70e..581660796 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BreakTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/BreakTreeItem.java @@ -14,31 +14,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class BreakTreeItem extends TreeItem { - public int loopPos; - public boolean isKnown; - public BreakTreeItem(AVM2Instruction instruction, int loopPos) { - this(instruction, loopPos, true); - } + public int loopPos; + public boolean isKnown; - public BreakTreeItem(AVM2Instruction instruction, int loopPos, boolean isKnown) { - super(instruction, NOPRECEDENCE); - this.loopPos = loopPos; - this.isKnown = isKnown; - } + public BreakTreeItem(AVM2Instruction instruction, int loopPos) { + this(instruction, loopPos, true); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("break") + " loop" + loopPos; - } + public BreakTreeItem(AVM2Instruction instruction, int loopPos, boolean isKnown) { + super(instruction, NOPRECEDENCE); + this.loopPos = loopPos; + this.isKnown = isKnown; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("break") + " loop" + loopPos; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallMethodTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallMethodTreeItem.java index 56ad05ffa..a162c6ea3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallMethodTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallMethodTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,30 +21,28 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class CallMethodTreeItem extends TreeItem { - public TreeItem receiver; - public String methodName; - public List arguments; - public CallMethodTreeItem(AVM2Instruction instruction, TreeItem receiver, String methodName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.methodName = methodName; - this.arguments = arguments; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants,localRegNames); - } - return receiver.toString(constants,localRegNames) + hilight(".") + methodName + hilight("(") + args + hilight(")"); - } + public TreeItem receiver; + public String methodName; + public List arguments; + public CallMethodTreeItem(AVM2Instruction instruction, TreeItem receiver, String methodName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.methodName = methodName; + this.arguments = arguments; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames); + } + return receiver.toString(constants, localRegNames) + hilight(".") + methodName + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallPropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallPropertyTreeItem.java index e440e4ecb..a187ccc95 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallPropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallPropertyTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,32 +21,30 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class CallPropertyTreeItem extends TreeItem { - public TreeItem receiver; - public FullMultinameTreeItem propertyName; - public List arguments; - public boolean isVoid; - public CallPropertyTreeItem(AVM2Instruction instruction, boolean isVoid, TreeItem receiver, FullMultinameTreeItem propertyName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.propertyName = propertyName; - this.arguments = arguments; - this.isVoid = isVoid; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + hilight(","); - } - args = args + arguments.get(a).toString(constants,localRegNames); - } - return formatProperty(constants, receiver, propertyName,localRegNames) + hilight("(") + args + hilight(")"); - } + public TreeItem receiver; + public FullMultinameTreeItem propertyName; + public List arguments; + public boolean isVoid; + public CallPropertyTreeItem(AVM2Instruction instruction, boolean isVoid, TreeItem receiver, FullMultinameTreeItem propertyName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.propertyName = propertyName; + this.arguments = arguments; + this.isVoid = isVoid; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + hilight(","); + } + args = args + arguments.get(a).toString(constants, localRegNames); + } + return formatProperty(constants, receiver, propertyName, localRegNames) + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallStaticTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallStaticTreeItem.java index aca465edf..af08638c0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallStaticTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallStaticTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,30 +21,28 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class CallStaticTreeItem extends TreeItem { - public TreeItem receiver; - public String methodName; - public List arguments; - public CallStaticTreeItem(AVM2Instruction instruction, TreeItem receiver, String methodName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.methodName = methodName; - this.arguments = arguments; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants,localRegNames); - } - return receiver.toString(constants,localRegNames) + hilight(".") + methodName + hilight("(") + args + hilight(")"); - } + public TreeItem receiver; + public String methodName; + public List arguments; + public CallStaticTreeItem(AVM2Instruction instruction, TreeItem receiver, String methodName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.methodName = methodName; + this.arguments = arguments; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames); + } + return receiver.toString(constants, localRegNames) + hilight(".") + methodName + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallSuperTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallSuperTreeItem.java index 5028ec176..54849a095 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallSuperTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallSuperTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -23,34 +22,34 @@ import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; import java.util.List; - public class CallSuperTreeItem extends TreeItem { - public TreeItem receiver; - public FullMultinameTreeItem multiname; - public List arguments; - public boolean isVoid; - public CallSuperTreeItem(AVM2Instruction instruction, boolean isVoid, TreeItem receiver, FullMultinameTreeItem multiname, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.multiname = multiname; - this.arguments = arguments; - this.isVoid = isVoid; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants,localRegNames); - } - String calee = receiver.toString(constants,localRegNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) calee = ""; - return calee + hilight("super.") + multiname.toString(constants,localRegNames) + hilight("(") + args + hilight(")"); - } + public TreeItem receiver; + public FullMultinameTreeItem multiname; + public List arguments; + public boolean isVoid; + public CallSuperTreeItem(AVM2Instruction instruction, boolean isVoid, TreeItem receiver, FullMultinameTreeItem multiname, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.multiname = multiname; + this.arguments = arguments; + this.isVoid = isVoid; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames); + } + String calee = receiver.toString(constants, localRegNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + multiname.toString(constants, localRegNames) + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallTreeItem.java index fbfcefab4..6c725a9f7 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CallTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,39 +21,35 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class CallTreeItem extends TreeItem { - public TreeItem receiver; - public TreeItem function; - public List arguments; - public CallTreeItem(AVM2Instruction instruction, TreeItem receiver, TreeItem function, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.function = function; - this.arguments = arguments; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants,localRegNames); - } - String recPart=receiver.toString(constants,localRegNames) + hilight("."); - if(receiver instanceof NewActivationTreeItem) - { - recPart=""; - } - if(receiver instanceof ThisTreeItem) - { - recPart=""; - } - return recPart+ function.toString(constants,localRegNames) + hilight("(") + args + hilight(")"); - } + public TreeItem receiver; + public TreeItem function; + public List arguments; + public CallTreeItem(AVM2Instruction instruction, TreeItem receiver, TreeItem function, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.function = function; + this.arguments = arguments; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames); + } + String recPart = receiver.toString(constants, localRegNames) + hilight("."); + if (receiver instanceof NewActivationTreeItem) { + recPart = ""; + } + if (receiver instanceof ThisTreeItem) { + recPart = ""; + } + return recPart + function.toString(constants, localRegNames) + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ClassTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ClassTreeItem.java index ea908e09b..547dbbe9a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ClassTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ClassTreeItem.java @@ -14,25 +14,22 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; - import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.ConstantPool; import java.util.HashMap; - public class ClassTreeItem extends TreeItem { - public String className; - public ClassTreeItem(String className) { - super(null, PRECEDENCE_PRIMARY); - this.className = className; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return className; - } + public String className; + public ClassTreeItem(String className) { + super(null, PRECEDENCE_PRIMARY); + this.className = className; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return className; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CoerceTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CoerceTreeItem.java index 52e007ac6..232af7e42 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CoerceTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/CoerceTreeItem.java @@ -14,34 +14,31 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class CoerceTreeItem extends TreeItem { - public TreeItem value; - public String type; - public CoerceTreeItem(AVM2Instruction instruction, TreeItem value, String type) { - super(instruction, NOPRECEDENCE); - this.value = value; - this.type = type; - } + public TreeItem value; + public String type; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - //return hilight("("+type+")")+ - return value.toString(constants,localRegNames); - } + public CoerceTreeItem(AVM2Instruction instruction, TreeItem value, String type) { + super(instruction, NOPRECEDENCE); + this.value = value; + this.type = type; + } + + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + //return hilight("("+type+")")+ + return value.toString(constants, localRegNames); + } @Override public TreeItem getNotCoerced() { return value; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructPropTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructPropTreeItem.java index ce6f8ab2f..a12d87a85 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructPropTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructPropTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,33 +21,33 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class ConstructPropTreeItem extends TreeItem { - public TreeItem object; - public FullMultinameTreeItem propertyName; - public List args; - public ConstructPropTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - this.args = args; - } + public TreeItem object; + public FullMultinameTreeItem propertyName; + public List args; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants,localRegNames); - } - String objstr = object.toString(constants,localRegNames); - if (!objstr.equals("")) objstr += "."; - return hilight("new ") + objstr + propertyName.toString(constants,localRegNames) + hilight("(") + argStr + hilight(")"); - - } + public ConstructPropTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + this.args = args; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames); + } + String objstr = object.toString(constants, localRegNames); + if (!objstr.equals("")) { + objstr += "."; + } + return hilight("new ") + objstr + propertyName.toString(constants, localRegNames) + hilight("(") + argStr + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructSuperTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructSuperTreeItem.java index 54b72a7d9..99a81df9e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructSuperTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructSuperTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -23,31 +22,31 @@ import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; import java.util.List; - public class ConstructSuperTreeItem extends TreeItem { - public TreeItem object; - public List args; - public ConstructSuperTreeItem(AVM2Instruction instruction, TreeItem object, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.args = args; - } + public TreeItem object; + public List args; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants,localRegNames); - } - String calee = object.toString(constants,localRegNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) calee = ""; - return calee + hilight("super(") + argStr + hilight(")"); - - } + public ConstructSuperTreeItem(AVM2Instruction instruction, TreeItem object, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.args = args; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames); + } + String calee = object.toString(constants, localRegNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super(") + argStr + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructTreeItem.java index 711a8a9c9..4ac1f7613 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConstructTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,32 +21,30 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class ConstructTreeItem extends TreeItem { - public TreeItem object; - public List args; - public ConstructTreeItem(AVM2Instruction instruction, TreeItem object, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.args = args; - } + public TreeItem object; + public List args; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants,localRegNames); - } - if (object instanceof NewFunctionTreeItem) { - return object.toString(constants,localRegNames); - } - return hilight("new ") + object.toString(constants,localRegNames) + hilight("(") + argStr + hilight(")"); - - } + public ConstructTreeItem(AVM2Instruction instruction, TreeItem object, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.args = args; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames); + } + if (object instanceof NewFunctionTreeItem) { + return object.toString(constants, localRegNames); + } + return hilight("new ") + object.toString(constants, localRegNames) + hilight("(") + argStr + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ContinueTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ContinueTreeItem.java index fc06d3db8..309ed7916 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ContinueTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ContinueTreeItem.java @@ -14,31 +14,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class ContinueTreeItem extends TreeItem { - public int loopPos; - public boolean isKnown; - public ContinueTreeItem(AVM2Instruction instruction, int loopPos) { - this(instruction, loopPos, true); - } + public int loopPos; + public boolean isKnown; - public ContinueTreeItem(AVM2Instruction instruction, int loopPos, boolean isKnown) { - super(instruction, NOPRECEDENCE); - this.loopPos = loopPos; - this.isKnown = isKnown; - } + public ContinueTreeItem(AVM2Instruction instruction, int loopPos) { + this(instruction, loopPos, true); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("continue") + " " + (isKnown ? "loop" : "unk") + loopPos; - } + public ContinueTreeItem(AVM2Instruction instruction, int loopPos, boolean isKnown) { + super(instruction, NOPRECEDENCE); + this.loopPos = loopPos; + this.isKnown = isKnown; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("continue") + " " + (isKnown ? "loop" : "unk") + loopPos; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConvertTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConvertTreeItem.java index 82563edf6..23efa4fd9 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConvertTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ConvertTreeItem.java @@ -14,28 +14,26 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class ConvertTreeItem extends TreeItem { - public TreeItem value; - public String type; - public ConvertTreeItem(AVM2Instruction instruction, TreeItem value, String type) { - super(instruction, NOPRECEDENCE); - this.value = value; - this.type = type; - } + public TreeItem value; + public String type; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - //return hilight("("+type+")")+ - return value.toString(constants,localRegNames); - } + public ConvertTreeItem(AVM2Instruction instruction, TreeItem value, String type) { + super(instruction, NOPRECEDENCE); + this.value = value; + this.type = type; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + //return hilight("("+type+")")+ + return value.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecLocalTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecLocalTreeItem.java index b8877806b..67d405be1 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecLocalTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecLocalTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class DecLocalTreeItem extends TreeItem { - public int regIndex; - public DecLocalTreeItem(AVM2Instruction instruction, int regIndex) { - super(instruction, PRECEDENCE_POSTFIX); - this.regIndex = regIndex; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return localRegName(localRegNames, regIndex) + hilight("--"); - } + public int regIndex; + public DecLocalTreeItem(AVM2Instruction instruction, int regIndex) { + super(instruction, PRECEDENCE_POSTFIX); + this.regIndex = regIndex; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return localRegName(localRegNames, regIndex) + hilight("--"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecrementTreeItem.java index d58650376..d9e4827d2 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/DecrementTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class DecrementTreeItem extends TreeItem { - public TreeItem object; - public DecrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_ADDITIVE); - this.object = object; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight("-1"); - } + public TreeItem object; + public DecrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_ADDITIVE); + this.object = object; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight("-1"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FindPropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FindPropertyTreeItem.java index d88a8720c..0b5bdc8e8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FindPropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FindPropertyTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class FindPropertyTreeItem extends TreeItem { - public FullMultinameTreeItem propertyName; - public FindPropertyTreeItem(AVM2Instruction instruction, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.propertyName = propertyName; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return ""; - } + public FullMultinameTreeItem propertyName; + public FindPropertyTreeItem(AVM2Instruction instruction, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return ""; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FloatValueTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FloatValueTreeItem.java index 601eb8e88..527afec31 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FloatValueTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FloatValueTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class FloatValueTreeItem extends NumberValueTreeItem { - public Double value; - public FloatValueTreeItem(AVM2Instruction instruction, Double value) { - super(instruction); - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("" + value); - } + public Double value; + public FloatValueTreeItem(AVM2Instruction instruction, Double value) { + super(instruction); + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("" + value); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FullMultinameTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FullMultinameTreeItem.java index f8d71769f..8de4ed25b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FullMultinameTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/FullMultinameTreeItem.java @@ -14,62 +14,59 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class FullMultinameTreeItem extends TreeItem { - public int multinameIndex; - public TreeItem name; - public TreeItem namespace; - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, TreeItem name) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = name; - this.namespace = null; - } + public int multinameIndex; + public TreeItem name; + public TreeItem namespace; - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = null; - this.namespace = null; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, TreeItem name) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = name; + this.namespace = null; + } - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, TreeItem name, TreeItem namespace) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = name; - this.namespace = namespace; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = null; + this.namespace = null; + } - public boolean isRuntime() { - return (name != null) || (namespace != null); - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - if (name != null) { - ret = "["+name.toString(constants,localRegNames)+"]"; - } else { - ret = hilight(constants.constant_multiname[multinameIndex].getName(constants)); - } - if (namespace != null) { - ret=namespace.toString(constants,localRegNames)+"::"+ret; - } else { - /*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); - if ((ns != null)&&(ns.name_index!=0)) { - ret = hilight(ns.getName(constants) + "::")+ret; - }*/ - } - return ret; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, TreeItem name, TreeItem namespace) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = name; + this.namespace = namespace; + } + public boolean isRuntime() { + return (name != null) || (namespace != null); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + if (name != null) { + ret = "[" + name.toString(constants, localRegNames) + "]"; + } else { + ret = hilight(constants.constant_multiname[multinameIndex].getName(constants)); + } + if (namespace != null) { + ret = namespace.toString(constants, localRegNames) + "::" + ret; + } else { + /*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); + if ((ns != null)&&(ns.name_index!=0)) { + ret = hilight(ns.getName(constants) + "::")+ret; + }*/ + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetDescendantsTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetDescendantsTreeItem.java index d8c1fd864..b68c755aa 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetDescendantsTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetDescendantsTreeItem.java @@ -14,28 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class GetDescendantsTreeItem extends TreeItem { - public TreeItem object; - public FullMultinameTreeItem multiname; - public GetDescendantsTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem multiname) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.multiname = multiname; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight("..") + multiname.toString(constants,localRegNames); - } + public TreeItem object; + public FullMultinameTreeItem multiname; + public GetDescendantsTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem multiname) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.multiname = multiname; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight("..") + multiname.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetLexTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetLexTreeItem.java index d21f38135..c22f42f01 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetLexTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetLexTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,19 +21,17 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.types.Multiname; import java.util.HashMap; - public class GetLexTreeItem extends TreeItem { - public Multiname propertyName; - public GetLexTreeItem(AVM2Instruction instruction, Multiname propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.propertyName = propertyName; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight(propertyName.getName(constants)); - } + public Multiname propertyName; + public GetLexTreeItem(AVM2Instruction instruction, Multiname propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight(propertyName.getName(constants)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetPropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetPropertyTreeItem.java index 4c7317699..cf24fa1fa 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetPropertyTreeItem.java @@ -14,28 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class GetPropertyTreeItem extends TreeItem { - public TreeItem object; - public FullMultinameTreeItem propertyName; - public GetPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return formatProperty(constants, object, propertyName,localRegNames); - } + public TreeItem object; + public FullMultinameTreeItem propertyName; + public GetPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return formatProperty(constants, object, propertyName, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSlotTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSlotTreeItem.java index 25cebada0..559825ad3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSlotTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSlotTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,21 +21,20 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.types.Multiname; import java.util.HashMap; - public class GetSlotTreeItem extends TreeItem { - public Multiname slotName; - public TreeItem scope; - public GetSlotTreeItem(AVM2Instruction instruction, TreeItem scope, Multiname slotName) { - super(instruction, PRECEDENCE_PRIMARY); - this.slotName = slotName; - this.scope = scope; - } + public Multiname slotName; + public TreeItem scope; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - //scope.toString(constants)+"." - return hilight(slotName.getName(constants)); - } + public GetSlotTreeItem(AVM2Instruction instruction, TreeItem scope, Multiname slotName) { + super(instruction, PRECEDENCE_PRIMARY); + this.slotName = slotName; + this.scope = scope; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + //scope.toString(constants)+"." + return hilight(slotName.getName(constants)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSuperTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSuperTreeItem.java index 55de31131..a7f0efd32 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSuperTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/GetSuperTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,23 +21,23 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; - public class GetSuperTreeItem extends TreeItem { - public TreeItem object; - public FullMultinameTreeItem propertyName; - public GetSuperTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String calee = object.toString(constants,localRegNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) calee = ""; - return calee + hilight("super.") + propertyName.toString(constants,localRegNames); - } + public TreeItem object; + public FullMultinameTreeItem propertyName; + public GetSuperTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String calee = object.toString(constants, localRegNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + propertyName.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InTreeItem.java index 47025bd4c..a02537d94 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InTreeItem.java @@ -14,28 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class InTreeItem extends TreeItem { - public TreeItem object; - public TreeItem collection; - public InTreeItem(AVM2Instruction instruction, TreeItem object, TreeItem collection) { - super(instruction, NOPRECEDENCE); - this.object = object; - this.collection = collection; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight(" in ") + collection.toString(constants,localRegNames); - } + public TreeItem object; + public TreeItem collection; + public InTreeItem(AVM2Instruction instruction, TreeItem object, TreeItem collection) { + super(instruction, NOPRECEDENCE); + this.object = object; + this.collection = collection; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight(" in ") + collection.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncLocalTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncLocalTreeItem.java index 3161235d1..30cff7c32 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncLocalTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncLocalTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class IncLocalTreeItem extends TreeItem { - public int regIndex; - public IncLocalTreeItem(AVM2Instruction instruction, int regIndex) { - super(instruction, PRECEDENCE_POSTFIX); - this.regIndex = regIndex; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return localRegName(localRegNames, regIndex) + hilight("++"); - } + public int regIndex; + public IncLocalTreeItem(AVM2Instruction instruction, int regIndex) { + super(instruction, PRECEDENCE_POSTFIX); + this.regIndex = regIndex; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return localRegName(localRegNames, regIndex) + hilight("++"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncrementTreeItem.java index eec750192..34ff7732e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IncrementTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class IncrementTreeItem extends TreeItem { - public TreeItem object; - public IncrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_ADDITIVE); - this.object = object; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight("+1"); - } + public TreeItem object; + public IncrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_ADDITIVE); + this.object = object; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight("+1"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InitPropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InitPropertyTreeItem.java index 57eeebbf2..e13ba694f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InitPropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/InitPropertyTreeItem.java @@ -14,30 +14,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; +public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem { -public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem{ - public TreeItem object; - public FullMultinameTreeItem propertyName; - public TreeItem value; + public TreeItem object; + public FullMultinameTreeItem propertyName; + public TreeItem value; - public InitPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, TreeItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.object = object; - this.propertyName = propertyName; - this.value = value; - } + public InitPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, TreeItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.object = object; + this.propertyName = propertyName; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return formatProperty(constants, object, propertyName,localRegNames) + hilight("=") + value.toString(constants,localRegNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return formatProperty(constants, object, propertyName, localRegNames) + hilight("=") + value.toString(constants, localRegNames); + } public TreeItem getObject() { return new GetPropertyTreeItem(instruction, object, propertyName); @@ -46,6 +45,4 @@ public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem{ public TreeItem getValue() { return value; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IntegerValueTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IntegerValueTreeItem.java index 0746139ad..2fff76875 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IntegerValueTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/IntegerValueTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class IntegerValueTreeItem extends NumberValueTreeItem { - public Long value; - public IntegerValueTreeItem(AVM2Instruction instruction, Long value) { - super(instruction); - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("" + value); - } + public Long value; + public IntegerValueTreeItem(AVM2Instruction instruction, Long value) { + super(instruction); + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("" + value); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/LocalRegTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/LocalRegTreeItem.java index 581df3bb3..f82309d8e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/LocalRegTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/LocalRegTreeItem.java @@ -14,41 +14,38 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class LocalRegTreeItem extends TreeItem { - public int regIndex; - public TreeItem computedValue; - public LocalRegTreeItem(AVM2Instruction instruction, int regIndex, TreeItem computedValue) { - super(instruction, PRECEDENCE_PRIMARY); - this.regIndex = regIndex; - if (computedValue == null) { - computedValue = new UndefinedTreeItem(instruction); - } - this.computedValue = computedValue; - } + public int regIndex; + public TreeItem computedValue; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight(localRegName(localRegNames, regIndex)); - } + public LocalRegTreeItem(AVM2Instruction instruction, int regIndex, TreeItem computedValue) { + super(instruction, PRECEDENCE_PRIMARY); + this.regIndex = regIndex; + if (computedValue == null) { + computedValue = new UndefinedTreeItem(instruction); + } + this.computedValue = computedValue; + } - @Override - public boolean isFalse() { - return computedValue.isFalse(); - } - - @Override - public boolean isTrue() { - return computedValue.isTrue(); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight(localRegName(localRegNames, regIndex)); + } + @Override + public boolean isFalse() { + return computedValue.isFalse(); + } + @Override + public boolean isTrue() { + return computedValue.isTrue(); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameSpaceTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameSpaceTreeItem.java index 02077492f..b6d468f29 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameSpaceTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameSpaceTreeItem.java @@ -14,24 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class NameSpaceTreeItem extends TreeItem { - public int namespaceIndex; - public NameSpaceTreeItem(AVM2Instruction instruction, int namespaceIndex) { - super(instruction, NOPRECEDENCE); - this.namespaceIndex = namespaceIndex; - } + public int namespaceIndex; - public String toString(ConstantPool constants, HashMap localRegNames) { - if (namespaceIndex == 0) return "*"; - return hilight(constants.constant_namespace[namespaceIndex].toString(constants)); - } + public NameSpaceTreeItem(AVM2Instruction instruction, int namespaceIndex) { + super(instruction, NOPRECEDENCE); + this.namespaceIndex = namespaceIndex; + } + + public String toString(ConstantPool constants, HashMap localRegNames) { + if (namespaceIndex == 0) { + return "*"; + } + return hilight(constants.constant_namespace[namespaceIndex].toString(constants)); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameValuePair.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameValuePair.java index c8be26894..7e5bd14e3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameValuePair.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NameValuePair.java @@ -14,30 +14,27 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; - import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.ConstantPool; import java.util.HashMap; - public class NameValuePair extends TreeItem { - public TreeItem name; - public TreeItem value; - public NameValuePair(TreeItem name, TreeItem value) { - super(name.instruction, NOPRECEDENCE); - this.name = name; - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - if (name instanceof StringTreeItem) { - return ((StringTreeItem) name).value + ":" + value.toString(constants,localRegNames); - } - return name.toString(constants,localRegNames) + ":" + value.toString(constants,localRegNames); - } + public TreeItem name; + public TreeItem value; + public NameValuePair(TreeItem name, TreeItem value) { + super(name.instruction, NOPRECEDENCE); + this.name = name; + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + if (name instanceof StringTreeItem) { + return ((StringTreeItem) name).value + ":" + value.toString(constants, localRegNames); + } + return name.toString(constants, localRegNames) + ":" + value.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NanTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NanTreeItem.java index 1f5718577..096b7e4a8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NanTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NanTreeItem.java @@ -14,24 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class NanTreeItem extends TreeItem { - public NanTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } - - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("NaN"); - } + public NanTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("NaN"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewActivationTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewActivationTreeItem.java index 6b3c2e4ba..455eca9df 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewActivationTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewActivationTreeItem.java @@ -14,24 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class NewActivationTreeItem extends TreeItem { - public NewActivationTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } - - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("newactivation()"); - } + public NewActivationTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("newactivation()"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewArrayTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewArrayTreeItem.java index 6fc27d968..571967522 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewArrayTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewArrayTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,26 +21,24 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class NewArrayTreeItem extends TreeItem { - public List values; - public NewArrayTreeItem(AVM2Instruction instruction, List values) { - super(instruction, PRECEDENCE_PRIMARY); - this.values = values; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String args = ""; - for (int a = 0; a < values.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + values.get(a).toString(constants,localRegNames); - } - return hilight("[") + args + hilight("]"); - } + public List values; + public NewArrayTreeItem(AVM2Instruction instruction, List values) { + super(instruction, PRECEDENCE_PRIMARY); + this.values = values; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String args = ""; + for (int a = 0; a < values.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + values.get(a).toString(constants, localRegNames); + } + return hilight("[") + args + hilight("]"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewFunctionTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewFunctionTreeItem.java index d8599e893..ed3b3d406 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewFunctionTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewFunctionTreeItem.java @@ -14,30 +14,27 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class NewFunctionTreeItem extends TreeItem { - public String paramStr; - public String returnStr; - public String functionBody; - public NewFunctionTreeItem(AVM2Instruction instruction, String paramStr, String returnStr, String functionBody) { - super(instruction, PRECEDENCE_PRIMARY); - this.paramStr = paramStr; - this.returnStr = returnStr; - this.functionBody = functionBody; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("new function(" + paramStr + "):" + returnStr + "\r\n{\r\n") + functionBody +"\r\n"+ hilight("}"); - } + public String paramStr; + public String returnStr; + public String functionBody; + public NewFunctionTreeItem(AVM2Instruction instruction, String paramStr, String returnStr, String functionBody) { + super(instruction, PRECEDENCE_PRIMARY); + this.paramStr = paramStr; + this.returnStr = returnStr; + this.functionBody = functionBody; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("new function(" + paramStr + "):" + returnStr + "\r\n{\r\n") + functionBody + "\r\n" + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewObjectTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewObjectTreeItem.java index f9481d0df..e5d712597 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewObjectTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NewObjectTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,24 +21,24 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; import java.util.List; - public class NewObjectTreeItem extends TreeItem { - public List pairs; - public NewObjectTreeItem(AVM2Instruction instruction, List pairs) { - super(instruction, PRECEDENCE_PRIMARY); - this.pairs = pairs; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String params = ""; - for (int n = 0; n < pairs.size(); n++) { - if (n > 0) params += ",\r\n"; - params += pairs.get(n).toString(constants,localRegNames); - } - return hilight("{") + params + hilight("}"); - } + public List pairs; + public NewObjectTreeItem(AVM2Instruction instruction, List pairs) { + super(instruction, PRECEDENCE_PRIMARY); + this.pairs = pairs; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String params = ""; + for (int n = 0; n < pairs.size(); n++) { + if (n > 0) { + params += ",\r\n"; + } + params += pairs.get(n).toString(constants, localRegNames); + } + return hilight("{") + params + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NullTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NullTreeItem.java index 186e196e9..de8081f40 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NullTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NullTreeItem.java @@ -14,24 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class NullTreeItem extends TreeItem { - public NullTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } - - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("null"); - } + public NullTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("null"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NumberValueTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NumberValueTreeItem.java index 895bbd1a7..30a20b68f 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NumberValueTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/NumberValueTreeItem.java @@ -14,16 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; - public abstract class NumberValueTreeItem extends TreeItem { - public NumberValueTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } - + public NumberValueTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostDecrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostDecrementTreeItem.java index 71e458e39..9b160cc6a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostDecrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostDecrementTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class PostDecrementTreeItem extends TreeItem { - public TreeItem object; - public PostDecrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_POSTFIX); - this.object = object; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight("--"); - } + public TreeItem object; + public PostDecrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_POSTFIX); + this.object = object; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight("--"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostIncrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostIncrementTreeItem.java index 101f2fca0..a045a23e8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostIncrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/PostIncrementTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class PostIncrementTreeItem extends TreeItem { - public TreeItem object; - public PostIncrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_POSTFIX); - this.object = object; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return object.toString(constants,localRegNames) + hilight("++"); - } + public TreeItem object; + public PostIncrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_POSTFIX); + this.object = object; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return object.toString(constants, localRegNames) + hilight("++"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnValueTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnValueTreeItem.java index 953766f28..6bbb0b425 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnValueTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnValueTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class ReturnValueTreeItem extends TreeItem { - public TreeItem value; - public ReturnValueTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("return ") + value.toString(constants,localRegNames); - } + public TreeItem value; + public ReturnValueTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("return ") + value.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnVoidTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnVoidTreeItem.java index 7ad68b52b..dcdba426c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnVoidTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ReturnVoidTreeItem.java @@ -14,24 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class ReturnVoidTreeItem extends TreeItem { - public ReturnVoidTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("return"); - } - + public ReturnVoidTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("return"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetGlobalSlotTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetGlobalSlotTreeItem.java index 42c0baf7c..c85b07829 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetGlobalSlotTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetGlobalSlotTreeItem.java @@ -14,28 +14,25 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class SetGlobalSlotTreeItem extends TreeItem { - public int slotId; - public TreeItem value; - public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, TreeItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.slotId = slotId; - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("setglobalslot(" + slotId + ",") + value.toString(constants,localRegNames) + hilight(")"); - } + public int slotId; + public TreeItem value; + public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, TreeItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.slotId = slotId; + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("setglobalslot(" + slotId + ",") + value.toString(constants, localRegNames) + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetLocalTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetLocalTreeItem.java index 493395108..ccd328e71 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetLocalTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetLocalTreeItem.java @@ -14,28 +14,27 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem { - public int regIndex; - public TreeItem value; - public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, TreeItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.regIndex = regIndex; - this.value = value; - } + public int regIndex; + public TreeItem value; - @Override - public String toString(ConstantPool constants,HashMap localRegNames) { - return hilight(localRegName(localRegNames,regIndex) + "=") + value.toString(constants,localRegNames); - } + public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, TreeItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.regIndex = regIndex; + this.value = value; + } + + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight(localRegName(localRegNames, regIndex) + "=") + value.toString(constants, localRegNames); + } public TreeItem getObject() { return new LocalRegTreeItem(instruction, regIndex, null); @@ -44,6 +43,4 @@ public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem { public TreeItem getValue() { return value; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetPropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetPropertyTreeItem.java index 3fcc1aff1..ab6f234a7 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetPropertyTreeItem.java @@ -14,30 +14,29 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; +public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem { -public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem{ - public TreeItem object; - public FullMultinameTreeItem propertyName; - public TreeItem value; + public TreeItem object; + public FullMultinameTreeItem propertyName; + public TreeItem value; - public SetPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, TreeItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.object = object; - this.propertyName = propertyName; - this.value = value; - } + public SetPropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName, TreeItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.object = object; + this.propertyName = propertyName; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return formatProperty(constants, object, propertyName,localRegNames) + hilight("=") + value.toString(constants,localRegNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return formatProperty(constants, object, propertyName, localRegNames) + hilight("=") + value.toString(constants, localRegNames); + } public TreeItem getObject() { return new GetPropertyTreeItem(instruction, object, propertyName); @@ -46,6 +45,4 @@ public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem{ public TreeItem getValue() { return value; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSlotTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSlotTreeItem.java index 060cd7603..3f313b015 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSlotTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSlotTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,35 +21,35 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.types.Multiname; import java.util.HashMap; - public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem { - public Multiname slotName; - public TreeItem value; - public TreeItem scope; - public SetSlotTreeItem(AVM2Instruction instruction, TreeItem scope, Multiname slotName, TreeItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.slotName = slotName; - this.value = value; - this.scope = scope; - } + public Multiname slotName; + public TreeItem value; + public TreeItem scope; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; + public SetSlotTreeItem(AVM2Instruction instruction, TreeItem scope, Multiname slotName, TreeItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.slotName = slotName; + this.value = value; + this.scope = scope; + } - if (!(scope instanceof NewActivationTreeItem)) { - ret = scope.toString(constants,localRegNames) + "."; - } - if(scope instanceof LocalRegTreeItem){ - if(((LocalRegTreeItem)scope).computedValue !=null){ - if(((LocalRegTreeItem)scope).computedValue instanceof NewActivationTreeItem){ - ret=""; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + + if (!(scope instanceof NewActivationTreeItem)) { + ret = scope.toString(constants, localRegNames) + "."; + } + if (scope instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) scope).computedValue != null) { + if (((LocalRegTreeItem) scope).computedValue instanceof NewActivationTreeItem) { + ret = ""; } - } - return ret + hilight(slotName.getName(constants)) + hilight("=") + value.toString(constants,localRegNames); - } + } + } + return ret + hilight(slotName.getName(constants)) + hilight("=") + value.toString(constants, localRegNames); + } public TreeItem getObject() { return new GetSlotTreeItem(instruction, scope, slotName); @@ -59,5 +58,4 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem { public TreeItem getValue() { return value; } - } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSuperTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSuperTreeItem.java index 68dac2935..df0368c68 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSuperTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetSuperTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,26 +21,25 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; - public class SetSuperTreeItem extends TreeItem { - public TreeItem value; - public TreeItem object; - public FullMultinameTreeItem propertyName; - public SetSuperTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.value = value; - this.object = object; - this.propertyName = propertyName; - } - - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String calee = object.toString(constants,localRegNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) calee = ""; - return calee + hilight("super.") + propertyName.toString(constants,localRegNames) + hilight("=") + value.toString(constants,localRegNames); - } + public TreeItem value; + public TreeItem object; + public FullMultinameTreeItem propertyName; + public SetSuperTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.value = value; + this.object = object; + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String calee = object.toString(constants, localRegNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + propertyName.toString(constants, localRegNames) + hilight("=") + value.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetTypeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetTypeTreeItem.java index b6b4a8e0d..cf7c4a849 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetTypeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/SetTypeTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; /** @@ -22,6 +21,8 @@ package com.jpexs.asdec.abc.avm2.treemodel; * @author JPEXS */ public interface SetTypeTreeItem { + public TreeItem getObject(); + public TreeItem getValue(); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/StringTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/StringTreeItem.java index de3987caf..ccc046ff6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/StringTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/StringTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,19 +21,17 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.helpers.Helper; import java.util.HashMap; - public class StringTreeItem extends TreeItem { - public String value; - public StringTreeItem(AVM2Instruction instruction, String value) { - super(instruction, PRECEDENCE_PRIMARY); - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("\"" + Helper.escapeString(value) + "\""); - } + public String value; + public StringTreeItem(AVM2Instruction instruction, String value) { + super(instruction, PRECEDENCE_PRIMARY); + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("\"" + Helper.escapeString(value) + "\""); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThisTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThisTreeItem.java index 6bb7cbf17..b1a222aef 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThisTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThisTreeItem.java @@ -14,23 +14,19 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; - import com.jpexs.asdec.abc.avm2.ConstantPool; +import com.jpexs.asdec.abc.avm2.ConstantPool; import java.util.HashMap; - public class ThisTreeItem extends TreeItem { - public ThisTreeItem() { - super(null, PRECEDENCE_PRIMARY); - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return "this"; - } - + public ThisTreeItem() { + super(null, PRECEDENCE_PRIMARY); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return "this"; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThrowTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThrowTreeItem.java index d0d7653cb..ed7e62a13 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThrowTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/ThrowTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class ThrowTreeItem extends TreeItem { - public TreeItem value; - public ThrowTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } + public TreeItem value; + public ThrowTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("throw ") + value.toString(constants,localRegNames); - } - + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("throw ") + value.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/TreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/TreeItem.java index 4b46b162d..498136ac6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/TreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/TreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,101 +21,98 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; - public abstract class TreeItem { - public static final int PRECEDENCE_PRIMARY = 0; - public static final int PRECEDENCE_POSTFIX = 1; - public static final int PRECEDENCE_UNARY = 2; - public static final int PRECEDENCE_MULTIPLICATIVE = 3; - public static final int PRECEDENCE_ADDITIVE = 4; - public static final int PRECEDENCE_BITWISESHIFT = 5; - public static final int PRECEDENCE_RELATIONAL = 6; - public static final int PRECEDENCE_EQUALITY = 7; - public static final int PRECEDENCE_BITWISEAND = 8; - public static final int PRECEDENCE_BITWISEXOR = 9; - public static final int PRECEDENCE_BITWISEOR = 10; - public static final int PRECEDENCE_LOGICALAND = 11; - public static final int PRECEDENCE_LOGICALOR = 12; - public static final int PRECEDENCE_CONDITIONAL = 13; - public static final int PRECEDENCE_ASSIGMENT = 14; - public static final int PRECEDENCE_COMMA = 15; - public static final int NOPRECEDENCE = 16; - + public static final int PRECEDENCE_PRIMARY = 0; + public static final int PRECEDENCE_POSTFIX = 1; + public static final int PRECEDENCE_UNARY = 2; + public static final int PRECEDENCE_MULTIPLICATIVE = 3; + public static final int PRECEDENCE_ADDITIVE = 4; + public static final int PRECEDENCE_BITWISESHIFT = 5; + public static final int PRECEDENCE_RELATIONAL = 6; + public static final int PRECEDENCE_EQUALITY = 7; + public static final int PRECEDENCE_BITWISEAND = 8; + public static final int PRECEDENCE_BITWISEXOR = 9; + public static final int PRECEDENCE_BITWISEOR = 10; + public static final int PRECEDENCE_LOGICALAND = 11; + public static final int PRECEDENCE_LOGICALOR = 12; + public static final int PRECEDENCE_CONDITIONAL = 13; + public static final int PRECEDENCE_ASSIGMENT = 14; + public static final int PRECEDENCE_COMMA = 15; + public static final int NOPRECEDENCE = 16; + public int precedence = NOPRECEDENCE; + public AVM2Instruction instruction; - public int precedence = NOPRECEDENCE; - public AVM2Instruction instruction; + public TreeItem(AVM2Instruction instruction, int precedence) { + this.instruction = instruction; + this.precedence = precedence; + } - public TreeItem(AVM2Instruction instruction, int precedence) { - this.instruction = instruction; - this.precedence = precedence; - } + public abstract String toString(ConstantPool constants, HashMap localRegNames); + public String toStringSemicoloned(ConstantPool constants, HashMap localRegNames) { + return toString(constants, localRegNames) + (needsSemicolon() ? ";" : ""); + } - public abstract String toString(ConstantPool constants,HashMap localRegNames); - - public String toStringSemicoloned(ConstantPool constants,HashMap localRegNames) - { - return toString(constants,localRegNames)+(needsSemicolon()?";":""); - } + public boolean needsSemicolon() { + return true; + } - public boolean needsSemicolon() - { - return true; - } - - + protected String hilight(String str) { + if (instruction == null) { + return str; + } + return Highlighting.hilighOffset(str, instruction.offset); + } - protected String hilight(String str) { - if (instruction == null) - return str; - return Highlighting.hilighOffset(str, instruction.offset); - } - - public boolean isFalse() { - return false; - } + public boolean isFalse() { + return false; + } - public boolean isTrue() { - return false; - } + public boolean isTrue() { + return false; + } - protected String formatProperty(ConstantPool constants, TreeItem object, TreeItem propertyName,HashMap localRegNames) { - String obStr = object.toString(constants,localRegNames); - if (object.precedence > PRECEDENCE_PRIMARY) { - obStr = "(" + obStr + ")"; - } - if (object instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) object).computedValue instanceof FindPropertyTreeItem) - obStr = ""; - } - if(obStr.equals("")){ - return propertyName.toString(constants,localRegNames); - } - if (propertyName instanceof FullMultinameTreeItem) { + protected String formatProperty(ConstantPool constants, TreeItem object, TreeItem propertyName, HashMap localRegNames) { + String obStr = object.toString(constants, localRegNames); + if (object.precedence > PRECEDENCE_PRIMARY) { + obStr = "(" + obStr + ")"; + } + if (object instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) object).computedValue instanceof FindPropertyTreeItem) { + obStr = ""; + } + } + if (obStr.equals("")) { + return propertyName.toString(constants, localRegNames); + } + if (propertyName instanceof FullMultinameTreeItem) { - if (((FullMultinameTreeItem) propertyName).isRuntime()) { - return obStr + propertyName.toString(constants,localRegNames); - } else { - if (!obStr.equals("")) obStr += "."; - return obStr + ((FullMultinameTreeItem) propertyName).toString(constants,localRegNames); + if (((FullMultinameTreeItem) propertyName).isRuntime()) { + return obStr + propertyName.toString(constants, localRegNames); + } else { + if (!obStr.equals("")) { + obStr += "."; } - } else { - return obStr + "[" + propertyName.toString(constants,localRegNames) + "]"; - } - } - public TreeItem getNotCoerced(){ - return this; - } - - public static String localRegName(HashMap localRegNames,int reg) - { - if(localRegNames.containsKey(reg)) - { - return localRegNames.get(reg); - }else{ - if (reg == 0) return "this"; - return "_loc" + reg + "_"; - } - } + return obStr + ((FullMultinameTreeItem) propertyName).toString(constants, localRegNames); + } + } else { + return obStr + "[" + propertyName.toString(constants, localRegNames) + "]"; + } + } + + public TreeItem getNotCoerced() { + return this; + } + + public static String localRegName(HashMap localRegNames, int reg) { + if (localRegNames.containsKey(reg)) { + return localRegNames.get(reg); + } else { + if (reg == 0) { + return "this"; + } + return "_loc" + reg + "_"; + } + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UndefinedTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UndefinedTreeItem.java index 05914891d..c40fafe0b 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UndefinedTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UndefinedTreeItem.java @@ -14,25 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class UndefinedTreeItem extends TreeItem { - public UndefinedTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } - - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("undefined"); - } - + public UndefinedTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("undefined"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UnparsedTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UnparsedTreeItem.java index 0da873cb9..189f3276a 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UnparsedTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/UnparsedTreeItem.java @@ -14,26 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import java.util.HashMap; - public class UnparsedTreeItem extends TreeItem { - public String value; - public UnparsedTreeItem(AVM2Instruction instruction, String value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight(value); - } + public String value; + public UnparsedTreeItem(AVM2Instruction instruction, String value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight(value); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithTreeItem.java index 44d94b8bb..1ea7c51ba 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/WithTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -23,33 +22,31 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class WithTreeItem extends TreeItem { - public TreeItem scope; - public List items; - public WithTreeItem(AVM2Instruction instruction, TreeItem scope, List items) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = items; - } + public TreeItem scope; + public List items; - public WithTreeItem(AVM2Instruction instruction, TreeItem scope) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = new ArrayList(); - } + public WithTreeItem(AVM2Instruction instruction, TreeItem scope, List items) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = items; + } + public WithTreeItem(AVM2Instruction instruction, TreeItem scope) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = new ArrayList(); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret = hilight("with(") + scope.toString(constants,localRegNames) + hilight(")\r\n{\r\n"); - for (TreeItem ti : items) { - ret += ti.toString(constants,localRegNames) + "\r\n"; - } - ret += hilight("}"); - return ret; - } - + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret = hilight("with(") + scope.toString(constants, localRegNames) + hilight(")\r\n{\r\n"); + for (TreeItem ti : items) { + ret += ti.toString(constants, localRegNames) + "\r\n"; + } + ret += hilight("}"); + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/Block.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/Block.java index a7ccf4fcc..cdc69dea4 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/Block.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/Block.java @@ -14,13 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.treemodel.ContinueTreeItem; import java.util.List; - public interface Block { - public List getContinues(); + + public List getContinues(); } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/DoWhileTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/DoWhileTreeItem.java index 4fc0e6d70..a25e5d022 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/DoWhileTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/DoWhileTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,49 +24,46 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class DoWhileTreeItem extends LoopTreeItem implements Block { - public List commands; - public TreeItem expression; + public List commands; + public TreeItem expression; @Override public boolean needsSemicolon() { return false; } - - - public DoWhileTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, List commands, TreeItem expression) { - super(instruction, loopBreak, loopContinue); - this.expression = expression; - this.commands = commands; - } + public DoWhileTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, List commands, TreeItem expression) { + super(instruction, loopBreak, loopContinue); + this.expression = expression; + this.commands = commands; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("do\r\n{") + "\r\n"; - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}\r\nwhile(") + expression.toString(constants,localRegNames) + hilight(");") + "\r\n"; - ret += ":loop" + loopBreak; + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("do\r\n{") + "\r\n"; + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}\r\nwhile(") + expression.toString(constants, localRegNames) + hilight(");") + "\r\n"; + ret += ":loop" + loopBreak; - return ret; - } + return ret; + } - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ExceptionTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ExceptionTreeItem.java index c17f44c4b..df449339e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ExceptionTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ExceptionTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,19 +21,17 @@ import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import com.jpexs.asdec.abc.types.ABCException; import java.util.HashMap; - public class ExceptionTreeItem extends TreeItem { - public ABCException exception; - public ExceptionTreeItem(ABCException exception) { - super(null, NOPRECEDENCE); - this.exception = exception; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return exception.getVarName(constants); - } + public ABCException exception; + public ExceptionTreeItem(ABCException exception) { + super(null, NOPRECEDENCE); + this.exception = exception; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return exception.getVarName(constants); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForEachInTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForEachInTreeItem.java index ddcd2b740..2e8bd92e3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForEachInTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForEachInTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -24,60 +23,58 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class ForEachInTreeItem extends LoopTreeItem implements Block { - public InTreeItem expression; - public List commands; + public InTreeItem expression; + public List commands; - public ForEachInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List commands) { - super(instruction, loopBreak, loopContinue); - TreeItem firstAssign=commands.get(0); - if(firstAssign instanceof SetTypeTreeItem){ - if(expression.object instanceof LocalRegTreeItem){ - if(((SetTypeTreeItem)firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) - { - if(((LocalRegTreeItem)((SetTypeTreeItem)firstAssign).getValue().getNotCoerced()).regIndex==((LocalRegTreeItem)expression.object).regIndex){ - commands.remove(0); - expression.object=((SetTypeTreeItem)firstAssign).getObject(); - } - } - - } - //locAssign. - } - this.expression = expression; - this.commands = commands; - } - - @Override + public ForEachInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List commands) { + super(instruction, loopBreak, loopContinue); + TreeItem firstAssign = commands.get(0); + if (firstAssign instanceof SetTypeTreeItem) { + if (expression.object instanceof LocalRegTreeItem) { + if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { + commands.remove(0); + expression.object = ((SetTypeTreeItem) firstAssign).getObject(); + } + } + + } + //locAssign. + } + this.expression = expression; + this.commands = commands; + } + + @Override public boolean needsSemicolon() { return false; } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("for each (") + expression.toString(constants,localRegNames) + ")\r\n{\r\n"; - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loopBreak; - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("for each (") + expression.toString(constants, localRegNames) + ")\r\n{\r\n"; + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loopBreak; + return ret; + } - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForInTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForInTreeItem.java index 3271233f1..670429f19 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForInTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForInTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -24,60 +23,58 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class ForInTreeItem extends LoopTreeItem implements Block { - public InTreeItem expression; - public List commands; + public InTreeItem expression; + public List commands; - public ForInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List commands) { - super(instruction, loopBreak, loopContinue); - TreeItem firstAssign=commands.get(0); - if(firstAssign instanceof SetTypeTreeItem){ - if(expression.object instanceof LocalRegTreeItem){ - if(((SetTypeTreeItem)firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) - { - if(((LocalRegTreeItem)((SetTypeTreeItem)firstAssign).getValue().getNotCoerced()).regIndex==((LocalRegTreeItem)expression.object).regIndex){ - commands.remove(0); - expression.object=((SetTypeTreeItem)firstAssign).getObject(); - } - } - - } - //locAssign. - } - this.expression = expression; - this.commands = commands; - } - - @Override + public ForInTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, InTreeItem expression, List commands) { + super(instruction, loopBreak, loopContinue); + TreeItem firstAssign = commands.get(0); + if (firstAssign instanceof SetTypeTreeItem) { + if (expression.object instanceof LocalRegTreeItem) { + if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { + commands.remove(0); + expression.object = ((SetTypeTreeItem) firstAssign).getObject(); + } + } + + } + //locAssign. + } + this.expression = expression; + this.commands = commands; + } + + @Override public boolean needsSemicolon() { return false; } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("for (") + expression.toString(constants,localRegNames) + ")\r\n{\r\n"; - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loopBreak; - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("for (") + expression.toString(constants, localRegNames) + ")\r\n{\r\n"; + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loopBreak; + return ret; + } - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForTreeItem.java index c66c74fc9..305fbd776 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/ForTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,73 +24,72 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class ForTreeItem extends LoopTreeItem implements Block { - public List firstCommands; - public TreeItem expression; - public List finalCommands; - public List commands; + public List firstCommands; + public TreeItem expression; + public List finalCommands; + public List commands; - public ForTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, List firstCommands, TreeItem expression, List finalCommands, List commands) { - super(instruction, loopBreak, loopContinue); - this.firstCommands = firstCommands; - this.expression = expression; - this.finalCommands = finalCommands; - this.commands = commands; - } + public ForTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, List firstCommands, TreeItem expression, List finalCommands, List commands) { + super(instruction, loopBreak, loopContinue); + this.firstCommands = firstCommands; + this.expression = expression; + this.finalCommands = finalCommands; + this.commands = commands; + } - private String stripSemicolon(String s) { - if (s.endsWith(";")) { - s = s.substring(0, s.length() - 1); - } - return s; - } + private String stripSemicolon(String s) { + if (s.endsWith(";")) { + s = s.substring(0, s.length() - 1); + } + return s; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("for("); - for (int i = 0; i < firstCommands.size(); i++) { - if (i > 0) { - ret += ","; - } - ret += stripSemicolon(firstCommands.get(i).toString(constants,localRegNames)); - } - ret += ";"; - ret += expression.toString(constants,localRegNames); - ret += ";"; - for (int i = 0; i < finalCommands.size(); i++) { - if (i > 0) { - ret += ","; - } - ret += stripSemicolon(finalCommands.get(i).toString(constants,localRegNames)); - } - ret += hilight(")") + "\r\n{\r\n"; - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loopBreak; - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("for("); + for (int i = 0; i < firstCommands.size(); i++) { + if (i > 0) { + ret += ","; + } + ret += stripSemicolon(firstCommands.get(i).toString(constants, localRegNames)); + } + ret += ";"; + ret += expression.toString(constants, localRegNames); + ret += ";"; + for (int i = 0; i < finalCommands.size(); i++) { + if (i > 0) { + ret += ","; + } + ret += stripSemicolon(finalCommands.get(i).toString(constants, localRegNames)); + } + ret += hilight(")") + "\r\n{\r\n"; + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loopBreak; + return ret; + } - @Override + @Override public boolean needsSemicolon() { return false; } - - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/IfTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/IfTreeItem.java index 7ce7f67b3..4486cd2fc 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/IfTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/IfTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,62 +24,60 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class IfTreeItem extends TreeItem implements Block { - public TreeItem expression; - public List onTrue; - public List onFalse; - public IfTreeItem(AVM2Instruction instruction, TreeItem expression, List onTrue, List onFalse) { - super(instruction, NOPRECEDENCE); - this.expression = expression; - this.onTrue = onTrue; - this.onFalse = onFalse; - } + public TreeItem expression; + public List onTrue; + public List onFalse; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret = hilight("if(") + expression.toString(constants,localRegNames) + hilight(")\r\n{\r\n"); - for (TreeItem ti : onTrue) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}"); - if (onFalse.size() > 0) { - ret += hilight("\r\nelse\r\n{\r\n"); - for (TreeItem ti : onFalse) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}"); - } - return ret; - } + public IfTreeItem(AVM2Instruction instruction, TreeItem expression, List onTrue, List onFalse) { + super(instruction, NOPRECEDENCE); + this.expression = expression; + this.onTrue = onTrue; + this.onFalse = onFalse; + } - @Override + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret = hilight("if(") + expression.toString(constants, localRegNames) + hilight(")\r\n{\r\n"); + for (TreeItem ti : onTrue) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}"); + if (onFalse.size() > 0) { + ret += hilight("\r\nelse\r\n{\r\n"); + for (TreeItem ti : onFalse) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}"); + } + return ret; + } + + @Override public boolean needsSemicolon() { return false; } - - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : onTrue) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - for (TreeItem ti : onFalse) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } - + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : onTrue) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + for (TreeItem ti : onFalse) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/LoopTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/LoopTreeItem.java index f9c2f5334..618e84ab3 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/LoopTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/LoopTreeItem.java @@ -14,23 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public abstract class LoopTreeItem extends TreeItem { - public int loopBreak; - public int loopContinue; - public LoopTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue) { - super(instruction, NOPRECEDENCE); - this.loopBreak = loopBreak; - this.loopContinue = loopContinue; - } - @Override + public int loopBreak; + public int loopContinue; + + public LoopTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue) { + super(instruction, NOPRECEDENCE); + this.loopBreak = loopBreak; + this.loopContinue = loopContinue; + } + + @Override public boolean needsSemicolon() { return false; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/SwitchTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/SwitchTreeItem.java index 382abbf7f..21790d682 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/SwitchTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/SwitchTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.AVM2Code; @@ -26,75 +25,74 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class SwitchTreeItem extends LoopTreeItem implements Block { - public TreeItem switchedObject; - public List caseValues; - public List> caseCommands; - public List defaultCommands; + public TreeItem switchedObject; + public List caseValues; + public List> caseCommands; + public List defaultCommands; - public SwitchTreeItem(AVM2Instruction instruction, int switchBreak, TreeItem switchedObject, List caseValues, List> caseCommands, List defaultCommands) { - super(instruction, switchBreak, -1); - this.switchedObject = switchedObject; - this.caseValues = caseValues; - this.caseCommands = caseCommands; - this.defaultCommands = defaultCommands; - } + public SwitchTreeItem(AVM2Instruction instruction, int switchBreak, TreeItem switchedObject, List caseValues, List> caseCommands, List defaultCommands) { + super(instruction, switchBreak, -1); + this.switchedObject = switchedObject; + this.caseValues = caseValues; + this.caseCommands = caseCommands; + this.defaultCommands = defaultCommands; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("switch(") + switchedObject.toString(constants,localRegNames) + hilight(")") + "\r\n{\r\n"; - for (int i = 0; i < caseValues.size(); i++) { - ret += "case " + caseValues.get(i).toString(constants,localRegNames) + ":\r\n"; - ret += AVM2Code.IDENTOPEN + "\r\n"; - for (int j = 0; j < caseCommands.get(i).size(); j++) { - ret += caseCommands.get(i).get(j).toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += AVM2Code.IDENTCLOSE + "\r\n"; - } - if (defaultCommands.size() > 0) { - ret += hilight("default") + ":\r\n"; - ret += AVM2Code.IDENTOPEN + "\r\n"; - for (int j = 0; j < defaultCommands.size(); j++) { - ret += defaultCommands.get(j).toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += AVM2Code.IDENTCLOSE + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loopBreak; - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("switch(") + switchedObject.toString(constants, localRegNames) + hilight(")") + "\r\n{\r\n"; + for (int i = 0; i < caseValues.size(); i++) { + ret += "case " + caseValues.get(i).toString(constants, localRegNames) + ":\r\n"; + ret += AVM2Code.IDENTOPEN + "\r\n"; + for (int j = 0; j < caseCommands.get(i).size(); j++) { + ret += caseCommands.get(i).get(j).toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += AVM2Code.IDENTCLOSE + "\r\n"; + } + if (defaultCommands.size() > 0) { + ret += hilight("default") + ":\r\n"; + ret += AVM2Code.IDENTOPEN + "\r\n"; + for (int j = 0; j < defaultCommands.size(); j++) { + ret += defaultCommands.get(j).toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += AVM2Code.IDENTCLOSE + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loopBreak; + return ret; + } - @Override + @Override public boolean needsSemicolon() { return false; } - - public List getContinues() { - List ret = new ArrayList(); - for (List onecase : caseCommands) { - for (TreeItem ti : onecase) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - } + public List getContinues() { + List ret = new ArrayList(); - for (TreeItem ti : defaultCommands) { + for (List onecase : caseCommands) { + for (TreeItem ti : onecase) { if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); + ret.add((ContinueTreeItem) ti); } if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); + ret.addAll(((Block) ti).getContinues()); } - } - return ret; - } + } + } + + for (TreeItem ti : defaultCommands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TernarOpTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TernarOpTreeItem.java index a44248ea8..999a55205 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TernarOpTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TernarOpTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,23 +21,21 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.HashMap; - public class TernarOpTreeItem extends TreeItem { - public TreeItem expression; - public TreeItem onTrue; - public TreeItem onFalse; - public TernarOpTreeItem(AVM2Instruction instruction, TreeItem expression, TreeItem onTrue, TreeItem onFalse) { - super(instruction, PRECEDENCE_CONDITIONAL); - this.expression = expression; - this.onTrue = onTrue; - this.onFalse = onFalse; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return expression.toString(constants,localRegNames) + hilight("?") + onTrue.toString(constants,localRegNames) + hilight(":") + onFalse.toString(constants,localRegNames); - } + public TreeItem expression; + public TreeItem onTrue; + public TreeItem onFalse; + public TernarOpTreeItem(AVM2Instruction instruction, TreeItem expression, TreeItem onTrue, TreeItem onFalse) { + super(instruction, PRECEDENCE_CONDITIONAL); + this.expression = expression; + this.onTrue = onTrue; + this.onFalse = onFalse; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return expression.toString(constants, localRegNames) + hilight("?") + onTrue.toString(constants, localRegNames) + hilight(":") + onFalse.toString(constants, localRegNames); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TryTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TryTreeItem.java index 2c37ee7b9..d69e9462c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TryTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/TryTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,82 +24,81 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class TryTreeItem extends TreeItem implements Block { - public List tryCommands; - public List catchExceptions; - public List> catchCommands; - public List finallyCommands; + public List tryCommands; + public List catchExceptions; + public List> catchCommands; + public List finallyCommands; - public TryTreeItem(List tryCommands, List catchExceptions, List> catchCommands, List finallyCommands) { - super(null, NOPRECEDENCE); - this.tryCommands = tryCommands; - this.catchExceptions = catchExceptions; - this.catchCommands = catchCommands; - this.finallyCommands = finallyCommands; - } + public TryTreeItem(List tryCommands, List catchExceptions, List> catchCommands, List finallyCommands) { + super(null, NOPRECEDENCE); + this.tryCommands = tryCommands; + this.catchExceptions = catchExceptions; + this.catchCommands = catchCommands; + this.finallyCommands = finallyCommands; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "try\r\n{\r\n"; - for (TreeItem ti : tryCommands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += "}"; - for (int e = 0; e < catchExceptions.size(); e++) { - ret += "\r\ncatch(" + catchExceptions.get(e).getVarName(constants) + ":" + catchExceptions.get(e).getTypeName(constants) + ")\r\n{\r\n"; - List commands = catchCommands.get(e); - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += "}"; - } - if (finallyCommands.size() > 0) { - ret += "\r\nfinally\r\n{\r\n"; - for (TreeItem ti : finallyCommands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += "}"; - } - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "try\r\n{\r\n"; + for (TreeItem ti : tryCommands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += "}"; + for (int e = 0; e < catchExceptions.size(); e++) { + ret += "\r\ncatch(" + catchExceptions.get(e).getVarName(constants) + ":" + catchExceptions.get(e).getTypeName(constants) + ")\r\n{\r\n"; + List commands = catchCommands.get(e); + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += "}"; + } + if (finallyCommands.size() > 0) { + ret += "\r\nfinally\r\n{\r\n"; + for (TreeItem ti : finallyCommands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += "}"; + } + return ret; + } - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : tryCommands) { + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : tryCommands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + if (finallyCommands != null) { + for (TreeItem ti : finallyCommands) { if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); + ret.add((ContinueTreeItem) ti); } if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); + ret.addAll(((Block) ti).getContinues()); } - } - if (finallyCommands != null) { - for (TreeItem ti : finallyCommands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } + } + } + for (List commands : catchCommands) { + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); } - } - for (List commands : catchCommands) { - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); } - } - return ret; - } - - @Override + } + } + return ret; + } + + @Override public boolean needsSemicolon() { return false; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/WhileTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/WhileTreeItem.java index 5df804cd3..926c733fa 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/WhileTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/clauses/WhileTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.clauses; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -25,45 +24,44 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; - public class WhileTreeItem extends LoopTreeItem implements Block { - public TreeItem expression; - public List commands; + public TreeItem expression; + public List commands; - public WhileTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, TreeItem expression, List commands) { - super(instruction, loopBreak, loopContinue); - this.expression = expression; - this.commands = commands; - } + public WhileTreeItem(AVM2Instruction instruction, int loopBreak, int loopContinue, TreeItem expression, List commands) { + super(instruction, loopBreak, loopContinue); + this.expression = expression; + this.commands = commands; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - ret += "loop" + loopBreak + ":\r\n"; - ret += hilight("while(") + expression.toString(constants,localRegNames) + hilight(")") + "\r\n{\r\n"; - for (TreeItem ti : commands) { - ret += ti.toStringSemicoloned(constants,localRegNames) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loopBreak; - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + ret += "loop" + loopBreak + ":\r\n"; + ret += hilight("while(") + expression.toString(constants, localRegNames) + hilight(")") + "\r\n{\r\n"; + for (TreeItem ti : commands) { + ret += ti.toStringSemicoloned(constants, localRegNames) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loopBreak; + return ret; + } - public List getContinues() { - List ret = new ArrayList(); - for (TreeItem ti : commands) { - if (ti instanceof ContinueTreeItem) { - ret.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } - - @Override + public List getContinues() { + List ret = new ArrayList(); + for (TreeItem ti : commands) { + if (ti instanceof ContinueTreeItem) { + ret.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } + + @Override public boolean needsSemicolon() { return false; } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AddTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AddTreeItem.java index 64b4f61c5..2952dd928 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AddTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AddTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class AddTreeItem extends BinaryOpTreeItem { - public AddTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+"); - } - + public AddTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AndTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AndTreeItem.java index e12918f17..73a883c68 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AndTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AndTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class AndTreeItem extends BinaryOpTreeItem { - public AndTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&"); - } - + public AndTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AsTypeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AsTypeTreeItem.java index e45b96740..5548e0f34 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AsTypeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/AsTypeTreeItem.java @@ -14,18 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class AsTypeTreeItem extends BinaryOpTreeItem { - public AsTypeTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " as "); - } - - + public AsTypeTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " as "); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BinaryOpTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BinaryOpTreeItem.java index bedc5d3cb..03d6648ef 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BinaryOpTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BinaryOpTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,36 +21,33 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.HashMap; - public abstract class BinaryOpTreeItem extends TreeItem { - public TreeItem leftSide; - public TreeItem rightSide; - protected String operator = ""; - - public BinaryOpTreeItem(AVM2Instruction instruction, int precedence, TreeItem leftSide, TreeItem rightSide, String operator) { - super(instruction, precedence); - this.leftSide = leftSide; - this.rightSide = rightSide; - this.operator = operator; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String ret = ""; - if (leftSide.precedence > precedence) { - ret += "(" + leftSide.toString(constants,localRegNames) + ")"; - } else { - ret += leftSide.toString(constants,localRegNames); - } - ret += hilight(operator); - if (rightSide.precedence > precedence) { - ret += "(" + rightSide.toString(constants,localRegNames) + ")"; - } else { - ret += rightSide.toString(constants,localRegNames); - } - return ret; - } + public TreeItem leftSide; + public TreeItem rightSide; + protected String operator = ""; + public BinaryOpTreeItem(AVM2Instruction instruction, int precedence, TreeItem leftSide, TreeItem rightSide, String operator) { + super(instruction, precedence); + this.leftSide = leftSide; + this.rightSide = rightSide; + this.operator = operator; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String ret = ""; + if (leftSide.precedence > precedence) { + ret += "(" + leftSide.toString(constants, localRegNames) + ")"; + } else { + ret += leftSide.toString(constants, localRegNames); + } + ret += hilight(operator); + if (rightSide.precedence > precedence) { + ret += "(" + rightSide.toString(constants, localRegNames) + ")"; + } else { + ret += rightSide.toString(constants, localRegNames); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitAndTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitAndTreeItem.java index 0b5c99712..e070d4d50 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitAndTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitAndTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class BitAndTreeItem extends BinaryOpTreeItem { - public BitAndTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&"); - } - + public BitAndTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitNotTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitNotTreeItem.java index 51b5a4c4c..01a2fd196 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitNotTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitNotTreeItem.java @@ -14,16 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class BitNotTreeItem extends UnaryOpTreeItem { - public BitNotTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, PRECEDENCE_UNARY, value, "~"); - } + public BitNotTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, PRECEDENCE_UNARY, value, "~"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitOrTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitOrTreeItem.java index 43c80c849..9f9ac524c 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitOrTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitOrTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class BitOrTreeItem extends BinaryOpTreeItem { - public BitOrTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|"); - } - + public BitOrTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitXorTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitXorTreeItem.java index a6ce597db..639e5757e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitXorTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/BitXorTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class BitXorTreeItem extends BinaryOpTreeItem { - public BitXorTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^"); - } - + public BitXorTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java index 4ef0e4f84..63cc3c3f0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -23,21 +22,19 @@ import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.HashMap; - public class DeletePropertyTreeItem extends TreeItem { - public TreeItem object; - public FullMultinameTreeItem propertyName; - public DeletePropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_UNARY); - this.object = object; - this.propertyName = propertyName; - } - - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - return hilight("delete ") + object.toString(constants,localRegNames) + "[" + propertyName.toString(constants,localRegNames) + "]"; - } + public TreeItem object; + public FullMultinameTreeItem propertyName; + public DeletePropertyTreeItem(AVM2Instruction instruction, TreeItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_UNARY); + this.object = object; + this.propertyName = propertyName; + } + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + return hilight("delete ") + object.toString(constants, localRegNames) + "[" + propertyName.toString(constants, localRegNames) + "]"; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DivideTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DivideTreeItem.java index d65d1ab77..78ce26bc8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DivideTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/DivideTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class DivideTreeItem extends BinaryOpTreeItem { - public DivideTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/"); - } - + public DivideTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/EqTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/EqTreeItem.java index 36a2f7ec6..307cc3d21 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/EqTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/EqTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class EqTreeItem extends BinaryOpTreeItem { - public EqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "=="); - } - + public EqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "=="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GeTreeItem.java index 68f29ca5c..ad9712d11 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GeTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class GeTreeItem extends BinaryOpTreeItem { - public GeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">="); - } - + public GeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GtTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GtTreeItem.java index d5fbf99bc..49d16dce1 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GtTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/GtTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class GtTreeItem extends BinaryOpTreeItem { - public GtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">"); - } - + public GtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InTreeItem.java index c94457a09..f190ee8cb 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InTreeItem.java @@ -14,18 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class InTreeItem extends BinaryOpTreeItem { - public InTreeItem(AVM2Instruction instruction, TreeItem name, TreeItem object) { - super(instruction, PRECEDENCE_RELATIONAL, name, object, " in "); - } - - + public InTreeItem(AVM2Instruction instruction, TreeItem name, TreeItem object) { + super(instruction, PRECEDENCE_RELATIONAL, name, object, " in "); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InstanceOfTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InstanceOfTreeItem.java index 7f48bb28d..9560d9ba0 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InstanceOfTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/InstanceOfTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class InstanceOfTreeItem extends BinaryOpTreeItem { - public InstanceOfTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " instanceof "); - } - + public InstanceOfTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " instanceof "); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/IsTypeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/IsTypeTreeItem.java index fe8dae5c1..066e61afe 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/IsTypeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/IsTypeTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class IsTypeTreeItem extends BinaryOpTreeItem { - public IsTypeTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " is "); - } - + public IsTypeTreeItem(AVM2Instruction instruction, TreeItem value, TreeItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " is "); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LShiftTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LShiftTreeItem.java index 4423ac048..bd4ef1332 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LShiftTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LShiftTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class LShiftTreeItem extends BinaryOpTreeItem { - public LShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<"); - } - + public LShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LeTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LeTreeItem.java index 3e2262ce8..8dbefd0f9 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LeTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LeTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class LeTreeItem extends BinaryOpTreeItem { - public LeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<="); - } - + public LeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LtTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LtTreeItem.java index 04d1a7062..a17178455 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LtTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/LtTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class LtTreeItem extends BinaryOpTreeItem { - public LtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<"); - } - + public LtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/ModuloTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/ModuloTreeItem.java index d719a3a70..f578a31d1 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/ModuloTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/ModuloTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class ModuloTreeItem extends BinaryOpTreeItem { - public ModuloTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%"); - } - + public ModuloTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/MultiplyTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/MultiplyTreeItem.java index 3088f6f10..820af13df 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/MultiplyTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/MultiplyTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class MultiplyTreeItem extends BinaryOpTreeItem { - public MultiplyTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*"); - } - + public MultiplyTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NegTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NegTreeItem.java index db471afca..3f15e196e 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NegTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NegTreeItem.java @@ -14,16 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class NegTreeItem extends UnaryOpTreeItem { - public NegTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, PRECEDENCE_UNARY, value, "-"); - } + public NegTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, PRECEDENCE_UNARY, value, "-"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NeqTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NeqTreeItem.java index d694991b8..ec56cf9e8 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NeqTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NeqTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class NeqTreeItem extends BinaryOpTreeItem { - public NeqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!="); - } - + public NeqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NotTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NotTreeItem.java index 8912ca834..5702c3b46 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NotTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/NotTreeItem.java @@ -14,28 +14,24 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class NotTreeItem extends UnaryOpTreeItem { - public NotTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, PRECEDENCE_UNARY, value, "!"); - } - - @Override - public boolean isTrue() { - return !value.isTrue(); - } - - @Override - public boolean isFalse() { - return !value.isFalse(); - } + public NotTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, PRECEDENCE_UNARY, value, "!"); + } + @Override + public boolean isTrue() { + return !value.isTrue(); + } + @Override + public boolean isFalse() { + return !value.isFalse(); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/OrTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/OrTreeItem.java index 49a16228f..28d57dfb6 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/OrTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/OrTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class OrTreeItem extends BinaryOpTreeItem { - public OrTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); - } - + public OrTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreDecrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreDecrementTreeItem.java index 484c6c5bd..928bb8b26 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreDecrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreDecrementTreeItem.java @@ -14,15 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class PreDecrementTreeItem extends UnaryOpTreeItem { - public PreDecrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_UNARY, object, "--"); - } + + public PreDecrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_UNARY, object, "--"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreIncrementTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreIncrementTreeItem.java index 9d24bec22..3c0946c85 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreIncrementTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/PreIncrementTreeItem.java @@ -14,18 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class PreIncrementTreeItem extends UnaryOpTreeItem { - public PreIncrementTreeItem(AVM2Instruction instruction, TreeItem object) { - super(instruction, PRECEDENCE_UNARY, object, "++"); - } - - + public PreIncrementTreeItem(AVM2Instruction instruction, TreeItem object) { + super(instruction, PRECEDENCE_UNARY, object, "++"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/RShiftTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/RShiftTreeItem.java index 8aa0bedec..b2a8e65aa 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/RShiftTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/RShiftTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class RShiftTreeItem extends BinaryOpTreeItem { - public RShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>"); - } - + public RShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictEqTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictEqTreeItem.java index ee3f99a98..4a93d3a88 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictEqTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictEqTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class StrictEqTreeItem extends BinaryOpTreeItem { - public StrictEqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==="); - } - + public StrictEqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictNeqTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictNeqTreeItem.java index 53b9cf161..92b95cf75 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictNeqTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/StrictNeqTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class StrictNeqTreeItem extends BinaryOpTreeItem { - public StrictNeqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!=="); - } - + public StrictNeqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!=="); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/SubtractTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/SubtractTreeItem.java index a331d64f3..5e9cd3a34 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/SubtractTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/SubtractTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class SubtractTreeItem extends BinaryOpTreeItem { - public SubtractTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-"); - } - + public SubtractTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/TypeOfTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/TypeOfTreeItem.java index 8522e06dc..a28be3669 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/TypeOfTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/TypeOfTreeItem.java @@ -14,16 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class TypeOfTreeItem extends UnaryOpTreeItem { - public TypeOfTreeItem(AVM2Instruction instruction, TreeItem value) { - super(instruction, PRECEDENCE_UNARY, value, "typeof "); - } + public TypeOfTreeItem(AVM2Instruction instruction, TreeItem value) { + super(instruction, PRECEDENCE_UNARY, value, "typeof "); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/URShiftTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/URShiftTreeItem.java index b5fb6f87a..2c6c85124 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/URShiftTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/URShiftTreeItem.java @@ -14,17 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; - public class URShiftTreeItem extends BinaryOpTreeItem { - public URShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>"); - } - + public URShiftTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>"); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/UnaryOpTreeItem.java b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/UnaryOpTreeItem.java index 1323ea79c..897aebad5 100644 --- a/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/UnaryOpTreeItem.java +++ b/trunk/src/com/jpexs/asdec/abc/avm2/treemodel/operations/UnaryOpTreeItem.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.avm2.treemodel.operations; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,21 +21,23 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction; import com.jpexs.asdec.abc.avm2.treemodel.TreeItem; import java.util.HashMap; - public abstract class UnaryOpTreeItem extends TreeItem { - public TreeItem value; - public String operator; - public UnaryOpTreeItem(AVM2Instruction instruction, int precedence, TreeItem value, String operator) { - super(instruction, precedence); - this.value = value; - this.operator = operator; - } + public TreeItem value; + public String operator; - @Override - public String toString(ConstantPool constants, HashMap localRegNames) { - String s = value.toString(constants,localRegNames); - if (value.precedence > precedence) s = "(" + s + ")"; - return hilight(operator) + s; - } + public UnaryOpTreeItem(AVM2Instruction instruction, int precedence, TreeItem value, String operator) { + super(instruction, precedence); + this.value = value; + this.operator = operator; + } + + @Override + public String toString(ConstantPool constants, HashMap localRegNames) { + String s = value.toString(constants, localRegNames); + if (value.precedence > precedence) { + s = "(" + s + ")"; + } + return hilight(operator) + s; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/ABCComboBoxModel.java b/trunk/src/com/jpexs/asdec/abc/gui/ABCComboBoxModel.java index 643ec511f..17c380965 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/ABCComboBoxModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/ABCComboBoxModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.tags.DoABCTag; @@ -22,38 +21,34 @@ import java.util.List; import javax.swing.ComboBoxModel; import javax.swing.event.ListDataListener; - public class ABCComboBoxModel implements ComboBoxModel { - public List list; - public int itemIndex = 0; - public ABCComboBoxModel(List list) { - this.list = list; - } + public List list; + public int itemIndex = 0; + public ABCComboBoxModel(List list) { + this.list = list; + } - public int getSize() { - return list.size(); - } + public int getSize() { + return list.size(); + } - public Object getElementAt(int index) { - return list.get(index); - } + public Object getElementAt(int index) { + return list.get(index); + } - public void addListDataListener(ListDataListener l) { + public void addListDataListener(ListDataListener l) { + } - } + public void removeListDataListener(ListDataListener l) { + } - public void removeListDataListener(ListDataListener l) { - - } - - public void setSelectedItem(Object anItem) { - itemIndex = list.indexOf(anItem); - } - - public Object getSelectedItem() { - return getElementAt(itemIndex); - } + public void setSelectedItem(Object anItem) { + itemIndex = list.indexOf(anItem); + } + public Object getSelectedItem() { + return getElementAt(itemIndex); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/ASMSourceEditorPane.java b/trunk/src/com/jpexs/asdec/abc/gui/ASMSourceEditorPane.java index b1c13f3ec..1013cbf63 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/ASMSourceEditorPane.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.ABC; @@ -28,120 +27,117 @@ import java.io.IOException; import java.util.HashMap; import javax.swing.JOptionPane; - public class ASMSourceEditorPane extends LineMarkedEditorPane { - public ABC abc; - public int bodyIndex=-1; + public ABC abc; + public int bodyIndex = -1; - public ASMSourceEditorPane() { - - } + public ASMSourceEditorPane() { + } - public void setBodyIndex(int bodyIndex, ABC abc) { - this.bodyIndex = bodyIndex; - this.abc = abc; - setText(abc.bodies[bodyIndex].code.toASMSource(abc.constants,abc.bodies[bodyIndex])); - } + public void setBodyIndex(int bodyIndex, ABC abc) { + this.bodyIndex = bodyIndex; + this.abc = abc; + setText(abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex])); + } - public void graph(){ - Graph gr=new Graph(abc.bodies[bodyIndex].code); - //(new GraphTreeFrame(gr)).setVisible(true); - (new GraphFrame(gr,"")).setVisible(true); - } + public void graph() { + Graph gr = new Graph(abc.bodies[bodyIndex].code); + //(new GraphTreeFrame(gr)).setVisible(true); + (new GraphFrame(gr, "")).setVisible(true); + } - public void exec(){ - HashMap args=new HashMap(); - args.put(0, new Object()); //object "this" - args.put(1, new Long(466561)); //param1 - Object o=abc.bodies[bodyIndex].code.execute(args,abc.constants); - JOptionPane.showMessageDialog(this, "Returned object:"+o.toString()); - } + public void exec() { + HashMap args = new HashMap(); + args.put(0, new Object()); //object "this" + args.put(1, new Long(466561)); //param1 + Object o = abc.bodies[bodyIndex].code.execute(args, abc.constants); + JOptionPane.showMessageDialog(this, "Returned object:" + o.toString()); + } - public boolean save(ConstantPool constants) { - try { - AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes()), constants, new DialogMissingSymbolHandler(),abc.bodies[bodyIndex]); - acode.getBytes(abc.bodies[bodyIndex].codeBytes); - abc.bodies[bodyIndex].code = acode; - } catch (IOException ex) { - } catch (ParseException ex) { - JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); - selectLine((int) ex.line); - return false; - } - return true; - } + public boolean save(ConstantPool constants) { + try { + AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes()), constants, new DialogMissingSymbolHandler(), abc.bodies[bodyIndex]); + acode.getBytes(abc.bodies[bodyIndex].codeBytes); + abc.bodies[bodyIndex].code = acode; + } catch (IOException ex) { + } catch (ParseException ex) { + JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); + selectLine((int) ex.line); + return false; + } + return true; + } - public void verify(ConstantPool constants, ABC abc) { - try { - AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes()), constants, new DialogMissingSymbolHandler(),abc.bodies[bodyIndex]); - //acode.clearSecureSWF(abc.constants, abc.bodies[bodyIndex]); - setText(acode.toASMSource(constants,abc.bodies[bodyIndex])); + public void verify(ConstantPool constants, ABC abc) { + try { + AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes()), constants, new DialogMissingSymbolHandler(), abc.bodies[bodyIndex]); + //acode.clearSecureSWF(abc.constants, abc.bodies[bodyIndex]); + setText(acode.toASMSource(constants, abc.bodies[bodyIndex])); - //Main.mainFrame.decompiledTextArea.setBody(mb, abc); - } catch (IOException ex) { - } catch (ParseException ex) { - JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); - selectLine((int) ex.line); - return; - } - JOptionPane.showMessageDialog(this, ("Code OK")); - } + //Main.mainFrame.decompiledTextArea.setBody(mb, abc); + } catch (IOException ex) { + } catch (ParseException ex) { + JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); + selectLine((int) ex.line); + return; + } + JOptionPane.showMessageDialog(this, ("Code OK")); + } - public void selectInstruction(int pos) { - String text = getText(); - int lineCnt = 1; - int lineStart = 0; - int lineEnd = -1; - int instrCount = 0; - int dot = -2; - for (int i = 0; i < text.length(); i++) { - if (text.charAt(i) == '\n') { - - lineCnt++; - lineEnd=i; - String ins=text.substring(lineStart,lineEnd).trim(); - if (!((i > 0) && (text.charAt(i - 1) == ':'))) - { - if(!ins.startsWith("exception ")){ - instrCount++; - } - } - if (instrCount == pos+1) { - break; - } - lineStart = i+1; + public void selectInstruction(int pos) { + String text = getText(); + int lineCnt = 1; + int lineStart = 0; + int lineEnd = -1; + int instrCount = 0; + int dot = -2; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '\n') { + + lineCnt++; + lineEnd = i; + String ins = text.substring(lineStart, lineEnd).trim(); + if (!((i > 0) && (text.charAt(i - 1) == ':'))) { + if (!ins.startsWith("exception ")) { + instrCount++; + } } - } - if (lineCnt == -1) { - lineEnd = text.length() - 1; - } - //select(lineStart, lineEnd); - setCaretPosition(lineStart); - //requestFocus(); - } - - public void selectLine(int line) { - String text = getText(); - int lineCnt = 1; - int lineStart = 0; - int lineEnd = -1; - for (int i = 0; i < text.length(); i++) { - if (text.charAt(i) == '\n') { - lineCnt++; - if (lineCnt == line) { - lineStart = i; - } - if (lineCnt == line + 1) { - lineEnd = i; - } + if (instrCount == pos + 1) { + break; } - } - if (lineCnt == -1) { - lineEnd = text.length() - 1; - } - select(lineStart, lineEnd); - requestFocus(); - } + lineStart = i + 1; + } + } + if (lineCnt == -1) { + lineEnd = text.length() - 1; + } + //select(lineStart, lineEnd); + setCaretPosition(lineStart); + //requestFocus(); + } + + public void selectLine(int line) { + String text = getText(); + int lineCnt = 1; + int lineStart = 0; + int lineEnd = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '\n') { + lineCnt++; + if (lineCnt == line) { + lineStart = i; + } + if (lineCnt == line + 1) { + lineEnd = i; + } + } + } + if (lineCnt == -1) { + lineEnd = text.length() - 1; + } + select(lineStart, lineEnd); + requestFocus(); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTree.java b/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTree.java index 8fbd7d80d..b8a70f86f 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTree.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTree.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -27,52 +26,56 @@ import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreePath; public class ClassesListTree extends JTree implements TreeSelectionListener { - public ABC abc; - public void selectClass(int classIndex) { - ClassesListTreeModel model=(ClassesListTreeModel)getModel(); - TreeElement selectedElement=model.getElementByClassIndex(classIndex); - TreePath treePath=selectedElement.getTreePath(); + public ABC abc; + + public void selectClass(int classIndex) { + ClassesListTreeModel model = (ClassesListTreeModel) getModel(); + TreeElement selectedElement = model.getElementByClassIndex(classIndex); + TreePath treePath = selectedElement.getTreePath(); setSelectionPath(treePath); scrollPathToVisible(treePath); } - public ClassesListTree(ABC abc) { - this.abc = abc; - setModel(new ClassesListTreeModel(abc)); - addTreeSelectionListener(this); - DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); - ClassLoader cldr = this.getClass().getClassLoader(); - java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/abc/gui/graphics/class.png"); - ImageIcon leafIcon = new ImageIcon(imageURL); - treeRenderer.setLeafIcon(leafIcon); - setCellRenderer(treeRenderer); - } + public ClassesListTree(ABC abc) { + this.abc = abc; + setModel(new ClassesListTreeModel(abc)); + addTreeSelectionListener(this); + DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); + ClassLoader cldr = this.getClass().getClassLoader(); + java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/abc/gui/graphics/class.png"); + ImageIcon leafIcon = new ImageIcon(imageURL); + treeRenderer.setLeafIcon(leafIcon); + setCellRenderer(treeRenderer); + } - public void setABC(ABC abc) { - setModel(new ClassesListTreeModel(abc)); - this.abc = abc; - } + public void setABC(ABC abc) { + setModel(new ClassesListTreeModel(abc)); + this.abc = abc; + } - public void valueChanged(TreeSelectionEvent e) { - if (Main.isWorking()) return; - final TreeElement tp = (TreeElement) getLastSelectedPathComponent(); - if (tp == null) return; - final int classIndex = tp.getClassIndex(); - if (classIndex != -1) { - if (!Main.isWorking()) { - Main.startWork("Decompiling class..."); - (new Thread() { - - @Override - public void run() { - Main.abcMainFrame.navigator.setClassIndex(classIndex); - Main.abcMainFrame.decompiledTextArea.setClassIndex(classIndex, abc); - Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText(""); - Main.stopWork(); - } - }).start(); - } - } - } + public void valueChanged(TreeSelectionEvent e) { + if (Main.isWorking()) { + return; + } + final TreeElement tp = (TreeElement) getLastSelectedPathComponent(); + if (tp == null) { + return; + } + final int classIndex = tp.getClassIndex(); + if (classIndex != -1) { + if (!Main.isWorking()) { + Main.startWork("Decompiling class..."); + (new Thread() { + @Override + public void run() { + Main.abcMainFrame.navigator.setClassIndex(classIndex); + Main.abcMainFrame.decompiledTextArea.setClassIndex(classIndex, abc); + Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText(""); + Main.stopWork(); + } + }).start(); + } + } + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTreeModel.java b/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTreeModel.java index a015a5377..fc07614cb 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTreeModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/ClassesListTreeModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.ABC; @@ -22,97 +21,93 @@ import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; +class ClassIndexVisitor implements TreeVisitor { - -class ClassIndexVisitor implements TreeVisitor{ - - private TreeElement found=null; + private TreeElement found = null; private int classIndex; - public ClassIndexVisitor(int classIndex){ - this.classIndex=classIndex; + + public ClassIndexVisitor(int classIndex) { + this.classIndex = classIndex; } - + public void onBranch(TreeElement branch) { - if(branch.getClassIndex()==classIndex){ - found=branch; + if (branch.getClassIndex() == classIndex) { + found = branch; } } public void onLeaf(TreeElement leaf) { - if(leaf.getClassIndex()==classIndex){ - found=leaf; + if (leaf.getClassIndex() == classIndex) { + found = leaf; } } - public TreeElement getFound(){ + + public TreeElement getFound() { return found; } - } public class ClassesListTreeModel implements TreeModel { - private ABC abc; - private Tree classTree = new Tree(); - public ClassesListTreeModel(ABC abc) { - this.abc = abc; - for (int i = 0; i < abc.instance_info.length; i++) { - String packageName = abc.instance_info[i].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); - String className = abc.instance_info[i].getName(abc.constants).getName(abc.constants); - String full = packageName + "." + className; - classTree.add(className, packageName, i); - } - } + private ABC abc; + private Tree classTree = new Tree(); - public int getClassIndexByPath(String fullPath){ - TreeElement elem=classTree.get(fullPath); - if(elem==null){ - return -1; - } - return elem.getClassIndex(); - } - - public TreeElement getElementByClassIndex(int classIndex){ - ClassIndexVisitor civ=new ClassIndexVisitor(classIndex); - classTree.visit(civ); - return civ.getFound(); - } + public ClassesListTreeModel(ABC abc) { + this.abc = abc; + for (int i = 0; i < abc.instance_info.length; i++) { + String packageName = abc.instance_info[i].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); + String className = abc.instance_info[i].getName(abc.constants).getName(abc.constants); + String full = packageName + "." + className; + classTree.add(className, packageName, i); + } + } - public Object getRoot() { - return classTree.getRoot(); - } + public int getClassIndexByPath(String fullPath) { + TreeElement elem = classTree.get(fullPath); + if (elem == null) { + return -1; + } + return elem.getClassIndex(); + } - public Object getChild(Object parent, int index) { - TreeElement pte = (TreeElement)parent; - TreeElement te = pte.getChild(index); - return te; - } + public TreeElement getElementByClassIndex(int classIndex) { + ClassIndexVisitor civ = new ClassIndexVisitor(classIndex); + classTree.visit(civ); + return civ.getFound(); + } - public int getChildCount(Object parent) { - TreeElement te = (TreeElement)parent; - return te.getChildCount(); - } + public Object getRoot() { + return classTree.getRoot(); + } - public boolean isLeaf(Object node) { - TreeElement te = (TreeElement)node; - return te.isLeaf(); - } + public Object getChild(Object parent, int index) { + TreeElement pte = (TreeElement) parent; + TreeElement te = pte.getChild(index); + return te; + } - public void valueForPathChanged(TreePath path, Object newValue) { + public int getChildCount(Object parent) { + TreeElement te = (TreeElement) parent; + return te.getChildCount(); + } - } + public boolean isLeaf(Object node) { + TreeElement te = (TreeElement) node; + return te.isLeaf(); + } - public int getIndexOfChild(Object parent, Object child) { - TreeElement te1 = (TreeElement)parent; - TreeElement te2 = (TreeElement)child; - return te1.getIndexOfChild(te2); - } + public void valueForPathChanged(TreePath path, Object newValue) { + } - public void addTreeModelListener(TreeModelListener l) { + public int getIndexOfChild(Object parent, Object child) { + TreeElement te1 = (TreeElement) parent; + TreeElement te2 = (TreeElement) child; + return te1.getIndexOfChild(te2); + } - } - - public void removeTreeModelListener(TreeModelListener l) { - - } + public void addTreeModelListener(TreeModelListener l) { + } + public void removeTreeModelListener(TreeModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/ConstantsListModel.java b/trunk/src/com/jpexs/asdec/abc/gui/ConstantsListModel.java index 6ea7b858e..85d73c679 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/ConstantsListModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/ConstantsListModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.avm2.ConstantPool; @@ -22,81 +21,78 @@ import com.jpexs.asdec.helpers.Helper; import javax.swing.ListModel; import javax.swing.event.ListDataListener; - public class ConstantsListModel implements ListModel { - private ConstantPool constants; - public static final int TYPE_UINT = 0; - public static final int TYPE_INT = 1; - public static final int TYPE_DOUBLE = 2; - public static final int TYPE_DECIMAL = 3; - public static final int TYPE_STRING = 4; - public static final int TYPE_NAMESPACE = 5; - public static final int TYPE_NAMESPACESET = 6; - public static final int TYPE_MULTINAME = 7; - private int type = TYPE_INT; + private ConstantPool constants; + public static final int TYPE_UINT = 0; + public static final int TYPE_INT = 1; + public static final int TYPE_DOUBLE = 2; + public static final int TYPE_DECIMAL = 3; + public static final int TYPE_STRING = 4; + public static final int TYPE_NAMESPACE = 5; + public static final int TYPE_NAMESPACESET = 6; + public static final int TYPE_MULTINAME = 7; + private int type = TYPE_INT; - public ConstantsListModel(ConstantPool constants, int type) { - this.type = type; - this.constants = constants; - } + public ConstantsListModel(ConstantPool constants, int type) { + this.type = type; + this.constants = constants; + } + private int makeUp(int i) { + if (i < 0) { + return 0; + } + return i; + } - private int makeUp(int i) { - if (i < 0) return 0; - return i; - } + public int getSize() { + switch (type) { + case TYPE_UINT: + return makeUp(constants.constant_uint.length - 1); + case TYPE_INT: + return makeUp(constants.constant_int.length - 1); + case TYPE_DOUBLE: + return makeUp(constants.constant_double.length - 1); + case TYPE_DECIMAL: + return makeUp(constants.constant_decimal.length - 1); + case TYPE_STRING: + return makeUp(constants.constant_string.length - 1); + case TYPE_NAMESPACE: + return makeUp(constants.constant_namespace.length - 1); + case TYPE_NAMESPACESET: + return makeUp(constants.constant_namespace_set.length - 1); + case TYPE_MULTINAME: + return makeUp(constants.constant_multiname.length - 1); + } + return 0; + } - public int getSize() { - switch (type) { - case TYPE_UINT: - return makeUp(constants.constant_uint.length - 1); - case TYPE_INT: - return makeUp(constants.constant_int.length - 1); - case TYPE_DOUBLE: - return makeUp(constants.constant_double.length - 1); - case TYPE_DECIMAL: - return makeUp(constants.constant_decimal.length - 1); - case TYPE_STRING: - return makeUp(constants.constant_string.length - 1); - case TYPE_NAMESPACE: - return makeUp(constants.constant_namespace.length - 1); - case TYPE_NAMESPACESET: - return makeUp(constants.constant_namespace_set.length - 1); - case TYPE_MULTINAME: - return makeUp(constants.constant_multiname.length - 1); - } - return 0; - } + public Object getElementAt(int index) { + switch (type) { + case TYPE_UINT: + return "" + (index + 1) + ":" + constants.constant_uint[index + 1]; + case TYPE_INT: + return "" + (index + 1) + ":" + constants.constant_int[index + 1]; + case TYPE_DOUBLE: + return "" + (index + 1) + ":" + constants.constant_double[index + 1]; + case TYPE_DECIMAL: + return "" + (index + 1) + ":" + constants.constant_decimal[index + 1]; + case TYPE_STRING: + return "" + (index + 1) + ":" + Helper.escapeString(constants.constant_string[index + 1]); + case TYPE_NAMESPACE: + return "" + (index + 1) + ":" + constants.constant_namespace[index + 1].getNameWithKind(constants); + case TYPE_NAMESPACESET: + return "" + (index + 1) + ":" + constants.constant_namespace_set[index + 1].toString(constants); + case TYPE_MULTINAME: + return "" + (index + 1) + ":" + constants.constant_multiname[index + 1].toString(constants); + } + return null; + } - public Object getElementAt(int index) { - switch (type) { - case TYPE_UINT: - return "" + (index + 1) + ":" + constants.constant_uint[index + 1]; - case TYPE_INT: - return "" + (index + 1) + ":" + constants.constant_int[index + 1]; - case TYPE_DOUBLE: - return "" + (index + 1) + ":" + constants.constant_double[index + 1]; - case TYPE_DECIMAL: - return "" + (index + 1) + ":" + constants.constant_decimal[index + 1]; - case TYPE_STRING: - return "" + (index + 1) + ":" + Helper.escapeString(constants.constant_string[index + 1]); - case TYPE_NAMESPACE: - return "" + (index + 1) + ":" + constants.constant_namespace[index + 1].getNameWithKind(constants); - case TYPE_NAMESPACESET: - return "" + (index + 1) + ":" + constants.constant_namespace_set[index + 1].toString(constants); - case TYPE_MULTINAME: - return "" + (index + 1) + ":" + constants.constant_multiname[index + 1].toString(constants); - } - return null; - } - - public void addListDataListener(ListDataListener l) { - - } - - public void removeListDataListener(ListDataListener l) { - - } + public void addListDataListener(ListDataListener l) { + } + public void removeListDataListener(ListDataListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/asdec/abc/gui/DecompiledEditorPane.java index 1d309a66e..b90d4430c 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/DecompiledEditorPane.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -31,7 +30,7 @@ import java.util.List; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; -public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseListener,CaretListener { +public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseListener, CaretListener { private List highlights = new ArrayList(); private List traitHighlights = new ArrayList(); @@ -40,24 +39,22 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL private int classIndex; public int lastTraitIndex = 0; - public void setNoTrait() - { + public void setNoTrait() { Main.abcMainFrame.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD); } - private boolean displayMethod(int pos,int methodIndex) - { + private boolean displayMethod(int pos, int methodIndex) { int bi = abc.findBodyIndex(methodIndex); if (bi == -1) { return false; } - Main.abcMainFrame.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD); + Main.abcMainFrame.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD); if (Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.bodyIndex != bi) { Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setBodyIndex(bi, abc); Main.abcMainFrame.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]); Main.abcMainFrame.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc); } - boolean success=false; + boolean success = false; for (Highlighting h : highlights) { if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { try { @@ -65,36 +62,36 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL } catch (ConvertException ex) { } - success=true; + success = true; //return true; } } return success; } - + public void caretUpdate(CaretEvent e) { getCaret().setVisible(true); int pos = getCaretPosition(); for (Highlighting tm : methodHighlights) { if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { - displayMethod(pos,(int)tm.offset); + displayMethod(pos, (int) tm.offset); return; } } for (Highlighting th : traitHighlights) { if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { lastTraitIndex = (int) th.offset; - Trait tr=abc.findTraitByTraitId(classIndex, (int) th.offset); - if(tr!=null){ - if(tr instanceof TraitSlotConst){ - Main.abcMainFrame.detailPanel.slotConstTraitPanel.load((TraitSlotConst)tr, abc); + Trait tr = abc.findTraitByTraitId(classIndex, (int) th.offset); + if (tr != null) { + if (tr instanceof TraitSlotConst) { + Main.abcMainFrame.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc); Main.abcMainFrame.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD); return; } } - displayMethod(pos,abc.findMethodIdByTraitId(classIndex, (int) th.offset)); + displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset)); return; - } + } } setNoTrait(); } @@ -106,7 +103,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL public List traitHighlights; public List methodHighlights; - public BufferedClass(String text, List highlights, List traitHighlights,List methodHighlights) { + public BufferedClass(String text, List highlights, List traitHighlights, List methodHighlights) { this.text = text; this.highlights = highlights; this.traitHighlights = traitHighlights; @@ -120,18 +117,16 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL } public void gotoTrait(int traitId) { - if(traitId==-1) - { + if (traitId == -1) { setCaretPosition(0); return; } for (Highlighting th : traitHighlights) { if (th.offset == traitId) { - try{ + try { setCaretPosition(th.startPos + th.len - 1); setCaretPosition(th.startPos); - }catch(IllegalArgumentException iae){ - + } catch (IllegalArgumentException iae) { } return; } @@ -156,13 +151,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL traitHighlights = Highlighting.getTraitHighlights(hilightedCode); methodHighlights = Highlighting.getMethodHighlights(hilightedCode); hilightedCode = Highlighting.stripHilights(hilightedCode); - bufferedClasses.put(index, new BufferedClass(hilightedCode, highlights, traitHighlights,methodHighlights)); + bufferedClasses.put(index, new BufferedClass(hilightedCode, highlights, traitHighlights, methodHighlights)); } else { BufferedClass bc = bufferedClasses.get(index); hilightedCode = bc.text; highlights = bc.highlights; traitHighlights = bc.traitHighlights; - methodHighlights=bc.methodHighlights; + methodHighlights = bc.methodHighlights; } setText(hilightedCode); this.abc = abc; @@ -187,8 +182,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL } public void mousePressed(MouseEvent e) { - - } public void mouseReleased(MouseEvent e) { diff --git a/trunk/src/com/jpexs/asdec/abc/gui/DetailPanel.java b/trunk/src/com/jpexs/asdec/abc/gui/DetailPanel.java index c4613d842..0fffc7a97 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/DetailPanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/DetailPanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -32,82 +31,78 @@ import javax.swing.border.BevelBorder; * @author JPEXS */ public class DetailPanel extends JPanel implements ActionListener { + public MethodTraitDetailPanel methodTraitPanel; public JPanel unsupportedTraitPanel; public SlotConstTraitDetailPanel slotConstTraitPanel; - public static final String METHOD_TRAIT_CARD="Method/Getter/Setter Trait"; - public static final String UNSUPPORTED_TRAIT_CARD="Unsupported Trait Type"; - public static final String SLOT_CONST_TRAIT_CARD="Slot/Const Trait"; + public static final String METHOD_TRAIT_CARD = "Method/Getter/Setter Trait"; + public static final String UNSUPPORTED_TRAIT_CARD = "Unsupported Trait Type"; + public static final String SLOT_CONST_TRAIT_CARD = "Slot/Const Trait"; private JPanel innerPanel; public JButton saveButton; - private HashMap cardMap=new HashMap(); + private HashMap cardMap = new HashMap(); private String selectedCard; private JLabel selectedLabel; - public DetailPanel() - { - innerPanel=new JPanel(); - CardLayout layout=new CardLayout(); + public DetailPanel() { + innerPanel = new JPanel(); + CardLayout layout = new CardLayout(); innerPanel.setLayout(layout); - methodTraitPanel=new MethodTraitDetailPanel(); + methodTraitPanel = new MethodTraitDetailPanel(); cardMap.put(METHOD_TRAIT_CARD, methodTraitPanel); - - unsupportedTraitPanel=new JPanel(new BorderLayout()); - JLabel unsup=new JLabel("Editing of this trait type is currently unsupported",SwingConstants.CENTER); - unsupportedTraitPanel.add(unsup,BorderLayout.CENTER); + + unsupportedTraitPanel = new JPanel(new BorderLayout()); + JLabel unsup = new JLabel("Editing of this trait type is currently unsupported", SwingConstants.CENTER); + unsupportedTraitPanel.add(unsup, BorderLayout.CENTER); cardMap.put(UNSUPPORTED_TRAIT_CARD, unsupportedTraitPanel); - slotConstTraitPanel=new SlotConstTraitDetailPanel(); - cardMap.put(SLOT_CONST_TRAIT_CARD,slotConstTraitPanel); + slotConstTraitPanel = new SlotConstTraitDetailPanel(); + cardMap.put(SLOT_CONST_TRAIT_CARD, slotConstTraitPanel); - for(String key:cardMap.keySet()) - { - innerPanel.add(cardMap.get(key),key); + for (String key : cardMap.keySet()) { + innerPanel.add(cardMap.get(key), key); } setLayout(new BorderLayout()); - add(innerPanel,BorderLayout.CENTER); + add(innerPanel, BorderLayout.CENTER); - JPanel buttonsPanel=new JPanel(); + JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new FlowLayout()); saveButton = new JButton("Save trait"); saveButton.setActionCommand("SAVEDETAIL"); saveButton.addActionListener(this); buttonsPanel.setBorder(new BevelBorder(BevelBorder.RAISED)); buttonsPanel.add(saveButton); - add(buttonsPanel,BorderLayout.SOUTH); - selectedCard=UNSUPPORTED_TRAIT_CARD; + add(buttonsPanel, BorderLayout.SOUTH); + selectedCard = UNSUPPORTED_TRAIT_CARD; layout.show(innerPanel, UNSUPPORTED_TRAIT_CARD); saveButton.setVisible(false); - selectedLabel=new JLabel(""); + selectedLabel = new JLabel(""); selectedLabel.setText(selectedCard); selectedLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); selectedLabel.setHorizontalAlignment(SwingConstants.CENTER); - add(selectedLabel,BorderLayout.NORTH); + add(selectedLabel, BorderLayout.NORTH); } - public void showCard(String name) - { - CardLayout layout=(CardLayout)innerPanel.getLayout(); + public void showCard(String name) { + CardLayout layout = (CardLayout) innerPanel.getLayout(); layout.show(innerPanel, name); saveButton.setVisible(cardMap.get(name) instanceof TraitDetail); - selectedCard=name; + selectedCard = name; selectedLabel.setText(selectedCard); } public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("SAVEDETAIL")) { - if(cardMap.get(selectedCard) instanceof TraitDetail) - { - if(((TraitDetail)cardMap.get(selectedCard)).save()) - { - int lasttrait = Main.abcMainFrame.decompiledTextArea.lastTraitIndex; - Main.abcMainFrame.decompiledTextArea.reloadClass(); - Main.abcMainFrame.decompiledTextArea.gotoTrait(lasttrait); - JOptionPane.showMessageDialog(this, "Trait Successfully saved"); - } + if (cardMap.get(selectedCard) instanceof TraitDetail) { + if (((TraitDetail) cardMap.get(selectedCard)).save()) { + int lasttrait = Main.abcMainFrame.decompiledTextArea.lastTraitIndex; + Main.abcMainFrame.decompiledTextArea.reloadClass(); + Main.abcMainFrame.decompiledTextArea.gotoTrait(lasttrait); + JOptionPane.showMessageDialog(this, "Trait Successfully saved"); } - } + } + } } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/DialogMissingSymbolHandler.java b/trunk/src/com/jpexs/asdec/abc/gui/DialogMissingSymbolHandler.java index 2d0cb162d..c9e8961c3 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/DialogMissingSymbolHandler.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/DialogMissingSymbolHandler.java @@ -14,29 +14,26 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.avm2.parser.MissingSymbolHandler; import javax.swing.JOptionPane; - public class DialogMissingSymbolHandler implements MissingSymbolHandler { - public boolean missingString(String value) { - return JOptionPane.showConfirmDialog(null, "String \"" + value + "\" is not present in constants table. Do you want to add it?", "Add String", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + public boolean missingString(String value) { + return JOptionPane.showConfirmDialog(null, "String \"" + value + "\" is not present in constants table. Do you want to add it?", "Add String", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } - public boolean missingInt(long value) { - return JOptionPane.showConfirmDialog(null, "Integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + public boolean missingInt(long value) { + return JOptionPane.showConfirmDialog(null, "Integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } - public boolean missingUInt(long value) { - return JOptionPane.showConfirmDialog(null, "Unsigned integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Unsigned integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } - - public boolean missingDouble(double value) { - return JOptionPane.showConfirmDialog(null, "Double value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Double", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + public boolean missingUInt(long value) { + return JOptionPane.showConfirmDialog(null, "Unsigned integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Unsigned integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } + public boolean missingDouble(double value) { + return JOptionPane.showConfirmDialog(null, "Double value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Double", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/GraphFrame.java b/trunk/src/com/jpexs/asdec/abc/gui/GraphFrame.java index 8f73a68b7..f413c3af2 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/GraphFrame.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/GraphFrame.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.avm2.flowgraph.Graph; @@ -33,89 +32,92 @@ import javax.swing.JScrollPane; */ public class GraphFrame extends JFrame { - private class GraphPanel extends JPanel { + private class GraphPanel extends JPanel { - private static final int SPACE_VERTICAL=10; - private static final int SPACE_HORIZONTAL=10; - private static final int BLOCK_WIDTH=100; - private static final int BLOCK_HEIGHT=20; + private static final int SPACE_VERTICAL = 10; + private static final int SPACE_HORIZONTAL = 10; + private static final int BLOCK_WIDTH = 100; + private static final int BLOCK_HEIGHT = 20; + private Graph graph; - private Graph graph; + public GraphPanel(Graph graph) { + this.graph = graph; + setPreferredSize(new Dimension((BLOCK_WIDTH + SPACE_HORIZONTAL) * getPartWidth(graph.head, new ArrayList()), (BLOCK_HEIGHT + SPACE_VERTICAL) * getPartHeight(graph.head, new ArrayList()))); + } - public GraphPanel(Graph graph) { - this.graph = graph; - setPreferredSize(new Dimension((BLOCK_WIDTH+SPACE_HORIZONTAL)*getPartWidth(graph.head, new ArrayList()), (BLOCK_HEIGHT+SPACE_VERTICAL)*getPartHeight(graph.head, new ArrayList()))); - } + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(Color.black); + paintPart(g, graph.head, 0, getPartWidth(graph.head, new ArrayList()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2, new ArrayList()); + } - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); - g.setColor(Color.black); - paintPart(g,graph.head,0,getPartWidth(graph.head,new ArrayList())*(BLOCK_WIDTH+SPACE_HORIZONTAL)/2,new ArrayList()); - } + private void paintPart(Graphics g, GraphPart part, int y, int x, List used) { + List l = new ArrayList(); + l.addAll(used); + int totalWidthParts = getPartWidth(part, l); + int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL); + g.drawRect(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2, y, BLOCK_WIDTH, BLOCK_HEIGHT); + g.drawString(part.toString(), x - BLOCK_WIDTH / 2, y + BLOCK_HEIGHT); + if (used.contains(part)) { + return; + } + used.add(part); + if (part.nextParts.size() > 0) { + int cx = x - totalWidth / 2; + for (int p = 0; p < part.nextParts.size(); p++) { + l = new ArrayList(); + l.addAll(used); + int cellWidth = getPartWidth(part.nextParts.get(p), l) * (BLOCK_WIDTH + SPACE_HORIZONTAL); + g.setColor(Color.black); + g.drawLine(x, y + BLOCK_HEIGHT, cx + cellWidth / 2, y + BLOCK_HEIGHT + SPACE_VERTICAL); + paintPart(g, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used); + cx += cellWidth; - private void paintPart(Graphics g,GraphPart part,int y,int x,List used){ - List l=new ArrayList(); - l.addAll(used); - int totalWidthParts=getPartWidth(part,l); - int totalWidth=totalWidthParts*(BLOCK_WIDTH+SPACE_HORIZONTAL); - g.drawRect(x-BLOCK_WIDTH/2-SPACE_HORIZONTAL/2, y, BLOCK_WIDTH, BLOCK_HEIGHT); - g.drawString(part.toString(), x-BLOCK_WIDTH/2, y+BLOCK_HEIGHT); - if(used.contains(part)) return; - used.add(part); - if(part.nextParts.size()>0){ - int cx=x-totalWidth/2; - for(int p=0;p(); - l.addAll(used); - int cellWidth=getPartWidth(part.nextParts.get(p),l)*(BLOCK_WIDTH+SPACE_HORIZONTAL); - g.setColor(Color.black); - g.drawLine(x, y+BLOCK_HEIGHT, cx+cellWidth/2, y+BLOCK_HEIGHT+SPACE_VERTICAL); - paintPart(g,part.nextParts.get(p),y+BLOCK_HEIGHT+SPACE_VERTICAL,cx+cellWidth/2,used); - cx+=cellWidth; - - } } + } - } + } - private int getPartHeight(GraphPart part,List used){ - if (used.contains(part)) { - return 1; - } - used.add(part); - int maxH=0; - for(int p=0;pmaxH) maxH=h; - } - return 1+maxH; - } - - private int getPartWidth(GraphPart part, List used) { - - if (used.contains(part)) { - return 1; + private int getPartHeight(GraphPart part, List used) { + if (used.contains(part)) { + return 1; + } + used.add(part); + int maxH = 0; + for (int p = 0; p < part.nextParts.size(); p++) { + int h = getPartHeight(part.nextParts.get(p), used); + if (h > maxH) { + maxH = h; } - used.add(part); - if (part.nextParts.size() == 0) { - return 1; - } - int w = 0; - for (GraphPart subpart : part.nextParts) { - w += getPartWidth(subpart, used); - } - return w; - } - } + } + return 1 + maxH; + } - public GraphFrame(Graph graph,String name) { - setSize(500, 500); - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - cnt.add(new JScrollPane(new GraphPanel(graph))); - setTitle("Graph "+name); - View.setWindowIcon(this); - View.centerScreen(this); - } + private int getPartWidth(GraphPart part, List used) { + + if (used.contains(part)) { + return 1; + } + used.add(part); + if (part.nextParts.size() == 0) { + return 1; + } + int w = 0; + for (GraphPart subpart : part.nextParts) { + w += getPartWidth(subpart, used); + } + return w; + } + } + + public GraphFrame(Graph graph, String name) { + setSize(500, 500); + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + cnt.add(new JScrollPane(new GraphPanel(graph))); + setTitle("Graph " + name); + View.setWindowIcon(this); + View.centerScreen(this); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/GraphTreeFrame.java b/trunk/src/com/jpexs/asdec/abc/gui/GraphTreeFrame.java index 6d90712c8..10d663c9b 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/GraphTreeFrame.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/GraphTreeFrame.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.avm2.flowgraph.Graph; @@ -32,48 +31,44 @@ import javax.swing.tree.TreePath; * @author JPEXS */ public class GraphTreeFrame extends JFrame { - public JTree graphTree; + public JTree graphTree; + public GraphTreeFrame(final Graph graph) { + setSize(400, 400); + graphTree = new JTree(new TreeModel() { + public Object getRoot() { + return graph.head; + } - public GraphTreeFrame(final Graph graph){ - setSize(400,400); - graphTree=new JTree(new TreeModel(){ - public Object getRoot() { - return graph.head; - } + public Object getChild(Object parent, int index) { + return ((GraphPart) parent).nextParts.get(index); + } - public Object getChild(Object parent, int index) { - return ((GraphPart)parent).nextParts.get(index); - } + public int getChildCount(Object parent) { + return ((GraphPart) parent).nextParts.size(); + } - public int getChildCount(Object parent) { - return ((GraphPart)parent).nextParts.size(); - } + public boolean isLeaf(Object node) { + return getChildCount(node) == 0; + } - public boolean isLeaf(Object node) { - return getChildCount(node)==0; - } + public void valueForPathChanged(TreePath path, Object newValue) { + } - public void valueForPathChanged(TreePath path, Object newValue) { + public int getIndexOfChild(Object parent, Object child) { + return ((GraphPart) parent).nextParts.indexOf(child); + } - } + public void addTreeModelListener(TreeModelListener l) { + } - public int getIndexOfChild(Object parent, Object child) { - return ((GraphPart)parent).nextParts.indexOf(child); - } + public void removeTreeModelListener(TreeModelListener l) { + } + }); - public void addTreeModelListener(TreeModelListener l) { - - } - - public void removeTreeModelListener(TreeModelListener l) { - - } - }); - - Container cnt=getContentPane(); - cnt.setLayout(new BorderLayout()); - cnt.add(graphTree,BorderLayout.CENTER); - } + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + cnt.add(graphTree, BorderLayout.CENTER); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/IconListRenderer.java b/trunk/src/com/jpexs/asdec/abc/gui/IconListRenderer.java index 507b070e3..049049eaa 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/IconListRenderer.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/IconListRenderer.java @@ -14,59 +14,60 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import java.awt.Component; import javax.swing.*; - public class IconListRenderer extends DefaultListCellRenderer { - private Icon constIcon; - private Icon functionIcon; - private Icon variableIcon; + private Icon constIcon; + private Icon functionIcon; + private Icon variableIcon; - private Icon loadIcon(String path) { - ClassLoader cldr = this.getClass().getClassLoader(); - java.net.URL imageURL = cldr.getResource(path); - return new ImageIcon(imageURL); - } + private Icon loadIcon(String path) { + ClassLoader cldr = this.getClass().getClassLoader(); + java.net.URL imageURL = cldr.getResource(path); + return new ImageIcon(imageURL); + } - public IconListRenderer() { - constIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/constant.png"); - functionIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/function.png"); - variableIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/variable.png"); - } + public IconListRenderer() { + constIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/constant.png"); + functionIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/function.png"); + variableIcon = loadIcon("com/jpexs/asdec/abc/gui/graphics/variable.png"); + } - @Override - public Component getListCellRendererComponent( - JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) { + @Override + public Component getListCellRendererComponent( + JList list, Object value, int index, + boolean isSelected, boolean cellHasFocus) { - // Get the renderer component from parent class + // Get the renderer component from parent class - JLabel label = - (JLabel) super.getListCellRendererComponent(list, - value, index, isSelected, cellHasFocus); + JLabel label = + (JLabel) super.getListCellRendererComponent(list, + value, index, isSelected, cellHasFocus); - // Get icon to use for the list item value + // Get icon to use for the list item value - String modifiersRegex = "(public |static |final |override |private |protected |package )*"; - - if (value.toString().matches(modifiersRegex + "const .*")) - label.setIcon(constIcon); - if (value.toString().matches(modifiersRegex + "var .*")) - label.setIcon(variableIcon); - if (value.toString().matches(modifiersRegex + "function .*")) - label.setIcon(functionIcon); - if (value.toString().equals(TraitsListModel.STR_CLASS_INITIALIZER)) - label.setIcon(functionIcon); - if (value.toString().equals(TraitsListModel.STR_INSTANCE_INITIALIZER)) - label.setIcon(functionIcon); - return label; - } + String modifiersRegex = "(public |static |final |override |private |protected |package )*"; + if (value.toString().matches(modifiersRegex + "const .*")) { + label.setIcon(constIcon); + } + if (value.toString().matches(modifiersRegex + "var .*")) { + label.setIcon(variableIcon); + } + if (value.toString().matches(modifiersRegex + "function .*")) { + label.setIcon(functionIcon); + } + if (value.toString().equals(TraitsListModel.STR_CLASS_INITIALIZER)) { + label.setIcon(functionIcon); + } + if (value.toString().equals(TraitsListModel.STR_INSTANCE_INITIALIZER)) { + label.setIcon(functionIcon); + } + return label; + } } - diff --git a/trunk/src/com/jpexs/asdec/abc/gui/LineMarkedEditorPane.java b/trunk/src/com/jpexs/asdec/abc/gui/LineMarkedEditorPane.java index 0b10e1a53..ab0ee75d0 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/LineMarkedEditorPane.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/LineMarkedEditorPane.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import java.awt.Color; @@ -31,36 +30,35 @@ import javax.swing.text.Element; */ public class LineMarkedEditorPane extends JEditorPane { - int lastLine=-1; - public LineMarkedEditorPane() { - setOpaque(false); - addCaretListener(new CaretListener(){ + int lastLine = -1; + public LineMarkedEditorPane() { + setOpaque(false); + addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { int caretPosition = getCaretPosition(); Element root = getDocument().getDefaultRootElement(); int currentLine = root.getElementIndex(caretPosition); - if(currentLine!=lastLine){ - lastLine=currentLine; - repaint(); + if (currentLine != lastLine) { + lastLine = currentLine; + repaint(); } } - - }); - } + }); + } @Override public void paint(Graphics g) { g.setColor(Color.white); - g.fillRect(0, 0, getWidth(),getHeight()); + g.fillRect(0, 0, getWidth(), getHeight()); FontMetrics fontMetrics = g.getFontMetrics(); int lh = fontMetrics.getHeight(); - int a = fontMetrics.getAscent(); - int d=fontMetrics.getDescent(); - int h = a + d; - int rH = h; - g.setColor(new Color(0xee,0xee,0xee)); - g.fillRect(0, d+lh*lastLine-1, getWidth(),lh); + int a = fontMetrics.getAscent(); + int d = fontMetrics.getDescent(); + int h = a + d; + int rH = h; + g.setColor(new Color(0xee, 0xee, 0xee)); + g.fillRect(0, d + lh * lastLine - 1, getWidth(), lh); super.paint(g); } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java b/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java index 1189bef2a..1d3f13c46 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MainFrame.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Configuration; @@ -35,436 +34,435 @@ import javax.swing.border.BevelBorder; import javax.swing.table.*; import jsyntaxpane.DefaultSyntaxKit; - public class MainFrame extends JFrame implements ActionListener, ItemListener { - - public TraitsList navigator; - public ClassesListTree classTree; - public ABC abc; - public List list; - public JComboBox abcComboBox; - public int listIndex = 0; - public DecompiledEditorPane decompiledTextArea; - public JScrollPane decompiledScrollPane; - public JSplitPane splitPane1; - public JSplitPane splitPane2; - public JSplitPane splitPane3; - //private ConstantsListModel constantListModel; - private JTable constantTable; - //private JList constantsList; - public JComboBox constantTypeList; - public JPanel statusPanel = new JPanel(); - public LoadingPanel loadingPanel = new LoadingPanel(20, 20); - public JLabel statusLabel = new JLabel(""); - public JLabel asmLabel = new JLabel("P-code source (editable)"); - public JLabel decLabel = new JLabel("ActionScript source"); - public DetailPanel detailPanel; + public TraitsList navigator; + public ClassesListTree classTree; + public ABC abc; + public List list; + public JComboBox abcComboBox; + public int listIndex = 0; + public DecompiledEditorPane decompiledTextArea; + public JScrollPane decompiledScrollPane; + public JSplitPane splitPane1; + public JSplitPane splitPane2; + public JSplitPane splitPane3; + //private ConstantsListModel constantListModel; + private JTable constantTable; + //private JList constantsList; + public JComboBox constantTypeList; + public JPanel statusPanel = new JPanel(); + public LoadingPanel loadingPanel = new LoadingPanel(20, 20); + public JLabel statusLabel = new JLabel(""); + public JLabel asmLabel = new JLabel("P-code source (editable)"); + public JLabel decLabel = new JLabel("ActionScript source"); + public DetailPanel detailPanel; + + public void setStatus(String s) { + if (s.equals("")) { + loadingPanel.setVisible(false); + } else { + loadingPanel.setVisible(true); + } + statusLabel.setText(s); + } + + public JTable autoResizeColWidth(JTable table, TableModel model) { + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.setModel(model); + + int margin = 5; + + for (int i = 0; i < table.getColumnCount(); i++) { + int vColIndex = i; + DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel(); + TableColumn col = colModel.getColumn(vColIndex); + int width = 0; + + // Get width of column header + TableCellRenderer renderer = col.getHeaderRenderer(); + + if (renderer == null) { + renderer = table.getTableHeader().getDefaultRenderer(); + } + + Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); + + width = comp.getPreferredSize().width; + + // Get maximum width of column data + for (int r = 0; r < table.getRowCount(); r++) { + renderer = table.getCellRenderer(r, vColIndex); + comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false, + r, vColIndex); + width = Math.max(width, comp.getPreferredSize().width); + } + + // Add margin + width += 2 * margin; + + // Set the width + col.setPreferredWidth(width); + } + + ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment( + SwingConstants.LEFT); + + // table.setAutoCreateRowSorter(true); + table.getTableHeader().setReorderingAllowed(false); + + return table; + } + + public void updateConstList() { + switch (constantTypeList.getSelectedIndex()) { + case 0: + autoResizeColWidth(constantTable, new UIntTableModel(abc)); + break; + case 1: + autoResizeColWidth(constantTable, new IntTableModel(abc)); + break; + case 2: + autoResizeColWidth(constantTable, new DoubleTableModel(abc)); + break; + case 3: + autoResizeColWidth(constantTable, new DecimalTableModel(abc)); + break; + case 4: + autoResizeColWidth(constantTable, new StringTableModel(abc)); + break; + case 5: + autoResizeColWidth(constantTable, new NamespaceTableModel(abc)); + break; + case 6: + autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc)); + break; + case 7: + autoResizeColWidth(constantTable, new MultinameTableModel(abc)); + break; + } + //DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel(); + //colModel.getColumn(0).setMaxWidth(50); + } + + public void switchAbc(int index) { + listIndex = index; + this.abc = list.get(listIndex).abc; + classTree.setABC(abc); + decompiledTextArea.setABC(abc); + navigator.setABC(abc); + //constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); + updateConstList(); + + } + + public MainFrame(List list) { + + View.setWindowIcon(this); + + DefaultSyntaxKit.initKit(); + + this.list = list; + setSize(1024, 600); + this.abc = list.get(listIndex).abc; + getContentPane().setLayout(new BorderLayout()); - public void setStatus(String s) { - if (s.equals("")) { - loadingPanel.setVisible(false); - } else { - loadingPanel.setVisible(true); - } - statusLabel.setText(s); - } - public JTable autoResizeColWidth(JTable table, TableModel model) { - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - table.setModel(model); - - int margin = 5; - - for (int i = 0; i < table.getColumnCount(); i++) { - int vColIndex = i; - DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel(); - TableColumn col = colModel.getColumn(vColIndex); - int width = 0; - - // Get width of column header - TableCellRenderer renderer = col.getHeaderRenderer(); - - if (renderer == null) { - renderer = table.getTableHeader().getDefaultRenderer(); - } - - Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); - - width = comp.getPreferredSize().width; - - // Get maximum width of column data - for (int r = 0; r < table.getRowCount(); r++) { - renderer = table.getCellRenderer(r, vColIndex); - comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false, - r, vColIndex); - width = Math.max(width, comp.getPreferredSize().width); - } - - // Add margin - width += 2 * margin; - - // Set the width - col.setPreferredWidth(width); - } - - ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment( - SwingConstants.LEFT); - - // table.setAutoCreateRowSorter(true); - table.getTableHeader().setReorderingAllowed(false); - - return table; - } - - public void updateConstList() { - switch (constantTypeList.getSelectedIndex()) { - case 0: - autoResizeColWidth(constantTable, new UIntTableModel(abc)); - break; - case 1: - autoResizeColWidth(constantTable, new IntTableModel(abc)); - break; - case 2: - autoResizeColWidth(constantTable, new DoubleTableModel(abc)); - break; - case 3: - autoResizeColWidth(constantTable, new DecimalTableModel(abc)); - break; - case 4: - autoResizeColWidth(constantTable, new StringTableModel(abc)); - break; - case 5: - autoResizeColWidth(constantTable, new NamespaceTableModel(abc)); - break; - case 6: - autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc)); - break; - case 7: - autoResizeColWidth(constantTable, new MultinameTableModel(abc)); - break; - } - //DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel(); - //colModel.getColumn(0).setMaxWidth(50); - } - - public void switchAbc(int index) { - listIndex = index; - this.abc = list.get(listIndex).abc; - classTree.setABC(abc); - decompiledTextArea.setABC(abc); - navigator.setABC(abc); - //constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); - updateConstList(); - - } - public MainFrame(List list) { - View.setWindowIcon(this); + decompiledTextArea = new DecompiledEditorPane(); - DefaultSyntaxKit.initKit(); + decompiledScrollPane = new JScrollPane(decompiledTextArea); - this.list = list; - setSize(1024, 600); - this.abc = list.get(listIndex).abc; - getContentPane().setLayout(new BorderLayout()); - + detailPanel = new DetailPanel(); + JPanel panB = new JPanel(); + panB.setLayout(new BorderLayout()); + panB.add(decompiledScrollPane, BorderLayout.CENTER); + panB.add(decLabel, BorderLayout.NORTH); + decLabel.setHorizontalAlignment(SwingConstants.CENTER); + decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + panB, detailPanel); + decompiledTextArea.setContentType("text/actionscript"); - - + JPanel pan2 = new JPanel(); + pan2.setLayout(new BorderLayout()); + pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH); - - - decompiledTextArea = new DecompiledEditorPane(); - - decompiledScrollPane = new JScrollPane(decompiledTextArea); - - detailPanel=new DetailPanel(); - JPanel panB = new JPanel(); - panB.setLayout(new BorderLayout()); - panB.add(decompiledScrollPane, BorderLayout.CENTER); - panB.add(decLabel, BorderLayout.NORTH); - decLabel.setHorizontalAlignment(SwingConstants.CENTER); - decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - panB, detailPanel); - decompiledTextArea.setContentType("text/actionscript"); - - JPanel pan2 = new JPanel(); - pan2.setLayout(new BorderLayout()); - pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH); - - navigator = new TraitsList(); - navigator.setABC(abc); - - - JPanel navPanel=new JPanel(new BorderLayout()); - JLabel traitsLabel=new JLabel("Traits"); - navPanel.add(traitsLabel,BorderLayout.NORTH); - - traitsLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - navPanel.add(new JScrollPane(navigator),BorderLayout.CENTER); - - splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, - new JScrollPane(classTree = new ClassesListTree(abc)), - navPanel); - - JTabbedPane tabbedPane = new JTabbedPane(); - tabbedPane.addTab("Classes", splitPane2); - - pan2.add(tabbedPane, BorderLayout.CENTER); - abcComboBox.addItemListener(this); + navigator = new TraitsList(); + navigator.setABC(abc); - splitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - pan2, - splitPane1); + JPanel navPanel = new JPanel(new BorderLayout()); + JLabel traitsLabel = new JLabel("Traits"); + navPanel.add(traitsLabel, BorderLayout.NORTH); - pan2.setPreferredSize(new Dimension(300, 200)); + traitsLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER); + + splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + new JScrollPane(classTree = new ClassesListTree(abc)), + navPanel); + + JTabbedPane tabbedPane = new JTabbedPane(); + tabbedPane.addTab("Classes", splitPane2); + + pan2.add(tabbedPane, BorderLayout.CENTER); + abcComboBox.addItemListener(this); - loadingPanel.setPreferredSize(new Dimension(30, 30)); - statusPanel = new JPanel(); - statusPanel.setPreferredSize(new Dimension(1, 30)); - statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); - statusPanel.setLayout(new BorderLayout()); - statusPanel.add(loadingPanel, BorderLayout.WEST); - statusPanel.add(statusLabel, BorderLayout.CENTER); - loadingPanel.setVisible(false); + splitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + pan2, + splitPane1); + + pan2.setPreferredSize(new Dimension(300, 200)); - getContentPane().add(splitPane3, BorderLayout.CENTER); - getContentPane().add(statusPanel, BorderLayout.SOUTH); - addWindowListener(new WindowAdapter() { + loadingPanel.setPreferredSize(new Dimension(30, 30)); + statusPanel = new JPanel(); + statusPanel.setPreferredSize(new Dimension(1, 30)); + statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); + statusPanel.setLayout(new BorderLayout()); + statusPanel.add(loadingPanel, BorderLayout.WEST); + statusPanel.add(statusLabel, BorderLayout.CENTER); + loadingPanel.setVisible(false); - @Override - public void windowClosing(WindowEvent e) { - if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) return; - } - Main.exit(); - } - }); - setTitle(Main.applicationName + " - " + Main.getFileTitle()); - JMenuBar menuBar = new JMenuBar(); - - JMenu menuFile = new JMenu("File"); - JMenuItem miOpen = new JMenuItem("Open..."); - miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png"))); - miOpen.setActionCommand("OPEN"); - miOpen.addActionListener(this); - JMenuItem miSave = new JMenuItem("Save"); - miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); - miSave.setActionCommand("SAVE"); - miSave.addActionListener(this); - JMenuItem miSaveAs = new JMenuItem("Save as..."); - miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); - miSaveAs.setActionCommand("SAVEAS"); - miSaveAs.addActionListener(this); - JMenuItem miExport = new JMenuItem("Export as ActionScript..."); - miExport.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png"))); - miExport.setActionCommand("EXPORT"); - miExport.addActionListener(this); - - JMenuItem miExportPCode = new JMenuItem("Export as PCode..."); - miExportPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png"))); - miExportPCode.setActionCommand("EXPORTPCODE"); - miExportPCode.addActionListener(this); - menuFile.add(miOpen); - menuFile.add(miSave); - menuFile.add(miSaveAs); - menuFile.add(miExport); - menuFile.add(miExportPCode); - menuFile.addSeparator(); - JMenuItem miClose = new JMenuItem("Exit"); - miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png"))); - miClose.setActionCommand("EXIT"); - miClose.addActionListener(this); - menuFile.add(miClose); - menuBar.add(menuFile); - - JMenu menuDeobfuscation = new JMenu("Deobfuscation"); - JCheckBoxMenuItem miSubLimiter = new JCheckBoxMenuItem ("Enable sub limiter"); - miSubLimiter.setActionCommand("SUBLIMITER"); - miSubLimiter.addActionListener(this); - - JMenuItem miRenameIdentifiers=new JMenuItem("Rename identifiers"); - miRenameIdentifiers.setActionCommand("RENAMEIDENTIFIERS"); - miRenameIdentifiers.addActionListener(this); - - - menuDeobfuscation.add(miSubLimiter); - menuDeobfuscation.add(miRenameIdentifiers); - - - //menuBar.add(menuOptions); - - JMenu menuTools = new JMenu("Tools"); - JMenuItem miProxy = new JMenuItem("Proxy"); - miProxy.setActionCommand("SHOWPROXY"); - miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"))); - miProxy.addActionListener(this); - menuTools.add(miProxy); - - menuTools.add(menuDeobfuscation); - menuBar.add(menuTools); - - JMenu menuHelp = new JMenu("Help"); - JMenuItem miAbout = new JMenuItem("About..."); - miAbout.setActionCommand("ABOUT"); - miAbout.addActionListener(this); - menuHelp.add(miAbout); - menuBar.add(menuHelp); - - setJMenuBar(menuBar); - - /* Constants */ - JPanel panConstants = new JPanel(); - panConstants.setLayout(new BorderLayout()); - constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE","DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); - constantTable = new JTable(); - autoResizeColWidth(constantTable, new UIntTableModel(abc)); - constantTable.setAutoCreateRowSorter(true); - constantTable.addMouseListener(new MouseAdapter(){ - - @Override - public void mouseClicked(MouseEvent e) { - if(e.getClickCount()==2){ - if(constantTypeList.getSelectedIndex()==7){ //MULTINAME - int rowIndex=constantTable.getSelectedRow(); - if(rowIndex==-1) return; - int multinameIndex=constantTable.convertRowIndexToModel(rowIndex); - if(multinameIndex>0){ - UsageFrame usageFrame=new UsageFrame(abc, multinameIndex); - usageFrame.setVisible(true); - } - } - } - } - - }); - constantTypeList.addItemListener(this); - panConstants.add(constantTypeList, BorderLayout.NORTH); - panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER); - tabbedPane.addTab("Constants", panConstants); - View.centerScreen(this); - - } - - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("EXIT")) { - setVisible(false); + getContentPane().add(splitPane3, BorderLayout.CENTER); + getContentPane().add(statusPanel, BorderLayout.SOUTH); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) return; + if (Main.proxyFrame.isVisible()) { + return; + } } Main.exit(); - } - if (Main.isWorking()) return; + } + }); + setTitle(Main.applicationName + " - " + Main.getFileTitle()); - if (e.getActionCommand().equals("ABOUT")) { - Main.about(); - } - + JMenuBar menuBar = new JMenuBar(); - if (e.getActionCommand().equals("SHOWPROXY")) { - Main.showProxy(); - } - - if (e.getActionCommand().equals("SUBLIMITER")) { - if(e.getSource() instanceof JCheckBoxMenuItem){ - Main.setSubLimiter(((JCheckBoxMenuItem)e.getSource()).getState()); + JMenu menuFile = new JMenu("File"); + JMenuItem miOpen = new JMenuItem("Open..."); + miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png"))); + miOpen.setActionCommand("OPEN"); + miOpen.addActionListener(this); + JMenuItem miSave = new JMenuItem("Save"); + miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); + miSave.setActionCommand("SAVE"); + miSave.addActionListener(this); + JMenuItem miSaveAs = new JMenuItem("Save as..."); + miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); + miSaveAs.setActionCommand("SAVEAS"); + miSaveAs.addActionListener(this); + JMenuItem miExport = new JMenuItem("Export as ActionScript..."); + miExport.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png"))); + miExport.setActionCommand("EXPORT"); + miExport.addActionListener(this); + + JMenuItem miExportPCode = new JMenuItem("Export as PCode..."); + miExportPCode.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportpc16.png"))); + miExportPCode.setActionCommand("EXPORTPCODE"); + miExportPCode.addActionListener(this); + menuFile.add(miOpen); + menuFile.add(miSave); + menuFile.add(miSaveAs); + menuFile.add(miExport); + menuFile.add(miExportPCode); + menuFile.addSeparator(); + JMenuItem miClose = new JMenuItem("Exit"); + miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png"))); + miClose.setActionCommand("EXIT"); + miClose.addActionListener(this); + menuFile.add(miClose); + menuBar.add(menuFile); + + JMenu menuDeobfuscation = new JMenu("Deobfuscation"); + JCheckBoxMenuItem miSubLimiter = new JCheckBoxMenuItem("Enable sub limiter"); + miSubLimiter.setActionCommand("SUBLIMITER"); + miSubLimiter.addActionListener(this); + + JMenuItem miRenameIdentifiers = new JMenuItem("Rename identifiers"); + miRenameIdentifiers.setActionCommand("RENAMEIDENTIFIERS"); + miRenameIdentifiers.addActionListener(this); + + + menuDeobfuscation.add(miSubLimiter); + menuDeobfuscation.add(miRenameIdentifiers); + + + //menuBar.add(menuOptions); + + JMenu menuTools = new JMenu("Tools"); + JMenuItem miProxy = new JMenuItem("Proxy"); + miProxy.setActionCommand("SHOWPROXY"); + miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"))); + miProxy.addActionListener(this); + menuTools.add(miProxy); + + menuTools.add(menuDeobfuscation); + menuBar.add(menuTools); + + JMenu menuHelp = new JMenu("Help"); + JMenuItem miAbout = new JMenuItem("About..."); + miAbout.setActionCommand("ABOUT"); + miAbout.addActionListener(this); + menuHelp.add(miAbout); + menuBar.add(menuHelp); + + setJMenuBar(menuBar); + + /* Constants */ + JPanel panConstants = new JPanel(); + panConstants.setLayout(new BorderLayout()); + constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); + constantTable = new JTable(); + autoResizeColWidth(constantTable, new UIntTableModel(abc)); + constantTable.setAutoCreateRowSorter(true); + constantTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + if (constantTypeList.getSelectedIndex() == 7) { //MULTINAME + int rowIndex = constantTable.getSelectedRow(); + if (rowIndex == -1) { + return; + } + int multinameIndex = constantTable.convertRowIndexToModel(rowIndex); + if (multinameIndex > 0) { + UsageFrame usageFrame = new UsageFrame(abc, multinameIndex); + usageFrame.setVisible(true); + } + } } - - } - - if (e.getActionCommand().equals("SAVE")) { - try { - Main.saveFile(Main.file); - } catch (IOException ex) { - ex.printStackTrace(); + } + }); + constantTypeList.addItemListener(this); + panConstants.add(constantTypeList, BorderLayout.NORTH); + panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER); + tabbedPane.addTab("Constants", panConstants); + View.centerScreen(this); + + } + + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("EXIT")) { + setVisible(false); + if (Main.proxyFrame != null) { + if (Main.proxyFrame.isVisible()) { + return; } - } - if (e.getActionCommand().equals("SAVEAS")) { - if (Main.saveFileDialog()) { - setTitle(Main.applicationName + " - " + Main.getFileTitle()); - } - } - if (e.getActionCommand().equals("OPEN")) { - Main.openFileDialog(); + } + Main.exit(); + } + if (Main.isWorking()) { + return; + } - } + if (e.getActionCommand().equals("ABOUT")) { + Main.about(); + } - if (e.getActionCommand().equals("EXPORT")||e.getActionCommand().equals("EXPORTPCODE")) { - JFileChooser chooser = new JFileChooser(); - chooser.setCurrentDirectory(new java.io.File((String)Configuration.getConfig("lastExportDir", "."))); - chooser.setDialogTitle("Select directory to export"); - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - chooser.setAcceptAllFileFilterUsed(false); - if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - Main.startWork("Exporting..."); - final String selFile = chooser.getSelectedFile().getAbsolutePath(); - Configuration.setConfig("lastExportDir", chooser.getSelectedFile().getParentFile().getAbsolutePath()); - final boolean isPcode=e.getActionCommand().equals("EXPORTPCODE"); - (new Thread() { - @Override - public void run() { - try { - for (DoABCTag tag : list) { - tag.abc.export(selFile,isPcode); - } - } catch (IOException ignored) { - JOptionPane.showMessageDialog(null, "Cannot write to the file"); - } - Main.stopWork(); - } - }).start(); + if (e.getActionCommand().equals("SHOWPROXY")) { + Main.showProxy(); + } - } + if (e.getActionCommand().equals("SUBLIMITER")) { + if (e.getSource() instanceof JCheckBoxMenuItem) { + Main.setSubLimiter(((JCheckBoxMenuItem) e.getSource()).getState()); + } - } - if(e.getActionCommand().equals("RENAMEIDENTIFIERS")){ - int pocet=0; - Main.startWork("Renaming identifiers..."); - for (DoABCTag tag : list) { - pocet+=tag.abc.deobfuscateIdentifiers(); - } - JOptionPane.showMessageDialog(null, "Identifiers renamed: "+pocet); - reload(); - Main.stopWork(); - } - - } - - public void reload(){ - switchAbc(listIndex); - } + } - public void itemStateChanged(ItemEvent e) { - if (e.getSource() == abcComboBox) { - int index = ((JComboBox) e.getSource()).getSelectedIndex(); - if (index == -1) { - return; - } - switchAbc(index); - } - if (e.getSource() == constantTypeList) { - int index = ((JComboBox) e.getSource()).getSelectedIndex(); - if (index == -1) { - return; - } - updateConstList(); - } - } + if (e.getActionCommand().equals("SAVE")) { + try { + Main.saveFile(Main.file); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + if (e.getActionCommand().equals("SAVEAS")) { + if (Main.saveFileDialog()) { + setTitle(Main.applicationName + " - " + Main.getFileTitle()); + } + } + if (e.getActionCommand().equals("OPEN")) { + Main.openFileDialog(); - public void display() { - setVisible(true); - splitPane2.setDividerLocation(0.5); - splitPane1.setDividerLocation(0.5); - } + } + + if (e.getActionCommand().equals("EXPORT") || e.getActionCommand().equals("EXPORTPCODE")) { + JFileChooser chooser = new JFileChooser(); + chooser.setCurrentDirectory(new java.io.File((String) Configuration.getConfig("lastExportDir", "."))); + chooser.setDialogTitle("Select directory to export"); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setAcceptAllFileFilterUsed(false); + if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { + Main.startWork("Exporting..."); + final String selFile = chooser.getSelectedFile().getAbsolutePath(); + Configuration.setConfig("lastExportDir", chooser.getSelectedFile().getParentFile().getAbsolutePath()); + final boolean isPcode = e.getActionCommand().equals("EXPORTPCODE"); + (new Thread() { + @Override + public void run() { + try { + for (DoABCTag tag : list) { + tag.abc.export(selFile, isPcode); + } + } catch (IOException ignored) { + JOptionPane.showMessageDialog(null, "Cannot write to the file"); + } + Main.stopWork(); + } + }).start(); + + } + + } + if (e.getActionCommand().equals("RENAMEIDENTIFIERS")) { + int pocet = 0; + Main.startWork("Renaming identifiers..."); + for (DoABCTag tag : list) { + pocet += tag.abc.deobfuscateIdentifiers(); + } + JOptionPane.showMessageDialog(null, "Identifiers renamed: " + pocet); + reload(); + Main.stopWork(); + } + + } + + public void reload() { + switchAbc(listIndex); + } + + public void itemStateChanged(ItemEvent e) { + if (e.getSource() == abcComboBox) { + int index = ((JComboBox) e.getSource()).getSelectedIndex(); + if (index == -1) { + return; + } + switchAbc(index); + } + if (e.getSource() == constantTypeList) { + int index = ((JComboBox) e.getSource()).getSelectedIndex(); + if (index == -1) { + return; + } + updateConstList(); + } + } + + public void display() { + setVisible(true); + splitPane2.setDividerLocation(0.5); + splitPane1.setDividerLocation(0.5); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MethodBodyParamsPanel.java b/trunk/src/com/jpexs/asdec/abc/gui/MethodBodyParamsPanel.java index 2fa16d2ed..b8953b094 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MethodBodyParamsPanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MethodBodyParamsPanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -30,51 +29,52 @@ import javax.swing.event.ChangeListener; * * @author JPEXS */ -public class MethodBodyParamsPanel extends JPanel implements ChangeListener{ +public class MethodBodyParamsPanel extends JPanel implements ChangeListener { - public JLabel maxStackLabel = new JLabel("Max stack:",SwingConstants.RIGHT); + public JLabel maxStackLabel = new JLabel("Max stack:", SwingConstants.RIGHT); public JFormattedTextField maxStackField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel localCountLabel = new JLabel("Local registers count:",SwingConstants.RIGHT); + public JLabel localCountLabel = new JLabel("Local registers count:", SwingConstants.RIGHT); public JFormattedTextField localCountField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel initScopeDepthLabel = new JLabel("Minimum scope depth:",SwingConstants.RIGHT); + public JLabel initScopeDepthLabel = new JLabel("Minimum scope depth:", SwingConstants.RIGHT); public JFormattedTextField initScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel maxScopeDepthLabel = new JLabel("Maximum scope depth:",SwingConstants.RIGHT); + public JLabel maxScopeDepthLabel = new JLabel("Maximum scope depth:", SwingConstants.RIGHT); public JFormattedTextField maxScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); public MethodBody body; - public JCheckBox autoFillCheckBox=new JCheckBox("Auto fill on code save (GLOBAL SETTING)"); - public JLabel experimentalLabel=new JLabel("...EXPERIMENTAL"); - public MethodBodyParamsPanel() { + public JCheckBox autoFillCheckBox = new JCheckBox("Auto fill on code save (GLOBAL SETTING)"); + public JLabel experimentalLabel = new JLabel("...EXPERIMENTAL"); + + public MethodBodyParamsPanel() { setLayout(null); maxStackLabel.setBounds(10, 10, 150, 25); - maxStackField.setBounds(10+150+10, 10, 75, 25); + maxStackField.setBounds(10 + 150 + 10, 10, 75, 25); add(maxStackLabel); add(maxStackField); - localCountLabel.setBounds(10, 10+30, 150, 25); - localCountField.setBounds(10+150+10, 10+30, 75, 25); + localCountLabel.setBounds(10, 10 + 30, 150, 25); + localCountField.setBounds(10 + 150 + 10, 10 + 30, 75, 25); add(localCountLabel); add(localCountField); - initScopeDepthLabel.setBounds(10, 10+30+30, 150, 25); - initScopeDepthField.setBounds(10+150+10, 10+30+30, 75, 25); + initScopeDepthLabel.setBounds(10, 10 + 30 + 30, 150, 25); + initScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30, 75, 25); add(initScopeDepthLabel); add(initScopeDepthField); - maxScopeDepthLabel.setBounds(10, 10+30+30+30, 150, 25); - maxScopeDepthField.setBounds(10+150+10, 10+30+30+30, 75, 25); + maxScopeDepthLabel.setBounds(10, 10 + 30 + 30 + 30, 150, 25); + maxScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30 + 30, 75, 25); add(maxScopeDepthLabel); add(maxScopeDepthField); - - autoFillCheckBox.setBounds(30, 10+30+30+30+30, 230, 25); + + autoFillCheckBox.setBounds(30, 10 + 30 + 30 + 30 + 30, 230, 25); add(autoFillCheckBox); autoFillCheckBox.addChangeListener(this); experimentalLabel.setForeground(Color.red); - experimentalLabel.setBounds(250,10+30+30+30+30, 100, 25); + experimentalLabel.setBounds(250, 10 + 30 + 30 + 30 + 30, 100, 25); add(experimentalLabel); - setPreferredSize(new Dimension(300,150)); + setPreferredSize(new Dimension(300, 150)); } public void loadFromBody(MethodBody body) { @@ -95,15 +95,13 @@ public class MethodBodyParamsPanel extends JPanel implements ChangeListener{ public boolean save() { if (body != null) { body.init_scope_depth = Integer.parseInt(initScopeDepthField.getText()); - if(!autoFillCheckBox.isSelected()) - { + if (!autoFillCheckBox.isSelected()) { body.max_stack = Integer.parseInt(maxStackField.getText()); body.max_regs = Integer.parseInt(localCountField.getText()); body.max_scope_depth = Integer.parseInt(maxScopeDepthField.getText()); - }else{ - if(!body.autoFillStats(Main.abcMainFrame.abc)) - { - JOptionPane.showMessageDialog(null, "Cannot get code stats for automatic body params.\r\nUncheck autofill to avoid this message.","Warning",JOptionPane.WARNING_MESSAGE); + } else { + if (!body.autoFillStats(Main.abcMainFrame.abc)) { + JOptionPane.showMessageDialog(null, "Cannot get code stats for automatic body params.\r\nUncheck autofill to avoid this message.", "Warning", JOptionPane.WARNING_MESSAGE); } } return true; @@ -112,12 +110,12 @@ public class MethodBodyParamsPanel extends JPanel implements ChangeListener{ } public void stateChanged(ChangeEvent e) { - if(e.getSource()==autoFillCheckBox){ - if(autoFillCheckBox.isSelected()){ + if (e.getSource() == autoFillCheckBox) { + if (autoFillCheckBox.isSelected()) { localCountField.setEnabled(false); maxScopeDepthField.setEnabled(false); maxStackField.setEnabled(false); - }else{ + } else { localCountField.setEnabled(true); maxScopeDepthField.setEnabled(true); maxStackField.setEnabled(true); diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MethodCodePanel.java b/trunk/src/com/jpexs/asdec/abc/gui/MethodCodePanel.java index 97f2c7169..9aff5ca93 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MethodCodePanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -31,49 +30,51 @@ import javax.swing.JScrollPane; * @author JPEXS */ public class MethodCodePanel extends JPanel implements ActionListener { - public ASMSourceEditorPane sourceTextArea; - public JPanel buttonsPanel; + + public ASMSourceEditorPane sourceTextArea; + public JPanel buttonsPanel; public MethodCodePanel() { sourceTextArea = new ASMSourceEditorPane(); - + setLayout(new BorderLayout()); add(new JScrollPane(sourceTextArea), BorderLayout.CENTER); sourceTextArea.setContentType("text/flasm3"); - - buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new FlowLayout()); - JButton verifyButton = new JButton("Verify"); - verifyButton.setActionCommand("VERIFYBODY"); - verifyButton.addActionListener(this); - JButton graphButton = new JButton("Graph"); - graphButton.setActionCommand("GRAPH"); - graphButton.addActionListener(this); + buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new FlowLayout()); + JButton verifyButton = new JButton("Verify"); + verifyButton.setActionCommand("VERIFYBODY"); + verifyButton.addActionListener(this); - JButton execButton = new JButton("Execute"); - execButton.setActionCommand("EXEC"); - execButton.addActionListener(this); + JButton graphButton = new JButton("Graph"); + graphButton.setActionCommand("GRAPH"); + graphButton.addActionListener(this); - //buttonsPan.add(graphButton); - // buttonsPanel.add(saveButton); - // buttonsPan.add(execButton); + JButton execButton = new JButton("Execute"); + execButton.setActionCommand("EXEC"); + execButton.addActionListener(this); - //add(buttonsPanel, BorderLayout.SOUTH); + //buttonsPan.add(graphButton); + // buttonsPanel.add(saveButton); + // buttonsPan.add(execButton); + + //add(buttonsPanel, BorderLayout.SOUTH); } public void actionPerformed(ActionEvent e) { - if (Main.isWorking()) return; - if (e.getActionCommand().equals("GRAPH")) { - sourceTextArea.graph(); - } + if (Main.isWorking()) { + return; + } + if (e.getActionCommand().equals("GRAPH")) { + sourceTextArea.graph(); + } - if (e.getActionCommand().equals("EXEC")) { - sourceTextArea.exec(); - } + if (e.getActionCommand().equals("EXEC")) { + sourceTextArea.exec(); + } if (e.getActionCommand().equals("VERIFYBODY")) { - sourceTextArea.verify(Main.abcMainFrame.abc.constants, Main.abcMainFrame.abc); - } + sourceTextArea.verify(Main.abcMainFrame.abc.constants, Main.abcMainFrame.abc); + } } - } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MethodInfoPanel.java b/trunk/src/com/jpexs/asdec/abc/gui/MethodInfoPanel.java index 71c09d3fe..9655239e1 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MethodInfoPanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MethodInfoPanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -32,92 +31,85 @@ import jsyntaxpane.syntaxkits.Flasm3MethodInfoSyntaxKit; * @author JPEXS */ public class MethodInfoPanel extends JPanel { + public LineMarkedEditorPane paramEditor; public JEditorPane returnTypeEditor; private MethodInfo methodInfo; private ABC abc; - public MethodInfoPanel() - { - returnTypeEditor=new JEditorPane(); - paramEditor=new LineMarkedEditorPane(); - setLayout(new BoxLayout(this,BoxLayout.PAGE_AXIS)); + + public MethodInfoPanel() { + returnTypeEditor = new JEditorPane(); + paramEditor = new LineMarkedEditorPane(); + setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(new JLabel("Parameters:")); add(new JScrollPane(paramEditor)); add(new JLabel("Return value type:")); - JScrollPane jsp=new JScrollPane(returnTypeEditor); + JScrollPane jsp = new JScrollPane(returnTypeEditor); add(jsp); paramEditor.setContentType("text/flasm3_methodinfo"); returnTypeEditor.setContentType("text/flasm3_methodinfo"); - jsp.setMaximumSize(new Dimension(1024,25)); - Flasm3MethodInfoSyntaxKit sk=(Flasm3MethodInfoSyntaxKit)returnTypeEditor.getEditorKit(); + jsp.setMaximumSize(new Dimension(1024, 25)); + Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) returnTypeEditor.getEditorKit(); sk.deinstallComponent(returnTypeEditor, "jsyntaxpane.components.LineNumbersRuler"); } - public void load(int methodInfoIndex,ABC abc) - { - this.abc=abc; - if(methodInfoIndex<=0) - { + public void load(int methodInfoIndex, ABC abc) { + this.abc = abc; + if (methodInfoIndex <= 0) { paramEditor.setText(""); } - this.methodInfo=abc.method_info[methodInfoIndex]; - int p=0; - String ret=""; - int optParPos=0; - if(methodInfo.flagHas_optional()) - { - optParPos=methodInfo.param_types.length-methodInfo.optional.length; + this.methodInfo = abc.method_info[methodInfoIndex]; + int p = 0; + String ret = ""; + int optParPos = 0; + if (methodInfo.flagHas_optional()) { + optParPos = methodInfo.param_types.length - methodInfo.optional.length; } - for(int ptype:methodInfo.param_types) - { - if(p>0){ - ret+=",\n"; + for (int ptype : methodInfo.param_types) { + if (p > 0) { + ret += ",\n"; } - if(methodInfo.flagHas_paramnames()&&Main.PARAM_NAMES_ENABLE) - { - ret=ret+abc.constants.constant_string[methodInfo.paramNames[p]]; - }else{ - ret=ret+"param"+(p+1); + if (methodInfo.flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { + ret = ret + abc.constants.constant_string[methodInfo.paramNames[p]]; + } else { + ret = ret + "param" + (p + 1); } - ret+=":"; - if(ptype==0){ - ret+="*"; - }else{ - ret+="m["+ptype+"]\""+Helper.escapeString(abc.constants.constant_multiname[ptype].toString(abc.constants))+"\""; + ret += ":"; + if (ptype == 0) { + ret += "*"; + } else { + ret += "m[" + ptype + "]\"" + Helper.escapeString(abc.constants.constant_multiname[ptype].toString(abc.constants)) + "\""; } - if(methodInfo.flagHas_optional()) - { - if(p>=optParPos) - { - ret+="="+methodInfo.optional[p-optParPos].toString(abc.constants); + if (methodInfo.flagHas_optional()) { + if (p >= optParPos) { + ret += "=" + methodInfo.optional[p - optParPos].toString(abc.constants); } } p++; } - if(methodInfo.flagNeed_rest()){ - ret+=",\n... rest"; + if (methodInfo.flagNeed_rest()) { + ret += ",\n... rest"; } paramEditor.setText(ret); - if(methodInfo.ret_type==0){ + if (methodInfo.ret_type == 0) { returnTypeEditor.setText("*"); - }else{ - returnTypeEditor.setText("m["+methodInfo.ret_type+"]\""+Helper.escapeString(abc.constants.constant_multiname[methodInfo.ret_type].toString(abc.constants))+"\""); + } else { + returnTypeEditor.setText("m[" + methodInfo.ret_type + "]\"" + Helper.escapeString(abc.constants.constant_multiname[methodInfo.ret_type].toString(abc.constants)) + "\""); } } - public boolean save() - { + public boolean save() { try { MethodInfoParser.parseParams(paramEditor.getText(), methodInfo, abc); } catch (ParseException ex) { - JOptionPane.showMessageDialog(paramEditor, ex.text, "MethodInfo Params Error", JOptionPane.ERROR_MESSAGE); - return false; + JOptionPane.showMessageDialog(paramEditor, ex.text, "MethodInfo Params Error", JOptionPane.ERROR_MESSAGE); + return false; } try { MethodInfoParser.parseReturnType(returnTypeEditor.getText(), methodInfo); } catch (ParseException ex) { - JOptionPane.showMessageDialog(returnTypeEditor, ex.text, "MethodInfo Return type Error", JOptionPane.ERROR_MESSAGE); - return false; + JOptionPane.showMessageDialog(returnTypeEditor, ex.text, "MethodInfo Return type Error", JOptionPane.ERROR_MESSAGE); + return false; } return true; } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/MethodTraitDetailPanel.java b/trunk/src/com/jpexs/asdec/abc/gui/MethodTraitDetailPanel.java index 7a24911ee..713824ad6 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/MethodTraitDetailPanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/MethodTraitDetailPanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -34,27 +33,24 @@ public class MethodTraitDetailPanel extends JTabbedPane implements TraitDetail { public MethodTraitDetailPanel() { methodCodePanel = new MethodCodePanel(); methodBodyParamsPanel = new MethodBodyParamsPanel(); - methodInfoPanel=new MethodInfoPanel(); - addTab("MethodInfo",methodInfoPanel); + methodInfoPanel = new MethodInfoPanel(); + addTab("MethodInfo", methodInfoPanel); addTab("MethodBody Code", methodCodePanel); addTab("MethodBody params", new JScrollPane(methodBodyParamsPanel)); setSelectedIndex(1); } public boolean save() { - if(!methodInfoPanel.save()) - { + if (!methodInfoPanel.save()) { return false; } - if (!methodCodePanel.sourceTextArea.save(Main.abcMainFrame.abc.constants)) - { + if (!methodCodePanel.sourceTextArea.save(Main.abcMainFrame.abc.constants)) { return false; } - if(!methodBodyParamsPanel.save()) - { + if (!methodBodyParamsPanel.save()) { return false; } - + return true; } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/asdec/abc/gui/SlotConstTraitDetailPanel.java index 7e83de247..c3473c67a 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/SlotConstTraitDetailPanel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.ABC; @@ -38,46 +37,44 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { private TraitSlotConst trait; public SlotConstTraitDetailPanel() { - slotConstEditor=new JEditorPane(); + slotConstEditor = new JEditorPane(); setLayout(new BorderLayout()); - add(new JLabel("Type and Value:"),BorderLayout.NORTH); - add(new JScrollPane(slotConstEditor),BorderLayout.CENTER); + add(new JLabel("Type and Value:"), BorderLayout.NORTH); + add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); slotConstEditor.setContentType("text/flasm3_methodinfo"); - Flasm3MethodInfoSyntaxKit sk=(Flasm3MethodInfoSyntaxKit)slotConstEditor.getEditorKit(); + Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) slotConstEditor.getEditorKit(); sk.deinstallComponent(slotConstEditor, "jsyntaxpane.components.LineNumbersRuler"); } - - public void load(TraitSlotConst trait,ABC abc){ - this.abc=abc; - this.trait=trait; - String s=""; + public void load(TraitSlotConst trait, ABC abc) { + this.abc = abc; + this.trait = trait; + String s = ""; String typeStr = "*"; - if (trait.type_index > 0) { - typeStr = "m["+trait.type_index+"]\""+Helper.escapeString(abc.constants.constant_multiname[trait.type_index].toString(abc.constants))+"\""; - }else{ - typeStr = "*"; - } - String valueStr = ""; - if (trait.value_kind != 0) { - valueStr = " = " + (new ValueKind(trait.value_index, trait.value_kind)).toString(abc.constants); - } + if (trait.type_index > 0) { + typeStr = "m[" + trait.type_index + "]\"" + Helper.escapeString(abc.constants.constant_multiname[trait.type_index].toString(abc.constants)) + "\""; + } else { + typeStr = "*"; + } + String valueStr = ""; + if (trait.value_kind != 0) { + valueStr = " = " + (new ValueKind(trait.value_index, trait.value_kind)).toString(abc.constants); + } - s=typeStr + valueStr; - - slotConstEditor.setText(s); + s = typeStr + valueStr; + + slotConstEditor.setText(s); } public boolean save() { try { - if(!MethodInfoParser.parseSlotConst(slotConstEditor.getText(), trait, abc)){ + if (!MethodInfoParser.parseSlotConst(slotConstEditor.getText(), trait, abc)) { return false; } } catch (ParseException ex) { - JOptionPane.showMessageDialog(slotConstEditor, ex.text, "SlotConst typevalue Error", JOptionPane.ERROR_MESSAGE); - return false; + JOptionPane.showMessageDialog(slotConstEditor, ex.text, "SlotConst typevalue Error", JOptionPane.ERROR_MESSAGE); + return false; } return true; } - } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/TraitDetail.java b/trunk/src/com/jpexs/asdec/abc/gui/TraitDetail.java index d749a871f..1f7e5ea02 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/TraitDetail.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/TraitDetail.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; /** @@ -22,5 +21,6 @@ package com.jpexs.asdec.abc.gui; * @author JPEXS */ public interface TraitDetail { + public boolean save(); } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/TraitsList.java b/trunk/src/com/jpexs/asdec/abc/gui/TraitsList.java index 479fa3a23..744956913 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/TraitsList.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/TraitsList.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -24,33 +23,34 @@ import javax.swing.JList; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; - public class TraitsList extends JList implements ListSelectionListener { - ABC abc; - int classIndex = -1; - public TraitsList() { - addListSelectionListener(this); - setCellRenderer(new IconListRenderer()); - } + ABC abc; + int classIndex = -1; - public void setABC(ABC abc) { - this.abc = abc; - setModel(new DefaultListModel()); - } + public TraitsList() { + addListSelectionListener(this); + setCellRenderer(new IconListRenderer()); + } - public void setClassIndex(int classIndex) { - if (abc != null) - setModel(new TraitsListModel(abc, classIndex)); - this.classIndex = classIndex; + public void setABC(ABC abc) { + this.abc = abc; + setModel(new DefaultListModel()); + } - } + public void setClassIndex(int classIndex) { + if (abc != null) { + setModel(new TraitsListModel(abc, classIndex)); + } + this.classIndex = classIndex; - public void valueChanged(ListSelectionEvent e) { + } - int index = getSelectedIndex(); - - Main.abcMainFrame.decompiledTextArea.gotoTrait(index); + public void valueChanged(ListSelectionEvent e) { - } + int index = getSelectedIndex(); + + Main.abcMainFrame.decompiledTextArea.gotoTrait(index); + + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/TraitsListModel.java b/trunk/src/com/jpexs/asdec/abc/gui/TraitsListModel.java index 2bed078a7..effb69206 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/TraitsListModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/TraitsListModel.java @@ -14,51 +14,46 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.ABC; import javax.swing.ListModel; import javax.swing.event.ListDataListener; - public class TraitsListModel implements ListModel { - ABC abc; - int classIndex; - public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; - public static final String STR_CLASS_INITIALIZER = "class initializer"; + ABC abc; + int classIndex; + public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; + public static final String STR_CLASS_INITIALIZER = "class initializer"; - public TraitsListModel(ABC abc, int classIndex) { - this.abc = abc; - this.classIndex = classIndex; - } + public TraitsListModel(ABC abc, int classIndex) { + this.abc = abc; + this.classIndex = classIndex; + } - public int getSize() { - int cnt = abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length; - //if(abc.instance_info[classIndex].iinit_index!=0) cnt++; - cnt += 2; - return cnt; - } + public int getSize() { + int cnt = abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length; + //if(abc.instance_info[classIndex].iinit_index!=0) cnt++; + cnt += 2; + return cnt; + } - public Object getElementAt(int index) { - if (index < abc.class_info[classIndex].static_traits.traits.length) { - return abc.class_info[classIndex].static_traits.traits[index].convert(abc.constants, abc.method_info, abc,true); - } else if (index < abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) { - return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convert(abc.constants, abc.method_info, abc,false); - } else if (index == abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) { - return STR_INSTANCE_INITIALIZER; - } else { - return STR_CLASS_INITIALIZER; - } - } + public Object getElementAt(int index) { + if (index < abc.class_info[classIndex].static_traits.traits.length) { + return abc.class_info[classIndex].static_traits.traits[index].convert(abc.constants, abc.method_info, abc, true); + } else if (index < abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) { + return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convert(abc.constants, abc.method_info, abc, false); + } else if (index == abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) { + return STR_INSTANCE_INITIALIZER; + } else { + return STR_CLASS_INITIALIZER; + } + } - public void addListDataListener(ListDataListener l) { - - } - - public void removeListDataListener(ListDataListener l) { - - } + public void addListDataListener(ListDataListener l) { + } + public void removeListDataListener(ListDataListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/Tree.java b/trunk/src/com/jpexs/asdec/abc/gui/Tree.java index 5882702b4..47a1f5777 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/Tree.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/Tree.java @@ -14,37 +14,37 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import java.util.StringTokenizer; public class Tree { - private final TreeElement ROOT = new TreeElement("", "", -1, null); - public void add(String name, String path, int classIndex) { - StringTokenizer st = new StringTokenizer(path, "."); - TreeElement parent = ROOT; - while (st.hasMoreTokens()) { - String pathElement = st.nextToken(); - parent = parent.getBranch(pathElement); - } - parent.addLeaf(name, classIndex); - } + private final TreeElement ROOT = new TreeElement("", "", -1, null); - public TreeElement getRoot() { - return ROOT; - } + public void add(String name, String path, int classIndex) { + StringTokenizer st = new StringTokenizer(path, "."); + TreeElement parent = ROOT; + while (st.hasMoreTokens()) { + String pathElement = st.nextToken(); + parent = parent.getBranch(pathElement); + } + parent.addLeaf(name, classIndex); + } - public void visit(TreeVisitor visitor) { - ROOT.visitLeafs(visitor); - ROOT.visitBranches(visitor); - } + public TreeElement getRoot() { + return ROOT; + } - public TreeElement get(String fullPath) { - if ("".equals(fullPath)) { - return ROOT; - } - return ROOT.getByPath(fullPath); - } + public void visit(TreeVisitor visitor) { + ROOT.visitLeafs(visitor); + ROOT.visitBranches(visitor); + } + + public TreeElement get(String fullPath) { + if ("".equals(fullPath)) { + return ROOT; + } + return ROOT.getByPath(fullPath); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/TreeElement.java b/trunk/src/com/jpexs/asdec/abc/gui/TreeElement.java index 2f140539a..b30479389 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/TreeElement.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/TreeElement.java @@ -14,155 +14,154 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import java.util.*; import javax.swing.tree.TreePath; public class TreeElement { - private SortedMap branches; - private SortedMap leafs; - private String name; - private String path; - private int classIndex; - private TreeElement parent; - public TreeElement(String name, String path, int classIndex, TreeElement parent) { - this.name = name; - this.path = path; - this.classIndex = classIndex; - this.parent = parent; - branches = new TreeMap(); - leafs = new TreeMap(); - } + private SortedMap branches; + private SortedMap leafs; + private String name; + private String path; + private int classIndex; + private TreeElement parent; + + public TreeElement(String name, String path, int classIndex, TreeElement parent) { + this.name = name; + this.path = path; + this.classIndex = classIndex; + this.parent = parent; + branches = new TreeMap(); + leafs = new TreeMap(); + } public TreeElement getParent() { return parent; - } - - public String getName() { - return name; - } + } + + public String getName() { + return name; + } + + public String getPath() { + return path; + } - public String getPath() { - return path; - } - public TreePath getTreePath() { List pathList = new ArrayList(); - TreeElement temp=this; - do{ - pathList.add(0,temp); - } - while((temp=temp.getParent())!=null); + TreeElement temp = this; + do { + pathList.add(0, temp); + } while ((temp = temp.getParent()) != null); return new TreePath(pathList.toArray()); } - public int getClassIndex() { - return classIndex; - } + public int getClassIndex() { + return classIndex; + } - @Override - public String toString() { - return name; - } + @Override + public String toString() { + return name; + } - TreeElement getBranch(String pathElement) { - TreeElement branch = branches.get(pathElement); - if (branch == null) { - branch = new TreeElement(pathElement, path+"."+pathElement, -1, this); - branches.put(pathElement, branch); - } - return branch; - } + TreeElement getBranch(String pathElement) { + TreeElement branch = branches.get(pathElement); + if (branch == null) { + branch = new TreeElement(pathElement, path + "." + pathElement, -1, this); + branches.put(pathElement, branch); + } + return branch; + } - void addLeaf(String pathElement, int classIndex) { - TreeElement child = new TreeElement(pathElement, path+"."+pathElement, classIndex, this); - leafs.put(pathElement, child); - } + void addLeaf(String pathElement, int classIndex) { + TreeElement child = new TreeElement(pathElement, path + "." + pathElement, classIndex, this); + leafs.put(pathElement, child); + } - public TreeElement getChild(int index) { - Iterator iter; - int startingIndex; - if (index < branches.size()) { - iter = branches.values().iterator(); - startingIndex = 0; - } else { - iter = leafs.values().iterator(); - startingIndex = branches.size(); - } - int ii = startingIndex; - TreeElement child = null; - while (ii <= index && iter.hasNext()) { - child = iter.next(); - ii++; - } - return child; - } + public TreeElement getChild(int index) { + Iterator iter; + int startingIndex; + if (index < branches.size()) { + iter = branches.values().iterator(); + startingIndex = 0; + } else { + iter = leafs.values().iterator(); + startingIndex = branches.size(); + } + int ii = startingIndex; + TreeElement child = null; + while (ii <= index && iter.hasNext()) { + child = iter.next(); + ii++; + } + return child; + } - public int getChildCount() { - return branches.size() + leafs.size(); - } + public int getChildCount() { + return branches.size() + leafs.size(); + } - public boolean isLeaf() { - return getChildCount() == 0; - } + public boolean isLeaf() { + return getChildCount() == 0; + } - public int getIndexOfChild(TreeElement child) { - if (getChildCount() < 1) { - return -1; - } - Iterator iter = branches.values().iterator(); - int ii = 0; - TreeElement aChild = null; - while (aChild != child && iter.hasNext()) { - aChild = iter.next(); - if (aChild == child) { - return ii; - } - ii++; - } - iter = leafs.values().iterator(); - while (aChild != child && iter.hasNext()) { - aChild = iter.next(); - if (aChild == child) { - return ii; - } - ii++; - } - return -1; - } + public int getIndexOfChild(TreeElement child) { + if (getChildCount() < 1) { + return -1; + } + Iterator iter = branches.values().iterator(); + int ii = 0; + TreeElement aChild = null; + while (aChild != child && iter.hasNext()) { + aChild = iter.next(); + if (aChild == child) { + return ii; + } + ii++; + } + iter = leafs.values().iterator(); + while (aChild != child && iter.hasNext()) { + aChild = iter.next(); + if (aChild == child) { + return ii; + } + ii++; + } + return -1; + } - void visitBranches(TreeVisitor visitor) { - Iterator iter = branches.values().iterator(); - while (iter.hasNext()) { - TreeElement branch = iter.next(); - visitor.onBranch(branch); - branch.visitLeafs(visitor); - branch.visitBranches(visitor); - } - } + void visitBranches(TreeVisitor visitor) { + Iterator iter = branches.values().iterator(); + while (iter.hasNext()) { + TreeElement branch = iter.next(); + visitor.onBranch(branch); + branch.visitLeafs(visitor); + branch.visitBranches(visitor); + } + } - void visitLeafs(TreeVisitor visitor) { - Iterator iter = leafs.values().iterator(); - while (iter.hasNext()) { - TreeElement leaf = iter.next(); - visitor.onLeaf(leaf); - } - } + void visitLeafs(TreeVisitor visitor) { + Iterator iter = leafs.values().iterator(); + while (iter.hasNext()) { + TreeElement leaf = iter.next(); + visitor.onLeaf(leaf); + } + } - TreeElement getByPath(String fullPath) { - TreeElement te = this; - StringTokenizer st = new StringTokenizer(fullPath, "."); - while (st.hasMoreTokens()) { - String pathElement = st.nextToken(); - TreeElement nte = te.branches.get(pathElement); - if (nte == null) { - nte = te.leafs.get(pathElement); - } - te = nte; - } - return te; - } + TreeElement getByPath(String fullPath) { + TreeElement te = this; + StringTokenizer st = new StringTokenizer(fullPath, "."); + while (st.hasMoreTokens()) { + String pathElement = st.nextToken(); + TreeElement nte = te.branches.get(pathElement); + if (nte == null) { + nte = te.leafs.get(pathElement); + } + te = nte; + } + return te; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/TreeVisitor.java b/trunk/src/com/jpexs/asdec/abc/gui/TreeVisitor.java index 0574141d5..eec9a722b 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/TreeVisitor.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/TreeVisitor.java @@ -14,10 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; public interface TreeVisitor { - public void onBranch(TreeElement branch); - public void onLeaf(TreeElement leaf); + + public void onBranch(TreeElement branch); + + public void onLeaf(TreeElement leaf); } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/UsageFrame.java b/trunk/src/com/jpexs/asdec/abc/gui/UsageFrame.java index fd2f12885..f0a48d131 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/UsageFrame.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/UsageFrame.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.Main; @@ -83,23 +82,22 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener try { Thread.sleep(100); } catch (InterruptedException ex) { - } if (usage instanceof TraitMultinameUsage) { - TraitMultinameUsage tmu=(TraitMultinameUsage)usage; - int traitIndex=0; - if(tmu.parentTraitIndex>-1){ - traitIndex=tmu.parentTraitIndex; - }else{ - traitIndex=tmu.traitIndex; + TraitMultinameUsage tmu = (TraitMultinameUsage) usage; + int traitIndex = 0; + if (tmu.parentTraitIndex > -1) { + traitIndex = tmu.parentTraitIndex; + } else { + traitIndex = tmu.traitIndex; } - if(!tmu.isStatic){ - traitIndex+=abc.class_info[tmu.classIndex].static_traits.traits.length; + if (!tmu.isStatic) { + traitIndex += abc.class_info[tmu.classIndex].static_traits.traits.length; } - if(tmu instanceof MethodMultinameUsage){ - MethodMultinameUsage mmu=(MethodMultinameUsage)usage; - if(mmu.isInitializer==true){ - traitIndex=abc.class_info[mmu.classIndex].static_traits.traits.length+abc.instance_info[mmu.classIndex].instance_traits.traits.length+(mmu.isStatic?1:0); + if (tmu instanceof MethodMultinameUsage) { + MethodMultinameUsage mmu = (MethodMultinameUsage) usage; + if (mmu.isInitializer == true) { + traitIndex = abc.class_info[mmu.classIndex].static_traits.traits.length + abc.instance_info[mmu.classIndex].instance_traits.traits.length + (mmu.isStatic ? 1 : 0); } } Main.abcMainFrame.decompiledTextArea.gotoTrait(traitIndex); diff --git a/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java b/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java index 4b90f66f9..4986a831f 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/UsageListModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui; import com.jpexs.asdec.abc.ABC; @@ -25,28 +24,25 @@ import javax.swing.DefaultListModel; * * @author JPEXS */ -public class UsageListModel extends DefaultListModel{ +public class UsageListModel extends DefaultListModel { private ABC abc; - public UsageListModel(ABC abc){ - this.abc=abc; + + public UsageListModel(ABC abc) { + this.abc = abc; } + @Override public Object get(int index) { - return ((MultinameUsage)super.get(index)).toString(abc); + return ((MultinameUsage) super.get(index)).toString(abc); } @Override public Object getElementAt(int index) { - return ((MultinameUsage)super.getElementAt(index)).toString(abc); + return ((MultinameUsage) super.getElementAt(index)).toString(abc); } - public MultinameUsage getUsage(int index){ - return ((MultinameUsage)super.getElementAt(index)); + public MultinameUsage getUsage(int index) { + return ((MultinameUsage) super.getElementAt(index)); } - - - - - } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DecimalTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DecimalTableModel.java index f5645b6d2..ce24b60ba 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DecimalTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DecimalTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,124 +21,129 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class DecimalTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; - public DecimalTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_decimal.length; - } + public DecimalTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_decimal.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) return rowIndex; - else { - return abc.constants.constant_decimal[rowIndex]; - } - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_decimal[rowIndex]; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DoubleTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DoubleTableModel.java index ebb0c72e9..a5670ad20 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DoubleTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/DoubleTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,126 +21,131 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class DoubleTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; - public DoubleTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_double.length; - } + public DoubleTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_double.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) return rowIndex; - else if (Double.isNaN(abc.constants.constant_double[rowIndex])) { - return "NaN"; - } else { - return "" + abc.constants.constant_double[rowIndex]; - } - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else if (Double.isNaN(abc.constants.constant_double[rowIndex])) { + return "NaN"; + } else { + return "" + abc.constants.constant_double[rowIndex]; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/IntTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/IntTableModel.java index 92712e980..d24cfd31f 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/IntTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/IntTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,122 +21,129 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class IntTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, Long.class}; - public IntTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, Long.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_int.length; - } + public IntTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_int.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) return rowIndex; - else return abc.constants.constant_int[rowIndex]; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_int[rowIndex]; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/MultinameTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/MultinameTableModel.java index b96285b72..e8842b56e 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/MultinameTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/MultinameTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,141 +21,159 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class MultinameTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Kind", "Name", "Namespace", "NamespaceSet"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class, String.class, String.class}; - public MultinameTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Kind", "Name", "Namespace", "NamespaceSet"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class, String.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_multiname.length; - } + public MultinameTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 5; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_multiname.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 5; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) return ""; - return abc.constants.constant_multiname[rowIndex].getKindStr(); - case 2: - if (rowIndex == 0) return ""; - if (abc.constants.constant_multiname[rowIndex].name_index == -1) return ""; - return abc.constants.constant_multiname[rowIndex].getName(abc.constants); - case 3: - if (rowIndex == 0) return ""; - if (abc.constants.constant_multiname[rowIndex].namespace_index == -1) return ""; - return abc.constants.constant_multiname[rowIndex].getNamespace(abc.constants).getNameWithKind(abc.constants); - case 4: - if (rowIndex == 0) return ""; - if (abc.constants.constant_multiname[rowIndex].namespace_set_index == -1) return ""; - return abc.constants.constant_multiname[rowIndex].getNamespaceSet(abc.constants).toString(abc.constants); - default: - return null; - } - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getKindStr(); + case 2: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].name_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getName(abc.constants); + case 3: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].namespace_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getNamespace(abc.constants).getNameWithKind(abc.constants); + case 4: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].namespace_set_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getNamespaceSet(abc.constants).toString(abc.constants); + default: + return null; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceSetTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceSetTableModel.java index 1531c95c8..a225b5ff6 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceSetTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceSetTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,129 +21,135 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class NamespaceSetTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "NameSpaces"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - public NamespaceSetTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "NameSpaces"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_namespace_set.length; - } + public NamespaceSetTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_namespace_set.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) return ""; - return abc.constants.constant_namespace_set[rowIndex].toString(abc.constants); - default: - return null; - } - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return ""; + } + return abc.constants.constant_namespace_set[rowIndex].toString(abc.constants); + default: + return null; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceTableModel.java index 03c161423..45b9d237c 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/NamespaceTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,132 +21,140 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class NamespaceTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Kind", "Name"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - public NamespaceTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Kind", "Name"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_namespace.length; - } + public NamespaceTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 3; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_namespace.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 3; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) return "-"; - return abc.constants.constant_namespace[rowIndex].getKindStr(); - case 2: - if (rowIndex == 0) return "-"; - return abc.constants.constant_namespace[rowIndex].getName(abc.constants); - default: - return null; - } - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return "-"; + } + return abc.constants.constant_namespace[rowIndex].getKindStr(); + case 2: + if (rowIndex == 0) { + return "-"; + } + return abc.constants.constant_namespace[rowIndex].getName(abc.constants); + default: + return null; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/StringTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/StringTableModel.java index a9c064e41..71e41da79 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/StringTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/StringTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,122 +21,129 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class StringTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; - public StringTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_string.length; - } + public StringTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_string.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) return rowIndex; - else return abc.constants.constant_string[rowIndex]; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_string[rowIndex]; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/UIntTableModel.java b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/UIntTableModel.java index 5187a6fce..bc4c91860 100644 --- a/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/UIntTableModel.java +++ b/trunk/src/com/jpexs/asdec/abc/gui/tablemodels/UIntTableModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.gui.tablemodels; import com.jpexs.asdec.abc.ABC; @@ -22,122 +21,129 @@ import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; public class UIntTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, Long.class}; - public UIntTableModel(ABC abc) { - this.abc = abc; - } + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, Long.class}; - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it - * should display. This method should be quick, as it - * is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - public int getRowCount() { - return abc.constants.constant_uint.length; - } + public UIntTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - public int getColumnCount() { - return 2; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + public int getRowCount() { + return abc.constants.constant_uint.length; + } - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does - * not need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + public int getColumnCount() { + return 2; + } - /** - * Returns the most specific superclass for all the cell values - * in the column. This is used by the JTable to set up a - * default renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns true if the cell at rowIndex and - * columnIndex - * is editable. Otherwise, setValueAt on the cell will not - * change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) return rowIndex; - else return abc.constants.constant_uint[rowIndex]; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_uint[rowIndex]; + } + } - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change - * to the data model occurs. - * - * @param l the TableModelListener - */ - public void addTableModelListener(TableModelListener l) { + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + public void addTableModelListener(TableModelListener l) { + } - } - - /** - * Removes a listener from the list that is notified each time a - * change to the data model occurs. - * - * @param l the TableModelListener - */ - public void removeTableModelListener(TableModelListener l) { - - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoLexer.java b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoLexer.java index 41abf8ada..475a6f88b 100644 --- a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoLexer.java +++ b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoLexer.java @@ -14,1036 +14,1061 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.methodinfo_parser; - /** - * This class is a scanner generated by - * JFlex 1.4.3 - * on 11.7.11 15:46 from the specification file + * This class is a scanner generated by JFlex + * 1.4.3 on 11.7.11 15:46 from the specification file * D:/Dokumenty/Programovani/JavaSE/ASDec/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/methodinfo.flex */ public final class MethodInfoLexer { - /** This character denotes the end of file */ - public static final int YYEOF = -1; - - /** initial size of the lookahead buffer */ - private static final int ZZ_BUFFERSIZE = 16384; - - /** lexical states */ - public static final int STRING = 2; - public static final int YYINITIAL = 0; - - /** - * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l - * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l - * at the beginning of a line - * l is of the form l = 2*k, k a non negative integer - */ - private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1 - }; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\5\1\3\1\2\1\0\1\3\1\1\16\5\4\0\1\3\1\0"+ - "\1\42\1\0\1\4\2\0\1\56\2\0\1\45\1\37\1\44\1\7"+ - "\1\35\1\0\1\6\3\57\4\40\2\10\1\43\2\0\1\46\3\0"+ - "\4\4\1\36\6\4\1\31\1\4\1\25\1\4\1\17\12\4\1\12"+ - "\1\41\1\13\1\0\1\4\1\0\1\32\1\27\1\50\1\51\1\24"+ - "\1\55\1\53\1\4\1\21\1\4\1\52\1\33\1\11\1\14\1\20"+ - "\1\47\1\4\1\30\1\15\1\22\1\26\1\23\1\4\1\54\2\4"+ - "\1\16\1\0\1\34\1\0\41\5\2\0\4\4\4\0\1\4\2\0"+ - "\1\5\7\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0"+ - "\u013f\4\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\21\0"+ - "\130\5\5\0\23\5\12\0\1\4\13\0\1\4\1\0\3\4\1\0"+ - "\1\4\1\0\24\4\1\0\54\4\1\0\46\4\1\0\5\4\4\0"+ - "\202\4\1\0\4\5\3\0\105\4\1\0\46\4\2\0\2\4\6\0"+ - "\20\4\41\0\46\4\2\0\1\4\7\0\47\4\11\0\21\5\1\0"+ - "\27\5\1\0\3\5\1\0\1\5\1\0\2\5\1\0\1\5\13\0"+ - "\33\4\5\0\3\4\15\0\4\5\14\0\6\5\13\0\32\4\5\0"+ - "\13\4\16\5\7\0\12\5\4\0\2\4\1\5\143\4\1\0\1\4"+ - "\10\5\1\0\6\5\2\4\2\5\1\0\4\5\2\4\12\5\3\4"+ - "\2\0\1\4\17\0\1\5\1\4\1\5\36\4\33\5\2\0\3\4"+ - "\60\0\46\4\13\5\1\4\u014f\0\3\5\66\4\2\0\1\5\1\4"+ - "\20\5\2\0\1\4\4\5\3\0\12\4\2\5\2\0\12\5\21\0"+ - "\3\5\1\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0"+ - "\1\4\3\0\4\4\2\0\1\5\1\4\7\5\2\0\2\5\2\0"+ - "\3\5\11\0\1\5\4\0\2\4\1\0\3\4\2\5\2\0\12\5"+ - "\4\4\15\0\3\5\1\0\6\4\4\0\2\4\2\0\26\4\1\0"+ - "\7\4\1\0\2\4\1\0\2\4\1\0\2\4\2\0\1\5\1\0"+ - "\5\5\4\0\2\5\2\0\3\5\13\0\4\4\1\0\1\4\7\0"+ - "\14\5\3\4\14\0\3\5\1\0\11\4\1\0\3\4\1\0\26\4"+ - "\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4\10\5"+ - "\1\0\3\5\1\0\3\5\2\0\1\4\17\0\2\4\2\5\2\0"+ - "\12\5\1\0\1\4\17\0\3\5\1\0\10\4\2\0\2\4\2\0"+ - "\26\4\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4"+ - "\6\5\3\0\2\5\2\0\3\5\10\0\2\5\4\0\2\4\1\0"+ - "\3\4\4\0\12\5\1\0\1\4\20\0\1\5\1\4\1\0\6\4"+ - "\3\0\3\4\1\0\4\4\3\0\2\4\1\0\1\4\1\0\2\4"+ - "\3\0\2\4\3\0\3\4\3\0\10\4\1\0\3\4\4\0\5\5"+ - "\3\0\3\5\1\0\4\5\11\0\1\5\17\0\11\5\11\0\1\4"+ - "\7\0\3\5\1\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4"+ - "\1\0\5\4\4\0\7\5\1\0\3\5\1\0\4\5\7\0\2\5"+ - "\11\0\2\4\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4"+ - "\1\0\27\4\1\0\12\4\1\0\5\4\2\0\1\5\1\4\7\5"+ - "\1\0\3\5\1\0\4\5\7\0\2\5\7\0\1\4\1\0\2\4"+ - "\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4\1\0\27\4"+ - "\1\0\20\4\4\0\6\5\2\0\3\5\1\0\4\5\11\0\1\5"+ - "\10\0\2\4\4\0\12\5\22\0\2\5\1\0\22\4\3\0\30\4"+ - "\1\0\11\4\1\0\1\4\2\0\7\4\3\0\1\5\4\0\6\5"+ - "\1\0\1\5\1\0\10\5\22\0\2\5\15\0\60\4\1\5\2\4"+ - "\7\5\4\0\10\4\10\5\1\0\12\5\47\0\2\4\1\0\1\4"+ - "\2\0\2\4\1\0\1\4\2\0\1\4\6\0\4\4\1\0\7\4"+ - "\1\0\3\4\1\0\1\4\1\0\1\4\2\0\2\4\1\0\4\4"+ - "\1\5\2\4\6\5\1\0\2\5\1\4\2\0\5\4\1\0\1\4"+ - "\1\0\6\5\2\0\12\5\2\0\2\4\42\0\1\4\27\0\2\5"+ - "\6\0\12\5\13\0\1\5\1\0\1\5\1\0\1\5\4\0\2\5"+ - "\10\4\1\0\42\4\6\0\24\5\1\0\2\5\4\4\4\0\10\5"+ - "\1\0\44\5\11\0\1\5\71\0\42\4\1\0\5\4\1\0\2\4"+ - "\1\0\7\5\3\0\4\5\6\0\12\5\6\0\6\4\4\5\106\0"+ - "\46\4\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4\6\0"+ - "\7\4\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0"+ - "\1\4\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4\2\0"+ - "\37\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4\1\0"+ - "\4\4\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4\1\0"+ - "\1\4\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4\16\0"+ - "\11\5\56\0\125\4\14\0\u026c\4\2\0\10\4\12\0\32\4\5\0"+ - "\113\4\3\0\3\4\17\0\15\4\1\0\4\4\3\5\13\0\22\4"+ - "\3\5\13\0\22\4\2\5\14\0\15\4\1\0\3\4\1\0\2\5"+ - "\14\0\64\4\40\5\3\0\1\4\3\0\2\4\1\5\2\0\12\5"+ - "\41\0\3\5\2\0\12\5\6\0\130\4\10\0\51\4\1\5\126\0"+ - "\35\4\3\0\14\5\4\0\14\5\12\0\12\5\36\4\2\0\5\4"+ - "\u038b\0\154\4\224\0\234\4\4\0\132\4\6\0\26\4\2\0\6\4"+ - "\2\0\46\4\2\0\6\4\2\0\10\4\1\0\1\4\1\0\1\4"+ - "\1\0\1\4\1\0\37\4\2\0\65\4\1\0\7\4\1\0\1\4"+ - "\3\0\3\4\1\0\7\4\3\0\4\4\2\0\6\4\4\0\15\4"+ - "\5\0\3\4\1\0\7\4\17\0\4\5\32\0\5\5\20\0\2\4"+ - "\23\0\1\4\13\0\4\5\6\0\6\5\1\0\1\4\15\0\1\4"+ - "\40\0\22\4\36\0\15\5\4\0\1\5\3\0\6\5\27\0\1\4"+ - "\4\0\1\4\2\0\12\4\1\0\1\4\3\0\5\4\6\0\1\4"+ - "\1\0\1\4\1\0\1\4\1\0\4\4\1\0\3\4\1\0\7\4"+ - "\3\0\3\4\5\0\5\4\26\0\44\4\u0e81\0\3\4\31\0\11\4"+ - "\6\5\1\0\5\4\2\0\5\4\4\0\126\4\2\0\2\5\2\0"+ - "\3\4\1\0\137\4\5\0\50\4\4\0\136\4\21\0\30\4\70\0"+ - "\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4\u215c\0"+ - "\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4\1\5"+ - "\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4\1\0"+ - "\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0"+ - "\15\4\3\0\20\5\20\0\4\5\17\0\2\4\30\0\3\4\31\0"+ - "\1\4\6\0\5\4\1\0\207\4\2\0\1\5\4\0\1\4\13\0"+ - "\12\5\7\0\32\4\4\0\1\4\1\0\32\4\12\0\132\4\3\0"+ - "\6\4\2\0\6\4\2\0\6\4\2\0\3\4\3\0\2\4\3\0"+ - "\2\4\22\0\3\5\4\0"; - - /** - * Translates characters to character classes - */ - private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - - /** - * Translates DFA states to action switch labels. - */ - private static final int [] ZZ_ACTION = zzUnpackAction(); - - private static final String ZZ_ACTION_PACKED_0 = - "\2\0\2\1\1\2\1\3\1\1\1\3\7\2\1\1"+ - "\1\4\1\5\1\6\1\7\1\10\2\2\1\11\2\12"+ - "\1\1\1\13\1\14\1\0\1\14\2\0\7\2\1\0"+ - "\3\2\1\15\1\16\1\17\1\20\1\21\1\22\1\16"+ - "\1\23\1\24\1\25\1\26\1\14\4\0\6\2\1\27"+ - "\4\2\1\16\2\0\1\30\2\2\1\31\6\2\1\32"+ - "\1\0\7\2\1\33\1\0\1\34\6\2\1\0\4\2"+ - "\1\35\1\36\1\0\1\37\1\40\2\2\1\0\1\41"+ - "\1\42\20\0\1\43"; - - private static int [] zzUnpackAction() { - int [] result = new int[134]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAction(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - - /** - * Translates a state to a row index in the transition table - */ - private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); - - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150"+ - "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\u02a0\0\u02d0"+ - "\0\140\0\140\0\140\0\140\0\140\0\u0300\0\u0330\0\u0360"+ - "\0\u0390\0\140\0\u03c0\0\140\0\360\0\u03f0\0\u0420\0\u0450"+ - "\0\u0480\0\u04b0\0\u04e0\0\u0510\0\u0540\0\u0570\0\u05a0\0\u05d0"+ - "\0\u0600\0\u0630\0\u0660\0\u0690\0\140\0\u06c0\0\140\0\140"+ - "\0\140\0\140\0\u06f0\0\140\0\140\0\140\0\140\0\u0720"+ - "\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0\0\u0810\0\u0840\0\u0870"+ - "\0\u08a0\0\u08d0\0\140\0\u0900\0\u0930\0\u0960\0\u0990\0\140"+ - "\0\u09c0\0\u09f0\0\300\0\u0a20\0\u0a50\0\300\0\u0a80\0\u0ab0"+ - "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\140\0\u0ba0\0\u0bd0\0\u0c00"+ - "\0\u0c30\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\300\0\u0d20\0\300"+ - "\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u0ea0"+ - "\0\u0ed0\0\u0f00\0\u0f30\0\300\0\300\0\u0f60\0\300\0\300"+ - "\0\u0f90\0\u0fc0\0\u0ff0\0\300\0\300\0\u1020\0\u1050\0\u1080"+ - "\0\u10b0\0\u10e0\0\u1110\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200"+ - "\0\u1230\0\u1260\0\u1290\0\u12c0\0\u12f0\0\140"; - - private static int [] zzUnpackRowMap() { - int [] result = new int[134]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackRowMap(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); - } - return j; - } - - /** - * The transition table of the DFA - */ - private static final int [] ZZ_TRANS = zzUnpackTrans(); - - private static final String ZZ_TRANS_PACKED_0 = - "\3\3\1\4\1\5\1\3\1\6\1\7\1\10\1\11"+ - "\2\3\1\12\1\13\1\3\2\5\1\14\1\15\1\5"+ - "\1\16\1\5\1\17\5\5\1\3\1\20\1\5\1\3"+ - "\1\10\1\3\1\21\1\22\1\23\1\24\1\25\1\26"+ - "\5\5\1\27\1\3\1\10\1\30\1\31\1\32\36\30"+ - "\1\33\1\34\15\30\63\0\1\4\60\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\6\0\1\35\1\0"+ - "\1\35\13\0\1\36\10\0\1\37\1\36\1\0\1\35"+ - "\16\0\1\35\6\0\1\35\1\0\1\10\24\0\1\40"+ - "\2\0\1\10\16\0\1\10\6\0\1\10\1\0\1\10"+ - "\13\0\1\36\10\0\1\37\1\36\1\0\1\10\16\0"+ - "\1\10\4\0\3\5\1\0\2\5\1\41\1\0\2\5"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\5"+ - "\1\42\1\0\7\5\1\43\5\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\3\5\1\44\11\5\2\0"+ - "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0"+ - "\3\5\1\0\2\5\2\0\1\45\1\5\1\0\15\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5"+ - "\1\46\3\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\5\5"+ - "\1\47\1\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\1\50\1\5\1\0\15\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\6\0\1\37\1\0"+ - "\1\37\24\0\1\51\2\0\1\37\16\0\1\37\4\0"+ - "\3\5\1\0\2\5\2\0\2\5\1\0\11\5\1\52"+ - "\1\5\1\53\1\5\2\0\1\5\1\0\1\5\6\0"+ - "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0"+ - "\2\5\1\0\13\5\1\54\1\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\1\30\2\0\36\30"+ - "\2\0\15\30\2\0\1\32\55\0\2\55\1\0\3\55"+ - "\1\56\5\55\1\57\5\55\1\60\4\55\1\61\1\62"+ - "\7\55\1\63\1\64\1\65\12\55\1\66\1\67\1\56"+ - "\6\0\1\70\1\71\1\70\26\0\1\71\1\70\16\0"+ - "\1\70\6\0\1\37\1\0\1\37\13\0\1\36\11\0"+ - "\1\36\1\0\1\37\16\0\1\37\6\0\1\37\1\0"+ - "\1\37\27\0\1\37\16\0\1\37\6\0\1\72\1\0"+ - "\1\73\27\0\1\73\16\0\1\73\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\74\15\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\14\5\1\75\2\0\1\5"+ - "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\13\5\1\76\1\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5"+ - "\1\77\11\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\7\5\1\100\5\5\2\0\1\5\1\0\1\5"+ - "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5"+ - "\6\0\1\101\6\5\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0"+ - "\1\5\6\0\2\5\1\102\4\5\1\0\1\5\35\0"+ - "\1\103\26\0\3\5\1\0\2\5\2\0\2\5\1\0"+ - "\1\5\1\104\1\105\12\5\2\0\1\5\1\0\1\5"+ - "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5"+ - "\6\0\1\5\1\106\5\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\14\5\1\107\2\0"+ - "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\6\0"+ - "\1\63\31\0\1\63\16\0\1\63\6\0\1\110\31\0"+ - "\1\110\16\0\1\110\6\0\1\70\1\0\1\70\27\0"+ - "\1\70\16\0\1\70\13\0\1\111\52\0\1\73\1\0"+ - "\1\73\2\0\1\111\24\0\1\73\16\0\1\73\17\0"+ - "\1\112\44\0\3\5\1\0\2\5\2\0\2\5\1\0"+ - "\14\5\1\113\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\3\5\1\114\11\5\2\0\1\5\1\0\1\5"+ - "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\5\5\1\115\7\5\2\0\1\5"+ - "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\5\5\1\116\7\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\14\5"+ - "\1\117\2\0\1\5\1\0\1\5\6\0\7\5\1\0"+ - "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0"+ - "\5\5\1\120\7\5\2\0\1\5\1\0\1\5\6\0"+ - "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0"+ - "\2\5\1\0\3\5\1\121\11\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\4\5\1\122\10\5\2\0"+ - "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0"+ - "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0"+ - "\1\5\1\0\1\5\6\0\3\5\1\123\3\5\1\0"+ - "\1\5\4\0\3\5\1\0\2\5\2\0\1\5\1\124"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\42\0\1\125\35\0\1\126\43\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\2\5\1\127\12\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5"+ - "\1\130\3\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\2\5\1\131\12\5\2\0\1\5\1\0\1\5"+ - "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5"+ - "\6\0\6\5\1\132\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\5\5\1\133\7\5\2\0"+ - "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0"+ - "\3\5\1\0\2\5\2\0\2\5\1\0\13\5\1\134"+ - "\1\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0"+ - "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0"+ - "\13\5\1\135\1\5\2\0\1\5\1\0\1\5\6\0"+ - "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0"+ - "\2\5\1\0\5\5\1\136\7\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\15\0\1\137\46\0"+ - "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0"+ - "\1\5\1\0\1\5\6\0\1\5\1\140\5\5\1\0"+ - "\1\5\4\0\3\5\1\0\2\5\2\0\1\141\1\5"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\1\5"+ - "\1\142\5\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\2\5\1\143\12\5\2\0\1\5"+ - "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5"+ - "\1\0\1\5\6\0\1\5\1\144\5\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5"+ - "\1\145\11\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5"+ - "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\4\5"+ - "\1\146\2\5\1\0\1\5\21\0\1\147\42\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\13\5\1\150\1\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\2\5"+ - "\1\151\12\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\152"+ - "\1\5\1\0\15\5\2\0\1\5\1\0\1\5\6\0"+ - "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0"+ - "\2\5\1\0\3\5\1\153\11\5\2\0\1\5\1\0"+ - "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0"+ - "\2\5\2\0\2\5\1\0\5\5\1\154\7\5\2\0"+ - "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0"+ - "\3\5\1\0\2\5\2\0\2\5\1\0\5\5\1\155"+ - "\7\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0"+ - "\1\5\22\0\1\156\41\0\3\5\1\0\2\5\2\0"+ - "\2\5\1\0\14\5\1\157\2\0\1\5\1\0\1\5"+ - "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\3\5\1\160\11\5\2\0\1\5"+ - "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\5\5\1\161\7\5"+ - "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5"+ - "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\5\5"+ - "\1\162\7\5\2\0\1\5\1\0\1\5\6\0\7\5"+ - "\1\0\1\5\21\0\1\163\42\0\3\5\1\0\2\5"+ - "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5"+ - "\6\0\2\5\1\164\4\5\1\0\1\5\4\0\3\5"+ - "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5"+ - "\1\0\1\5\6\0\2\5\1\165\4\5\1\0\1\5"+ - "\23\0\1\166\60\0\1\167\60\0\1\170\60\0\1\171"+ - "\42\0\1\172\75\0\1\173\54\0\1\174\63\0\1\175"+ - "\60\0\1\176\47\0\1\177\60\0\1\200\61\0\1\201"+ - "\63\0\1\202\61\0\1\203\60\0\1\204\60\0\1\205"+ - "\36\0\1\206\44\0"; - - private static int [] zzUnpackTrans() { - int [] result = new int[4896]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackTrans(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do result[j++] = value; while (--count > 0); - } - return j; - } - - - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; - - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state aState - */ - private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); - - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\2\0\1\11\15\1\5\11\4\1\1\11\1\1\1\11"+ - "\1\1\1\0\1\1\2\0\7\1\1\0\3\1\1\11"+ - "\1\1\4\11\1\1\4\11\1\1\4\0\6\1\1\11"+ - "\4\1\1\11\2\0\12\1\1\11\1\0\10\1\1\0"+ - "\7\1\1\0\6\1\1\0\4\1\1\0\2\1\20\0"+ - "\1\11"; - - private static int [] zzUnpackAttribute() { - int [] result = new int[134]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } - - private static int zzUnpackAttribute(String packed, int offset, int [] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do result[j++] = value; while (--count > 0); - } - return j; - } - - /** the input device */ - private java.io.Reader zzReader; - - /** the current state of the DFA */ - private int zzState; - - /** the current lexical state */ - private int zzLexicalState = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int zzMarkedPos; - - /** the current text position in the buffer */ - private int zzCurrentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int zzStartRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int zzEndRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - - /** zzAtEOF == true <=> the scanner is at the EOF */ - private boolean zzAtEOF; - - /** denotes if the user-EOF-code has already been executed */ - private boolean zzEOFDone; - - /* user code: */ - - StringBuffer string = new StringBuffer(); - boolean isMultiname=false; - long multinameId=0; - - - /** - * Create an empty lexer, yyrset will be called later to reset and assign - * the reader - */ - public MethodInfoLexer() { - - } - - public int yychar() { - return yychar; - } - - public int yyline() { - return yyline+1; - } - - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public MethodInfoLexer(java.io.Reader in) { - this.zzReader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public MethodInfoLexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] zzUnpackCMap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1768) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { - - /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead-zzStartRead); - - /* translate stored positions */ - zzEndRead-= zzStartRead; - zzCurrentPos-= zzStartRead; - zzMarkedPos-= zzStartRead; - zzStartRead = 0; - } - - /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos*2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length-zzEndRead); - - if (numRead > 0) { - zzEndRead+= numRead; - return false; - } - // unlikely but not impossible: read 0 characters, but not at end of stream - if (numRead == 0) { - int c = zzReader.read(); - if (c == -1) { - return true; - } else { - zzBuffer[zzEndRead++] = (char) c; - return false; - } - } - - // numRead < 0 - return true; - } - - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) - zzReader.close(); - } - - - /** - * Resets the scanner to read from a new input stream. - * Does not close the old reader. - * - * All internal variables are reset, the old input stream - * cannot be reused (internal buffer is discarded and lost). - * Lexical state is set to ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEOFDone = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead ); - } - - - /** - * Returns the character at position pos from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos-zzStartRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - public void yypushback(int number) { - if ( number > yylength() ) - zzScanError(ZZ_PUSHBACK_2BIG); - - zzMarkedPos -= number; - } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public ParsedSymbol yylex() throws java.io.IOException, ParseException { - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char [] zzBufferL = zzBuffer; - char [] zzCMapL = ZZ_CMAP; - - int [] zzTransL = ZZ_TRANS; - int [] zzRowMapL = ZZ_ROWMAP; - int [] zzAttrL = ZZ_ATTRIBUTE; - - while (true) { - zzMarkedPosL = zzMarkedPos; - - yychar+= zzMarkedPosL-zzStartRead; - - boolean zzR = false; - for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; - zzCurrentPosL++) { - switch (zzBufferL[zzCurrentPosL]) { - case '\u000B': - case '\u000C': - case '\u0085': - case '\u2028': - case '\u2029': - yyline++; - yycolumn = 0; - zzR = false; - break; - case '\r': - yyline++; - yycolumn = 0; - zzR = true; - break; - case '\n': - if (zzR) - zzR = false; - else { - yyline++; - yycolumn = 0; - } - break; - default: - zzR = false; - yycolumn++; - } + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * lexical states + */ + public static final int STRING = 2; + public static final int YYINITIAL = 0; + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the + * beginning of a line l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1 + }; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\5\1\3\1\2\1\0\1\3\1\1\16\5\4\0\1\3\1\0" + + "\1\42\1\0\1\4\2\0\1\56\2\0\1\45\1\37\1\44\1\7" + + "\1\35\1\0\1\6\3\57\4\40\2\10\1\43\2\0\1\46\3\0" + + "\4\4\1\36\6\4\1\31\1\4\1\25\1\4\1\17\12\4\1\12" + + "\1\41\1\13\1\0\1\4\1\0\1\32\1\27\1\50\1\51\1\24" + + "\1\55\1\53\1\4\1\21\1\4\1\52\1\33\1\11\1\14\1\20" + + "\1\47\1\4\1\30\1\15\1\22\1\26\1\23\1\4\1\54\2\4" + + "\1\16\1\0\1\34\1\0\41\5\2\0\4\4\4\0\1\4\2\0" + + "\1\5\7\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0" + + "\u013f\4\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\21\0" + + "\130\5\5\0\23\5\12\0\1\4\13\0\1\4\1\0\3\4\1\0" + + "\1\4\1\0\24\4\1\0\54\4\1\0\46\4\1\0\5\4\4\0" + + "\202\4\1\0\4\5\3\0\105\4\1\0\46\4\2\0\2\4\6\0" + + "\20\4\41\0\46\4\2\0\1\4\7\0\47\4\11\0\21\5\1\0" + + "\27\5\1\0\3\5\1\0\1\5\1\0\2\5\1\0\1\5\13\0" + + "\33\4\5\0\3\4\15\0\4\5\14\0\6\5\13\0\32\4\5\0" + + "\13\4\16\5\7\0\12\5\4\0\2\4\1\5\143\4\1\0\1\4" + + "\10\5\1\0\6\5\2\4\2\5\1\0\4\5\2\4\12\5\3\4" + + "\2\0\1\4\17\0\1\5\1\4\1\5\36\4\33\5\2\0\3\4" + + "\60\0\46\4\13\5\1\4\u014f\0\3\5\66\4\2\0\1\5\1\4" + + "\20\5\2\0\1\4\4\5\3\0\12\4\2\5\2\0\12\5\21\0" + + "\3\5\1\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0" + + "\1\4\3\0\4\4\2\0\1\5\1\4\7\5\2\0\2\5\2\0" + + "\3\5\11\0\1\5\4\0\2\4\1\0\3\4\2\5\2\0\12\5" + + "\4\4\15\0\3\5\1\0\6\4\4\0\2\4\2\0\26\4\1\0" + + "\7\4\1\0\2\4\1\0\2\4\1\0\2\4\2\0\1\5\1\0" + + "\5\5\4\0\2\5\2\0\3\5\13\0\4\4\1\0\1\4\7\0" + + "\14\5\3\4\14\0\3\5\1\0\11\4\1\0\3\4\1\0\26\4" + + "\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4\10\5" + + "\1\0\3\5\1\0\3\5\2\0\1\4\17\0\2\4\2\5\2\0" + + "\12\5\1\0\1\4\17\0\3\5\1\0\10\4\2\0\2\4\2\0" + + "\26\4\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4" + + "\6\5\3\0\2\5\2\0\3\5\10\0\2\5\4\0\2\4\1\0" + + "\3\4\4\0\12\5\1\0\1\4\20\0\1\5\1\4\1\0\6\4" + + "\3\0\3\4\1\0\4\4\3\0\2\4\1\0\1\4\1\0\2\4" + + "\3\0\2\4\3\0\3\4\3\0\10\4\1\0\3\4\4\0\5\5" + + "\3\0\3\5\1\0\4\5\11\0\1\5\17\0\11\5\11\0\1\4" + + "\7\0\3\5\1\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4" + + "\1\0\5\4\4\0\7\5\1\0\3\5\1\0\4\5\7\0\2\5" + + "\11\0\2\4\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4" + + "\1\0\27\4\1\0\12\4\1\0\5\4\2\0\1\5\1\4\7\5" + + "\1\0\3\5\1\0\4\5\7\0\2\5\7\0\1\4\1\0\2\4" + + "\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4\1\0\27\4" + + "\1\0\20\4\4\0\6\5\2\0\3\5\1\0\4\5\11\0\1\5" + + "\10\0\2\4\4\0\12\5\22\0\2\5\1\0\22\4\3\0\30\4" + + "\1\0\11\4\1\0\1\4\2\0\7\4\3\0\1\5\4\0\6\5" + + "\1\0\1\5\1\0\10\5\22\0\2\5\15\0\60\4\1\5\2\4" + + "\7\5\4\0\10\4\10\5\1\0\12\5\47\0\2\4\1\0\1\4" + + "\2\0\2\4\1\0\1\4\2\0\1\4\6\0\4\4\1\0\7\4" + + "\1\0\3\4\1\0\1\4\1\0\1\4\2\0\2\4\1\0\4\4" + + "\1\5\2\4\6\5\1\0\2\5\1\4\2\0\5\4\1\0\1\4" + + "\1\0\6\5\2\0\12\5\2\0\2\4\42\0\1\4\27\0\2\5" + + "\6\0\12\5\13\0\1\5\1\0\1\5\1\0\1\5\4\0\2\5" + + "\10\4\1\0\42\4\6\0\24\5\1\0\2\5\4\4\4\0\10\5" + + "\1\0\44\5\11\0\1\5\71\0\42\4\1\0\5\4\1\0\2\4" + + "\1\0\7\5\3\0\4\5\6\0\12\5\6\0\6\4\4\5\106\0" + + "\46\4\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4\6\0" + + "\7\4\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0" + + "\1\4\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4\2\0" + + "\37\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4\1\0" + + "\4\4\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4\1\0" + + "\1\4\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4\16\0" + + "\11\5\56\0\125\4\14\0\u026c\4\2\0\10\4\12\0\32\4\5\0" + + "\113\4\3\0\3\4\17\0\15\4\1\0\4\4\3\5\13\0\22\4" + + "\3\5\13\0\22\4\2\5\14\0\15\4\1\0\3\4\1\0\2\5" + + "\14\0\64\4\40\5\3\0\1\4\3\0\2\4\1\5\2\0\12\5" + + "\41\0\3\5\2\0\12\5\6\0\130\4\10\0\51\4\1\5\126\0" + + "\35\4\3\0\14\5\4\0\14\5\12\0\12\5\36\4\2\0\5\4" + + "\u038b\0\154\4\224\0\234\4\4\0\132\4\6\0\26\4\2\0\6\4" + + "\2\0\46\4\2\0\6\4\2\0\10\4\1\0\1\4\1\0\1\4" + + "\1\0\1\4\1\0\37\4\2\0\65\4\1\0\7\4\1\0\1\4" + + "\3\0\3\4\1\0\7\4\3\0\4\4\2\0\6\4\4\0\15\4" + + "\5\0\3\4\1\0\7\4\17\0\4\5\32\0\5\5\20\0\2\4" + + "\23\0\1\4\13\0\4\5\6\0\6\5\1\0\1\4\15\0\1\4" + + "\40\0\22\4\36\0\15\5\4\0\1\5\3\0\6\5\27\0\1\4" + + "\4\0\1\4\2\0\12\4\1\0\1\4\3\0\5\4\6\0\1\4" + + "\1\0\1\4\1\0\1\4\1\0\4\4\1\0\3\4\1\0\7\4" + + "\3\0\3\4\5\0\5\4\26\0\44\4\u0e81\0\3\4\31\0\11\4" + + "\6\5\1\0\5\4\2\0\5\4\4\0\126\4\2\0\2\5\2\0" + + "\3\4\1\0\137\4\5\0\50\4\4\0\136\4\21\0\30\4\70\0" + + "\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4\u215c\0" + + "\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4\1\5" + + "\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4\1\0" + + "\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0" + + "\15\4\3\0\20\5\20\0\4\5\17\0\2\4\30\0\3\4\31\0" + + "\1\4\6\0\5\4\1\0\207\4\2\0\1\5\4\0\1\4\13\0" + + "\12\5\7\0\32\4\4\0\1\4\1\0\32\4\12\0\132\4\3\0" + + "\6\4\2\0\6\4\2\0\6\4\2\0\3\4\3\0\2\4\3\0" + + "\2\4\22\0\3\5\4\0"; + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ACTION_PACKED_0 = + "\2\0\2\1\1\2\1\3\1\1\1\3\7\2\1\1" + + "\1\4\1\5\1\6\1\7\1\10\2\2\1\11\2\12" + + "\1\1\1\13\1\14\1\0\1\14\2\0\7\2\1\0" + + "\3\2\1\15\1\16\1\17\1\20\1\21\1\22\1\16" + + "\1\23\1\24\1\25\1\26\1\14\4\0\6\2\1\27" + + "\4\2\1\16\2\0\1\30\2\2\1\31\6\2\1\32" + + "\1\0\7\2\1\33\1\0\1\34\6\2\1\0\4\2" + + "\1\35\1\36\1\0\1\37\1\40\2\2\1\0\1\41" + + "\1\42\20\0\1\43"; + + private static int[] zzUnpackAction() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150" + + "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\u02a0\0\u02d0" + + "\0\140\0\140\0\140\0\140\0\140\0\u0300\0\u0330\0\u0360" + + "\0\u0390\0\140\0\u03c0\0\140\0\360\0\u03f0\0\u0420\0\u0450" + + "\0\u0480\0\u04b0\0\u04e0\0\u0510\0\u0540\0\u0570\0\u05a0\0\u05d0" + + "\0\u0600\0\u0630\0\u0660\0\u0690\0\140\0\u06c0\0\140\0\140" + + "\0\140\0\140\0\u06f0\0\140\0\140\0\140\0\140\0\u0720" + + "\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0\0\u0810\0\u0840\0\u0870" + + "\0\u08a0\0\u08d0\0\140\0\u0900\0\u0930\0\u0960\0\u0990\0\140" + + "\0\u09c0\0\u09f0\0\300\0\u0a20\0\u0a50\0\300\0\u0a80\0\u0ab0" + + "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\140\0\u0ba0\0\u0bd0\0\u0c00" + + "\0\u0c30\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\300\0\u0d20\0\300" + + "\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u0ea0" + + "\0\u0ed0\0\u0f00\0\u0f30\0\300\0\300\0\u0f60\0\300\0\300" + + "\0\u0f90\0\u0fc0\0\u0ff0\0\300\0\300\0\u1020\0\u1050\0\u1080" + + "\0\u10b0\0\u10e0\0\u1110\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200" + + "\0\u1230\0\u1260\0\u1290\0\u12c0\0\u12f0\0\140"; + + private static int[] zzUnpackRowMap() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + private static final String ZZ_TRANS_PACKED_0 = + "\3\3\1\4\1\5\1\3\1\6\1\7\1\10\1\11" + + "\2\3\1\12\1\13\1\3\2\5\1\14\1\15\1\5" + + "\1\16\1\5\1\17\5\5\1\3\1\20\1\5\1\3" + + "\1\10\1\3\1\21\1\22\1\23\1\24\1\25\1\26" + + "\5\5\1\27\1\3\1\10\1\30\1\31\1\32\36\30" + + "\1\33\1\34\15\30\63\0\1\4\60\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\6\0\1\35\1\0" + + "\1\35\13\0\1\36\10\0\1\37\1\36\1\0\1\35" + + "\16\0\1\35\6\0\1\35\1\0\1\10\24\0\1\40" + + "\2\0\1\10\16\0\1\10\6\0\1\10\1\0\1\10" + + "\13\0\1\36\10\0\1\37\1\36\1\0\1\10\16\0" + + "\1\10\4\0\3\5\1\0\2\5\1\41\1\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\5" + + "\1\42\1\0\7\5\1\43\5\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\3\5\1\44\11\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\1\45\1\5\1\0\15\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" + + "\1\46\3\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\5\5" + + "\1\47\1\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\1\50\1\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\6\0\1\37\1\0" + + "\1\37\24\0\1\51\2\0\1\37\16\0\1\37\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\11\5\1\52" + + "\1\5\1\53\1\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\13\5\1\54\1\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\1\30\2\0\36\30" + + "\2\0\15\30\2\0\1\32\55\0\2\55\1\0\3\55" + + "\1\56\5\55\1\57\5\55\1\60\4\55\1\61\1\62" + + "\7\55\1\63\1\64\1\65\12\55\1\66\1\67\1\56" + + "\6\0\1\70\1\71\1\70\26\0\1\71\1\70\16\0" + + "\1\70\6\0\1\37\1\0\1\37\13\0\1\36\11\0" + + "\1\36\1\0\1\37\16\0\1\37\6\0\1\37\1\0" + + "\1\37\27\0\1\37\16\0\1\37\6\0\1\72\1\0" + + "\1\73\27\0\1\73\16\0\1\73\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\74\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\14\5\1\75\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\13\5\1\76\1\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" + + "\1\77\11\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\7\5\1\100\5\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\1\101\6\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\2\5\1\102\4\5\1\0\1\5\35\0" + + "\1\103\26\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\1\5\1\104\1\105\12\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\1\5\1\106\5\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\14\5\1\107\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\6\0" + + "\1\63\31\0\1\63\16\0\1\63\6\0\1\110\31\0" + + "\1\110\16\0\1\110\6\0\1\70\1\0\1\70\27\0" + + "\1\70\16\0\1\70\13\0\1\111\52\0\1\73\1\0" + + "\1\73\2\0\1\111\24\0\1\73\16\0\1\73\17\0" + + "\1\112\44\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\14\5\1\113\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\3\5\1\114\11\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\5\5\1\115\7\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\5\5\1\116\7\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\14\5" + + "\1\117\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\5\5\1\120\7\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\3\5\1\121\11\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\4\5\1\122\10\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" + + "\1\5\1\0\1\5\6\0\3\5\1\123\3\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\1\5\1\124" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\42\0\1\125\35\0\1\126\43\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\2\5\1\127\12\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" + + "\1\130\3\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\2\5\1\131\12\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\6\5\1\132\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\5\5\1\133\7\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\13\5\1\134" + + "\1\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\13\5\1\135\1\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\5\5\1\136\7\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\15\0\1\137\46\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" + + "\1\5\1\0\1\5\6\0\1\5\1\140\5\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\1\141\1\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\1\5" + + "\1\142\5\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\2\5\1\143\12\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" + + "\1\0\1\5\6\0\1\5\1\144\5\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" + + "\1\145\11\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\4\5" + + "\1\146\2\5\1\0\1\5\21\0\1\147\42\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\13\5\1\150\1\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\2\5" + + "\1\151\12\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\152" + + "\1\5\1\0\15\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\3\5\1\153\11\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\5\5\1\154\7\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\5\5\1\155" + + "\7\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\22\0\1\156\41\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\14\5\1\157\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\3\5\1\160\11\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\5\5\1\161\7\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\5\5" + + "\1\162\7\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\21\0\1\163\42\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\2\5\1\164\4\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" + + "\1\0\1\5\6\0\2\5\1\165\4\5\1\0\1\5" + + "\23\0\1\166\60\0\1\167\60\0\1\170\60\0\1\171" + + "\42\0\1\172\75\0\1\173\54\0\1\174\63\0\1\175" + + "\60\0\1\176\47\0\1\177\60\0\1\200\61\0\1\201" + + "\63\0\1\202\61\0\1\203\60\0\1\204\60\0\1\205" + + "\36\0\1\206\44\0"; + + private static int[] zzUnpackTrans() { + int[] result = new int[4896]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; + + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state + * aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\2\0\1\11\15\1\5\11\4\1\1\11\1\1\1\11" + + "\1\1\1\0\1\1\2\0\7\1\1\0\3\1\1\11" + + "\1\1\4\11\1\1\4\11\1\1\4\0\6\1\1\11" + + "\4\1\1\11\2\0\12\1\1\11\1\0\10\1\1\0" + + "\7\1\1\0\6\1\1\0\4\1\1\0\2\1\20\0" + + "\1\11"; + + private static int[] zzUnpackAttribute() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } + + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is the source of + * the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read from + * input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + /** + * denotes if the user-EOF-code has already been executed + */ + private boolean zzEOFDone; + + /* user code: */ + StringBuffer string = new StringBuffer(); + boolean isMultiname = false; + long multinameId = 0; + + /** + * Create an empty lexer, yyrset will be called later to reset and assign the + * reader + */ + public MethodInfoLexer() { + } + + public int yychar() { + return yychar; + } + + public int yyline() { + return yyline + 1; + } + + /** + * Creates a new scanner There is also a java.io.InputStream version of this + * constructor. + * + * @param in the java.io.Reader to read input from. + */ + public MethodInfoLexer(java.io.Reader in) { + this.zzReader = in; + } + + /** + * Creates a new scanner. There is also java.io.Reader version of this + * constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public MethodInfoLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } + + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1768) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do { + map[j++] = value; + } while (--count > 0); + } + return map; + } + + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { + + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); + + /* translate stored positions */ + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzStartRead = 0; } - if (zzR) { - // peek one character ahead if it is \n (if we have counted one line too much) - boolean zzPeek; - if (zzMarkedPosL < zzEndReadL) - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - else if (zzAtEOF) - zzPeek = false; - else { - boolean eof = zzRefill(); - zzEndReadL = zzEndRead; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - if (eof) - zzPeek = false; - else - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } - if (zzPeek) yyline--; + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; } - zzAction = -1; - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = ZZ_LEXSTATE[zzLexicalState]; + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); + if (numRead > 0) { + zzEndRead += numRead; + return false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; + } else { + zzBuffer[zzEndRead++] = (char) c; + return false; + } + } - zzForAction: { - while (true) { - - if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL[zzCurrentPosL++]; - else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } - else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; + // numRead < 0 + return true; + } + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) { + zzReader.close(); + } + } + + /** + * Resets the scanner to read from a new input stream. Does not close the old + * reader. + * + * All internal variables are reset, the old input stream cannot be + * reused (internal buffer is discarded and lost). Lexical state is set to + * ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); + } + + /** + * Returns the character at position pos from the matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. A value from 0 to + * yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of yypushback(int) and a + * match-all fallback rule) this method will only be called with things that + * "Can't Possibly Happen". If this method is called, something is seriously + * wrong (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done in error fallback + * rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. This number must + * not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) { + zzScanError(ZZ_PUSHBACK_2BIG); + } + + zzMarkedPos -= number; + } + + /** + * Resumes scanning until the next regular expression is matched, the end of + * input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public ParsedSymbol yylex() throws java.io.IOException, ParseException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar += zzMarkedPosL - zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) { + zzR = false; + } else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; } - else { - zzInput = zzBufferL[zzCurrentPosL++]; + } + + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } else if (zzAtEOF) { + zzPeek = false; + } else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) { + zzPeek = false; + } else { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; - if (zzNext == -1) break zzForAction; - zzState = zzNext; + if (zzPeek) { + yyline--; + } + } + zzAction = -1; - int zzAttributes = zzAttrL[zzState]; - if ( (zzAttributes & 1) == 1 ) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ( (zzAttributes & 8) == 8 ) break zzForAction; - } + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - } + zzState = ZZ_LEXSTATE[zzLexicalState]; + + + zzForAction: + { + while (true) { + + if (zzCurrentPosL < zzEndReadL) { + zzInput = zzBufferL[zzCurrentPosL++]; + } else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) { + break zzForAction; + } + zzState = zzNext; + + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) { + break zzForAction; + } + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 2: { + return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + } + case 36: + break; + case 8: { + return new ParsedSymbol(ParsedSymbol.TYPE_ASSIGN); + } + case 37: + break; + case 24: { + return new ParsedSymbol(ParsedSymbol.TYPE_NULL); + } + case 38: + break; + case 22: { + string.append('\''); + } + case 39: + break; + case 3: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + } + case 40: + break; + case 33: { + return new ParsedSymbol(ParsedSymbol.TYPE_UNDEFINED); + } + case 41: + break; + case 34: { + return new ParsedSymbol(ParsedSymbol.TYPE_PROTECTED); + } + case 42: + break; + case 28: { + return new ParsedSymbol(ParsedSymbol.TYPE_STATIC); + } + case 43: + break; + case 9: { + string.append(yytext()); + } + case 44: + break; + case 14: { + char val = (char) Integer.parseInt(yytext().substring(1), 8); + string.append(val); + } + case 45: + break; + case 29: { + return new ParsedSymbol(ParsedSymbol.TYPE_PRIVATE); + } + case 46: + break; + case 5: { + return new ParsedSymbol(ParsedSymbol.TYPE_COLON); + } + case 47: + break; + case 18: { + string.append('\r'); + } + case 48: + break; + case 25: { + return new ParsedSymbol(ParsedSymbol.TYPE_TRUE); + } + case 49: + break; + case 6: { + return new ParsedSymbol(ParsedSymbol.TYPE_COMMA); + } + case 50: + break; + case 35: { + String s = yytext(); + long ns = Long.parseLong(s.substring(3, s.length() - 2)); + return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE, new Long(ns)); + } + case 51: + break; + case 27: { + return new ParsedSymbol(ParsedSymbol.TYPE_FALSE); + } + case 52: + break; + case 11: { + yybegin(YYINITIAL); + // length also includes the trailing quote + if (isMultiname) { + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + } else { + return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); + } + } + case 53: + break; + case 17: { + string.append('\b'); + } + case 54: + break; + case 10: { + throw new ParseException("Unterminated string at end of line", yyline + 1); + } + case 55: + break; + case 4: { + isMultiname = false; + yybegin(STRING); + string.setLength(0); + } + case 56: + break; + case 32: { + return new ParsedSymbol(ParsedSymbol.TYPE_EXPLICIT); + } + case 57: + break; + case 16: { + string.append('\t'); + } + case 58: + break; + case 12: { + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + } + case 59: + break; + case 31: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTERNAL); + } + case 60: + break; + case 23: { + return new ParsedSymbol(ParsedSymbol.TYPE_DOTS); + } + case 61: + break; + case 19: { + string.append('\\'); + } + case 62: + break; + case 7: { + return new ParsedSymbol(ParsedSymbol.TYPE_STAR); + } + case 63: + break; + case 13: { + throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); + } + case 64: + break; + case 30: { + return new ParsedSymbol(ParsedSymbol.TYPE_PACKAGE); + } + case 65: + break; + case 26: { + isMultiname = true; + String s = yytext(); + multinameId = Long.parseLong(s.substring(2, s.length() - 2)); + yybegin(STRING); + string.setLength(0); + } + case 66: + break; + case 15: { + string.append('\n'); + } + case 67: + break; + case 21: { + string.append('\f'); + } + case 68: + break; + case 20: { + string.append('\"'); + } + case 69: + break; + case 1: { + } + case 70: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return new ParsedSymbol(ParsedSymbol.TYPE_EOF); + } + } else { + zzScanError(ZZ_NO_MATCH); + } + } } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 2: - { return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER,yytext()); - } - case 36: break; - case 8: - { return new ParsedSymbol(ParsedSymbol.TYPE_ASSIGN); - } - case 37: break; - case 24: - { return new ParsedSymbol(ParsedSymbol.TYPE_NULL); - } - case 38: break; - case 22: - { string.append( '\'' ); - } - case 39: break; - case 3: - { return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER,new Long(Long.parseLong((yytext())))); - } - case 40: break; - case 33: - { return new ParsedSymbol(ParsedSymbol.TYPE_UNDEFINED); - } - case 41: break; - case 34: - { return new ParsedSymbol(ParsedSymbol.TYPE_PROTECTED); - } - case 42: break; - case 28: - { return new ParsedSymbol(ParsedSymbol.TYPE_STATIC); - } - case 43: break; - case 9: - { string.append( yytext() ); - } - case 44: break; - case 14: - { char val = (char) Integer.parseInt(yytext().substring(1),8); - string.append( val ); - } - case 45: break; - case 29: - { return new ParsedSymbol(ParsedSymbol.TYPE_PRIVATE); - } - case 46: break; - case 5: - { return new ParsedSymbol(ParsedSymbol.TYPE_COLON); - } - case 47: break; - case 18: - { string.append( '\r' ); - } - case 48: break; - case 25: - { return new ParsedSymbol(ParsedSymbol.TYPE_TRUE); - } - case 49: break; - case 6: - { return new ParsedSymbol(ParsedSymbol.TYPE_COMMA); - } - case 50: break; - case 35: - { String s=yytext(); - long ns=Long.parseLong(s.substring(3,s.length()-2)); - return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE,new Long(ns)); - } - case 51: break; - case 27: - { return new ParsedSymbol(ParsedSymbol.TYPE_FALSE); - } - case 52: break; - case 11: - { yybegin(YYINITIAL); - // length also includes the trailing quote - if(isMultiname){ - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME,new Long(multinameId)); - }else{ - return new ParsedSymbol(ParsedSymbol.TYPE_STRING,string.toString()); - } - } - case 53: break; - case 17: - { string.append( '\b' ); - } - case 54: break; - case 10: - { throw new ParseException("Unterminated string at end of line",yyline+1); - } - case 55: break; - case 4: - { isMultiname=false; - yybegin(STRING); - string.setLength(0); - } - case 56: break; - case 32: - { return new ParsedSymbol(ParsedSymbol.TYPE_EXPLICIT); - } - case 57: break; - case 16: - { string.append( '\t' ); - } - case 58: break; - case 12: - { return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT,new Double(Double.parseDouble((yytext())))); - } - case 59: break; - case 31: - { return new ParsedSymbol(ParsedSymbol.TYPE_INTERNAL); - } - case 60: break; - case 23: - { return new ParsedSymbol(ParsedSymbol.TYPE_DOTS); - } - case 61: break; - case 19: - { string.append( '\\' ); - } - case 62: break; - case 7: - { return new ParsedSymbol(ParsedSymbol.TYPE_STAR); - } - case 63: break; - case 13: - { throw new ParseException("Illegal escape sequence \""+yytext()+"\"",yyline+1); - } - case 64: break; - case 30: - { return new ParsedSymbol(ParsedSymbol.TYPE_PACKAGE); - } - case 65: break; - case 26: - { isMultiname=true; - String s=yytext(); - multinameId=Long.parseLong(s.substring(2,s.length()-2)); - yybegin(STRING); - string.setLength(0); - } - case 66: break; - case 15: - { string.append( '\n' ); - } - case 67: break; - case 21: - { string.append( '\f' ); - } - case 68: break; - case 20: - { string.append( '\"' ); - } - case 69: break; - case 1: - { - } - case 70: break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { - return new ParsedSymbol(ParsedSymbol.TYPE_EOF); - } - } - else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } - - + } } diff --git a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoParser.java b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoParser.java index c628a381f..1303ee5f7 100644 --- a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoParser.java +++ b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/MethodInfoParser.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.methodinfo_parser; import com.jpexs.asdec.Main; @@ -33,311 +32,279 @@ import java.util.List; */ public class MethodInfoParser { - public static boolean parseSlotConst(String text,TraitSlotConst trait,ABC abc) throws ParseException{ + public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws ParseException { MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); ParsedSymbol symb; - int type_index=-1; - ValueKind value=new ValueKind(0,0); - try{ - ParsedSymbol symbType=lexer.yylex(); - if(symbType.type==ParsedSymbol.TYPE_STAR) - { - type_index=0; - }else if(symbType.type==ParsedSymbol.TYPE_MULTINAME){ - type_index=(int)(long)(Long)symbType.value; - }else{ - throw new ParseException("Multiname or * expected", lexer.yyline()); + int type_index = -1; + ValueKind value = new ValueKind(0, 0); + try { + ParsedSymbol symbType = lexer.yylex(); + if (symbType.type == ParsedSymbol.TYPE_STAR) { + type_index = 0; + } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { + type_index = (int) (long) (Long) symbType.value; + } else { + throw new ParseException("Multiname or * expected", lexer.yyline()); + } + ParsedSymbol symbEqual = lexer.yylex(); + if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { + ParsedSymbol symbValue; + String nstype = ""; + do { + symbValue = lexer.yylex(); + if (symbValue.type >= 8 && symbValue.type <= 13) { + nstype = nstype + symbValue.type + ":"; } - ParsedSymbol symbEqual=lexer.yylex(); - if(symbEqual.type==ParsedSymbol.TYPE_ASSIGN) - { - ParsedSymbol symbValue; - String nstype=""; - do{ - symbValue=lexer.yylex(); - if(symbValue.type>=8&&symbValue.type<=13){ - nstype=nstype+symbValue.type+":"; + } while (symbValue.type >= 8 && symbValue.type <= 13); + if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { + throw new ParseException("Namespace expected", lexer.yyline()); + } + int id = 0; + switch (symbValue.type) { + case ParsedSymbol.TYPE_INTEGER: + value = new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int); + break; + case ParsedSymbol.TYPE_FLOAT: + value = new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double); + break; + case ParsedSymbol.TYPE_STRING: + value = new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8); + break; + case ParsedSymbol.TYPE_TRUE: + value = new ValueKind(0, ValueKind.CONSTANT_True); + break; + case ParsedSymbol.TYPE_FALSE: + value = new ValueKind(0, ValueKind.CONSTANT_False); + break; + case ParsedSymbol.TYPE_NULL: + value = new ValueKind(0, ValueKind.CONSTANT_Null); + break; + case ParsedSymbol.TYPE_UNDEFINED: + value = new ValueKind(0, ValueKind.CONSTANT_Undefined); + break; + case ParsedSymbol.TYPE_NAMESPACE: + if (nstype.equals("9:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace); + } else if (nstype.equals("9:10:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs); + } else if (nstype.equals("13:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace); + } else if (nstype.equals("12:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace); + } else if (nstype.equals("11:13:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs); + } else if (nstype.equals("8:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs); + } else if (nstype.equals("")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace); + } else { + throw new ParseException("Invalid type of namespace", lexer.yyline()); } - }while(symbValue.type>=8&&symbValue.type<=13); - if((!nstype.equals(""))&&(symbValue.type!=ParsedSymbol.TYPE_NAMESPACE)) - { - throw new ParseException("Namespace expected", lexer.yyline()); - } - int id=0; - switch(symbValue.type) - { - case ParsedSymbol.TYPE_INTEGER: - value=new ValueKind(abc.constants.forceGetIntId((Long)symbValue.value),ValueKind.CONSTANT_Int); - break; - case ParsedSymbol.TYPE_FLOAT: - value=new ValueKind(abc.constants.forceGetDoubleId((Double)symbValue.value),ValueKind.CONSTANT_Double); - break; - case ParsedSymbol.TYPE_STRING: - value=new ValueKind(abc.constants.forceGetStringId((String)symbValue.value),ValueKind.CONSTANT_Utf8); - break; - case ParsedSymbol.TYPE_TRUE: - value=new ValueKind(0,ValueKind.CONSTANT_True); - break; - case ParsedSymbol.TYPE_FALSE: - value=new ValueKind(0,ValueKind.CONSTANT_False); - break; - case ParsedSymbol.TYPE_NULL: - value=new ValueKind(0,ValueKind.CONSTANT_Null); - break; - case ParsedSymbol.TYPE_UNDEFINED: - value=new ValueKind(0,ValueKind.CONSTANT_Undefined); - break; - case ParsedSymbol.TYPE_NAMESPACE: - if(nstype.equals("9:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PackageNamespace); - }else - if(nstype.equals("9:10:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PackageInternalNs); - }else - if(nstype.equals("13:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_ProtectedNamespace); - }else - if(nstype.equals("12:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_ExplicitNamespace); - }else - if(nstype.equals("11:13:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_StaticProtectedNs); - }else - if(nstype.equals("8:")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PrivateNs); - }else if(nstype.equals("")){ - value=new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_Namespace); - }else{ - throw new ParseException("Invalid type of namespace", lexer.yyline()); - } - break; - default: - throw new ParseException("Unexpected symbol", lexer.yyline()); - } - symb=lexer.yylex(); - if(symb.type!=ParsedSymbol.TYPE_EOF){ - throw new ParseException("Unexpected symbol", lexer.yyline()); - } - }else if(symbEqual.type==ParsedSymbol.TYPE_EOF){ - - } else { + break; + default: throw new ParseException("Unexpected symbol", lexer.yyline()); - } - }catch(IOException ex) - { + } + symb = lexer.yylex(); + if (symb.type != ParsedSymbol.TYPE_EOF) { + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { + } else { + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + } catch (IOException ex) { return false; } - trait.type_index=type_index; - trait.value_kind=value.value_kind; - trait.value_index=value.value_index; + trait.type_index = type_index; + trait.value_kind = value.value_kind; + trait.value_index = value.value_index; return true; } + public static boolean parseReturnType(String text, MethodInfo update) throws ParseException { MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); ParsedSymbol symb; - int type=-1; + int type = -1; try { symb = lexer.yylex(); - if(symb.type==ParsedSymbol.TYPE_STAR) - { - type=0; - }else if(symb.type==ParsedSymbol.TYPE_MULTINAME){ - type=(int)(long)(Long)symb.value; - }else{ + if (symb.type == ParsedSymbol.TYPE_STAR) { + type = 0; + } else if (symb.type == ParsedSymbol.TYPE_MULTINAME) { + type = (int) (long) (Long) symb.value; + } else { throw new ParseException("Multiname or * expected", lexer.yyline()); } symb = lexer.yylex(); - if(symb.type!=ParsedSymbol.TYPE_EOF) - { + if (symb.type != ParsedSymbol.TYPE_EOF) { throw new ParseException("Only one return type allowed", lexer.yyline()); } - update.ret_type=type; + update.ret_type = type; return true; } catch (IOException ex) { - } return false; } - public static boolean parseParams(String text, MethodInfo update,ABC abc) throws ParseException { + + public static boolean parseParams(String text, MethodInfo update, ABC abc) throws ParseException { MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); - List paramNames=new ArrayList(); - List paramTypes=new ArrayList(); - List optionalValues=new ArrayList(); - boolean hasOptional=false; - boolean needsRest=false; + List paramNames = new ArrayList(); + List paramTypes = new ArrayList(); + List optionalValues = new ArrayList(); + boolean hasOptional = false; + boolean needsRest = false; try { ParsedSymbol symb; symb = lexer.yylex(); - while (symb.type != ParsedSymbol.TYPE_EOF) - { - if(symb.type==ParsedSymbol.TYPE_DOTS) - { - needsRest=true; + while (symb.type != ParsedSymbol.TYPE_EOF) { + if (symb.type == ParsedSymbol.TYPE_DOTS) { + needsRest = true; symb = lexer.yylex(); - if(symb.type!=ParsedSymbol.TYPE_IDENTIFIER) - { + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { throw new ParseException("Identifier expected", lexer.yyline()); } symb = lexer.yylex(); - if(symb.type!=ParsedSymbol.TYPE_EOF) - { + if (symb.type != ParsedSymbol.TYPE_EOF) { throw new ParseException("End expected after rest params", lexer.yyline()); } break; - } + } - if(symb.type!=ParsedSymbol.TYPE_IDENTIFIER) - { + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { throw new ParseException("Identifier expected", lexer.yyline()); } - paramNames.add((String)symb.value); + paramNames.add((String) symb.value); symb = lexer.yylex(); - if(symb.type==ParsedSymbol.TYPE_COLON){ - ParsedSymbol symbType=lexer.yylex(); - if(symbType.type==ParsedSymbol.TYPE_STAR) - { + if (symb.type == ParsedSymbol.TYPE_COLON) { + ParsedSymbol symbType = lexer.yylex(); + if (symbType.type == ParsedSymbol.TYPE_STAR) { paramTypes.add(new Long(0)); - }else if(symbType.type==ParsedSymbol.TYPE_MULTINAME){ - paramTypes.add((Long)symbType.value); - }else{ + } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { + paramTypes.add((Long) symbType.value); + } else { throw new ParseException("Multiname or * expected", lexer.yyline()); } - ParsedSymbol symbEqual=lexer.yylex(); - if(symbEqual.type==ParsedSymbol.TYPE_ASSIGN) - { - hasOptional=true; + ParsedSymbol symbEqual = lexer.yylex(); + if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { + hasOptional = true; ParsedSymbol symbValue; - String nstype=""; - do{ - symbValue=lexer.yylex(); - if(symbValue.type>=8&&symbValue.type<=13){ - nstype=nstype+symbValue.type+":"; - } - }while(symbValue.type>=8&&symbValue.type<=13); - if((!nstype.equals(""))&&(symbValue.type!=ParsedSymbol.TYPE_NAMESPACE)) - { + String nstype = ""; + do { + symbValue = lexer.yylex(); + if (symbValue.type >= 8 && symbValue.type <= 13) { + nstype = nstype + symbValue.type + ":"; + } + } while (symbValue.type >= 8 && symbValue.type <= 13); + if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { throw new ParseException("Namespace expected", lexer.yyline()); } - int id=0; - switch(symbValue.type) - { + int id = 0; + switch (symbValue.type) { case ParsedSymbol.TYPE_INTEGER: - optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long)symbValue.value),ValueKind.CONSTANT_Int)); + optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int)); break; case ParsedSymbol.TYPE_FLOAT: - optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double)symbValue.value),ValueKind.CONSTANT_Double)); + optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double)); break; case ParsedSymbol.TYPE_STRING: - optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String)symbValue.value),ValueKind.CONSTANT_Utf8)); + optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8)); break; case ParsedSymbol.TYPE_TRUE: - optionalValues.add(new ValueKind(0,ValueKind.CONSTANT_True)); + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_True)); break; case ParsedSymbol.TYPE_FALSE: - optionalValues.add(new ValueKind(0,ValueKind.CONSTANT_False)); + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_False)); break; case ParsedSymbol.TYPE_NULL: - optionalValues.add(new ValueKind(0,ValueKind.CONSTANT_Null)); + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Null)); break; case ParsedSymbol.TYPE_UNDEFINED: - optionalValues.add(new ValueKind(0,ValueKind.CONSTANT_Undefined)); + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Undefined)); break; case ParsedSymbol.TYPE_NAMESPACE: - if(nstype.equals("9:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PackageNamespace)); - }else - if(nstype.equals("9:10:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PackageInternalNs)); - }else - if(nstype.equals("13:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_ProtectedNamespace)); - }else - if(nstype.equals("12:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_ExplicitNamespace)); - }else - if(nstype.equals("11:13:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_StaticProtectedNs)); - }else - if(nstype.equals("8:")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_PrivateNs)); - }else if(nstype.equals("")){ - optionalValues.add(new ValueKind((int)(long)(Long)symbValue.value,ValueKind.CONSTANT_Namespace)); - }else{ + if (nstype.equals("9:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace)); + } else if (nstype.equals("9:10:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs)); + } else if (nstype.equals("13:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace)); + } else if (nstype.equals("12:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace)); + } else if (nstype.equals("11:13:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs)); + } else if (nstype.equals("8:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs)); + } else if (nstype.equals("")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace)); + } else { throw new ParseException("Invalid type of namespace", lexer.yyline()); } break; default: throw new ParseException("Unexpected symbol", lexer.yyline()); } - symb=lexer.yylex(); - if(symb.type==ParsedSymbol.TYPE_COMMA){ - - }else if(symb.type==ParsedSymbol.TYPE_EOF){ + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_COMMA) { + } else if (symb.type == ParsedSymbol.TYPE_EOF) { break; } - }else if(symbEqual.type==ParsedSymbol.TYPE_COMMA){ - if(hasOptional) - { + } else if (symbEqual.type == ParsedSymbol.TYPE_COMMA) { + if (hasOptional) { throw new ParseException("Parameter must have default value", lexer.yyline()); } - }else if(symbEqual.type==ParsedSymbol.TYPE_EOF){ - if(hasOptional) - { + } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { + if (hasOptional) { throw new ParseException("Parameter must have default value", lexer.yyline()); } break; } else { throw new ParseException("Unexpected symbol", lexer.yyline()); } - }else if(symb.type==ParsedSymbol.TYPE_COMMA){ - - }else if(symb.type==ParsedSymbol.TYPE_EOF){ + } else if (symb.type == ParsedSymbol.TYPE_COMMA) { + } else if (symb.type == ParsedSymbol.TYPE_EOF) { break; - }else{ + } else { throw new ParseException("Unexpected symbol", lexer.yyline()); } symb = lexer.yylex(); - } + } } catch (IOException iex) { return false; } - if(needsRest&&(!optionalValues.isEmpty())){ + if (needsRest && (!optionalValues.isEmpty())) { throw new ParseException("Rest parameter canot be combined with default values", lexer.yyline()); } - update.param_types=new int[paramTypes.size()]; - for(int p=0;p. */ - package com.jpexs.asdec.abc.methodinfo_parser; - public class ParseException extends Exception { - public long line; - public String text; - public ParseException(String text, long line) { - super("ParseException:" + text + " on line " + line); - this.line = line; - this.text = text; - } + public long line; + public String text; + + public ParseException(String text, long line) { + super("ParseException:" + text + " on line " + line); + this.line = line; + this.text = text; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/ParsedSymbol.java b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/ParsedSymbol.java index 9faeb6839..e86b9fad9 100644 --- a/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/ParsedSymbol.java +++ b/trunk/src/com/jpexs/asdec/abc/methodinfo_parser/ParsedSymbol.java @@ -14,53 +14,42 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.methodinfo_parser; - public class ParsedSymbol { - public int type; - public Object value; - public static final int TYPE_INTEGER = 1; - public static final int TYPE_FLOAT = 2; - public static final int TYPE_TRUE = 3; - public static final int TYPE_FALSE = 4; - public static final int TYPE_NULL = 5; - public static final int TYPE_UNDEFINED = 6; - public static final int TYPE_STRING = 7; + public int type; + public Object value; + public static final int TYPE_INTEGER = 1; + public static final int TYPE_FLOAT = 2; + public static final int TYPE_TRUE = 3; + public static final int TYPE_FALSE = 4; + public static final int TYPE_NULL = 5; + public static final int TYPE_UNDEFINED = 6; + public static final int TYPE_STRING = 7; + //8-12 namespace prefix + public static final int TYPE_PRIVATE = 8; + public static final int TYPE_PACKAGE = 9; + public static final int TYPE_INTERNAL = 10; + public static final int TYPE_STATIC = 11; + public static final int TYPE_EXPLICIT = 12; + public static final int TYPE_PROTECTED = 13; + public static final int TYPE_NAMESPACE = 14; + public static final int TYPE_COLON = 15; + public static final int TYPE_COMMA = 16; + public static final int TYPE_DOTS = 17; + public static final int TYPE_MULTINAME = 18; + public static final int TYPE_IDENTIFIER = 19; + public static final int TYPE_EOF = 20; + public static final int TYPE_STAR = 21; + public static final int TYPE_ASSIGN = 22; - //8-12 namespace prefix - public static final int TYPE_PRIVATE = 8; - public static final int TYPE_PACKAGE = 9; - public static final int TYPE_INTERNAL = 10; - public static final int TYPE_STATIC = 11; - public static final int TYPE_EXPLICIT = 12; - public static final int TYPE_PROTECTED = 13; - public static final int TYPE_NAMESPACE = 14; - - public static final int TYPE_COLON = 15; - public static final int TYPE_COMMA = 16; - public static final int TYPE_DOTS = 17; - - - - - public static final int TYPE_MULTINAME = 18; - public static final int TYPE_IDENTIFIER = 19; - - - public static final int TYPE_EOF = 20; - public static final int TYPE_STAR = 21; - public static final int TYPE_ASSIGN = 22; - - public ParsedSymbol(int type, Object value) { - this.type = type; - this.value = value; - } - - public ParsedSymbol(int type) { - this.type = type; - } + public ParsedSymbol(int type, Object value) { + this.type = type; + this.value = value; + } + public ParsedSymbol(int type) { + this.type = type; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/ABCException.java b/trunk/src/com/jpexs/asdec/abc/types/ABCException.java index c7835c1d9..da49dc608 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/ABCException.java +++ b/trunk/src/com/jpexs/asdec/abc/types/ABCException.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.AVM2Code; @@ -22,43 +21,46 @@ import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.avm2.ConvertException; import com.jpexs.asdec.helpers.Helper; - public class ABCException { - public int start; - public int end; - public int target; - public int type_index; - public int name_index; - @Override - public String toString() { - return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type_index=" + type_index + " name_index=" + name_index; - } + public int start; + public int end; + public int target; + public int type_index; + public int name_index; - public String toString(ConstantPool constants) { - return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants) + "\" name=\"" + getVarName(constants) + "\""; - } + @Override + public String toString() { + return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type_index=" + type_index + " name_index=" + name_index; + } - public String toString(ConstantPool constants, AVM2Code code) { - try { - return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants) + " type=\"" + getTypeName(constants) + "\" name=\"" + getVarName(constants) + "\""; - } catch (ConvertException ex) { - return ""; - } - } + public String toString(ConstantPool constants) { + return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants) + "\" name=\"" + getVarName(constants) + "\""; + } - public boolean isFinally() { - return (name_index == 0) && (type_index == 0); - } + public String toString(ConstantPool constants, AVM2Code code) { + try { + return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants) + " type=\"" + getTypeName(constants) + "\" name=\"" + getVarName(constants) + "\""; + } catch (ConvertException ex) { + return ""; + } + } - public String getVarName(ConstantPool constants) { - if (name_index == 0) return ""; - return constants.constant_multiname[name_index].getName(constants); - } + public boolean isFinally() { + return (name_index == 0) && (type_index == 0); + } - public String getTypeName(ConstantPool constants) { - if (type_index == 0) return "*"; - return constants.constant_multiname[type_index].getName(constants); - } + public String getVarName(ConstantPool constants) { + if (name_index == 0) { + return ""; + } + return constants.constant_multiname[name_index].getName(constants); + } + public String getTypeName(ConstantPool constants) { + if (type_index == 0) { + return "*"; + } + return constants.constant_multiname[type_index].getName(constants); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/ClassInfo.java b/trunk/src/com/jpexs/asdec/abc/types/ClassInfo.java index 6f44dbfe0..6942968e8 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/ClassInfo.java +++ b/trunk/src/com/jpexs/asdec/abc/types/ClassInfo.java @@ -14,30 +14,27 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.types.traits.Traits; - public class ClassInfo { - public int cinit_index; //MethodInfo - static initializer - public Traits static_traits; + public int cinit_index; //MethodInfo - static initializer + public Traits static_traits; - @Override - public String toString() { - return "method_index=" + cinit_index + "\r\n" + static_traits.toString(); - } + @Override + public String toString() { + return "method_index=" + cinit_index + "\r\n" + static_traits.toString(); + } + public String toString(ABC abc) { + return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc); + } - public String toString(ABC abc) { - return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc); - } - - public String getStaticVarsStr(ConstantPool constants,ABC abc) { - return static_traits.convert(constants, "\tstatic ",abc); - } + public String getStaticVarsStr(ConstantPool constants, ABC abc) { + return static_traits.convert(constants, "\tstatic ", abc); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/Decimal.java b/trunk/src/com/jpexs/asdec/abc/types/Decimal.java index b30d50832..a1a70a82c 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/Decimal.java +++ b/trunk/src/com/jpexs/asdec/abc/types/Decimal.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; /** @@ -22,16 +21,15 @@ package com.jpexs.asdec.abc.types; * @author JPEXS */ public class Decimal { + public byte data[]; - public Decimal(byte data[]) - { - this.data=data; + + public Decimal(byte data[]) { + this.data = data; } @Override public String toString() { return new String(data); } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/types/InstanceInfo.java b/trunk/src/com/jpexs/asdec/abc/types/InstanceInfo.java index d80406b44..5b763a3ef 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/InstanceInfo.java +++ b/trunk/src/com/jpexs/asdec/abc/types/InstanceInfo.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.ABC; @@ -22,63 +21,63 @@ import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.abc.types.traits.Traits; import com.jpexs.asdec.helpers.Helper; - public class InstanceInfo { - public int name_index; - public int super_index; - public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs - public int protectedNS; //if flags & 8 - public int interfaces[]; - public int iinit_index; // MethodInfo - constructor - public Traits instance_traits; + public int name_index; + public int super_index; + public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs + public int protectedNS; //if flags & 8 + public int interfaces[]; + public int iinit_index; // MethodInfo - constructor + public Traits instance_traits; + public static final int CLASS_SEALED = 1; //not dynamic + public static final int CLASS_FINAL = 2; + public static final int CLASS_INTERFACE = 4; + public static final int CLASS_PROTECTEDNS = 8; - public static final int CLASS_SEALED = 1; //not dynamic - public static final int CLASS_FINAL = 2; - public static final int CLASS_INTERFACE = 4; - public static final int CLASS_PROTECTEDNS = 8; + @Override + public String toString() { + return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(); + } - @Override - public String toString() { - return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(); - } + public String toString(ABC abc) { + String supIndexStr = "[nothing]"; + if (super_index > 0) { + abc.constants.constant_multiname[super_index].toString(abc.constants); + } + return "name_index=" + abc.constants.constant_multiname[name_index].toString(abc.constants) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc); + } + public String getClassHeaderStr(ConstantPool constants) { + String supIndexStr = ""; + if (super_index > 0) { + supIndexStr = " extends " + constants.constant_multiname[super_index].getName(constants);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index + } + String modifiers = ""; + Namespace ns = constants.constant_multiname[name_index].getNamespace(constants); + modifiers = ns.getPrefix(constants); + if (!modifiers.equals("")) { + modifiers += " "; + } - public String toString(ABC abc) { - String supIndexStr = "[nothing]"; - if (super_index > 0) - abc.constants.constant_multiname[super_index].toString(abc.constants); - return "name_index=" + abc.constants.constant_multiname[name_index].toString(abc.constants) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc); - } + if ((flags & CLASS_FINAL) == CLASS_FINAL) { + modifiers = "final "; + } + if ((flags & CLASS_SEALED) == 0) { + modifiers = modifiers + "dynamic "; + } + String objType = "class "; + if ((flags & CLASS_INTERFACE) == CLASS_INTERFACE) { + objType = "interface "; + } + return modifiers + objType + constants.constant_multiname[name_index].getName(constants) + supIndexStr; + } - public String getClassHeaderStr(ConstantPool constants) { - String supIndexStr = ""; - if (super_index > 0) - supIndexStr = " extends " + constants.constant_multiname[super_index].getName(constants);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index - String modifiers = ""; - Namespace ns = constants.constant_multiname[name_index].getNamespace(constants); - modifiers = ns.getPrefix(constants); - if (!modifiers.equals("")) modifiers += " "; - - if ((flags & CLASS_FINAL) == CLASS_FINAL) { - modifiers = "final "; - } - if ((flags & CLASS_SEALED) == 0) { - modifiers = modifiers + "dynamic "; - } - String objType = "class "; - if ((flags & CLASS_INTERFACE) == CLASS_INTERFACE) { - objType = "interface "; - } - return modifiers + objType + constants.constant_multiname[name_index].getName(constants) + supIndexStr; - } - - public String getInstanceVarsStr(ConstantPool constants,ABC abc) { - return instance_traits.convert(constants, "\t",abc); - } - - public Multiname getName(ConstantPool constants) { - return constants.constant_multiname[name_index]; - } + public String getInstanceVarsStr(ConstantPool constants, ABC abc) { + return instance_traits.convert(constants, "\t", abc); + } + public Multiname getName(ConstantPool constants) { + return constants.constant_multiname[name_index]; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/MetadataInfo.java b/trunk/src/com/jpexs/asdec/abc/types/MetadataInfo.java index 2e0972712..52957cf8b 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/MetadataInfo.java +++ b/trunk/src/com/jpexs/asdec/abc/types/MetadataInfo.java @@ -14,41 +14,40 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.helpers.Helper; - public class MetadataInfo { - public int name_index; - public int keys[]; - public int values[]; + public int name_index; + public int keys[]; + public int values[]; - public MetadataInfo(int name_index, int[] keys, int[] values) { - this.name_index = name_index; - this.keys = keys; - this.values = values; - } + public MetadataInfo(int name_index, int[] keys, int[] values) { + this.name_index = name_index; + this.keys = keys; + this.values = values; + } - @Override - public String toString() { - return "name_index=" + name_index + " keys=" + Helper.intArrToString(keys) + " values=" + Helper.intArrToString(values); - } - - public String toString(ConstantPool constants) { - String s = "name=" + constants.constant_string[name_index]; - if (keys.length > 0) s += "\r\n"; - for (int i = 0; i < keys.length; i++) { - if (keys[i] == 0) { - s += "\"" + constants.constant_string[values[i]] + "\"\r\n"; - } else { - s += "\"" + constants.constant_string[keys[i]] + "\"=\"" + constants.constant_string[values[i]] + "\"\r\n"; - } - } - return s; - } + @Override + public String toString() { + return "name_index=" + name_index + " keys=" + Helper.intArrToString(keys) + " values=" + Helper.intArrToString(values); + } + public String toString(ConstantPool constants) { + String s = "name=" + constants.constant_string[name_index]; + if (keys.length > 0) { + s += "\r\n"; + } + for (int i = 0; i < keys.length; i++) { + if (keys[i] == 0) { + s += "\"" + constants.constant_string[values[i]] + "\"\r\n"; + } else { + s += "\"" + constants.constant_string[keys[i]] + "\"=\"" + constants.constant_string[values[i]] + "\"\r\n"; + } + } + return s; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/MethodBody.java b/trunk/src/com/jpexs/asdec/abc/types/MethodBody.java index ad8688da7..51265750f 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/asdec/abc/types/MethodBody.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.Main; @@ -26,117 +25,108 @@ import com.jpexs.asdec.abc.types.traits.Traits; import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; - public class MethodBody implements Cloneable { - public int method_info; - public int max_stack; - public int max_regs; - public int init_scope_depth; - public int max_scope_depth; - public byte codeBytes[]; - public AVM2Code code; - public ABCException exceptions[] = new ABCException[0]; - public Traits traits = new Traits(); + public int method_info; + public int max_stack; + public int max_regs; + public int init_scope_depth; + public int max_scope_depth; + public byte codeBytes[]; + public AVM2Code code; + public ABCException exceptions[] = new ABCException[0]; + public Traits traits = new Traits(); - @Override - public String toString() { - String s = ""; - s += "method_info=" + method_info + " max_stack=" + max_stack + " max_regs=" + max_regs + " scope_depth=" + init_scope_depth + " max_scope=" + max_scope_depth; - s += "\r\nCode:\r\n" + code.toString(); - return s; - } - - public HashMap getLocalRegNames(ABC abc) - { - HashMap ret=new HashMap(); - for (int i = 1; i <= abc.method_info[this.method_info].param_types.length; i++) { - String paramName="param"+i; - if(abc.method_info[this.method_info].flagHas_paramnames()&&Main.PARAM_NAMES_ENABLE){ - paramName=abc.constants.constant_string[abc.method_info[this.method_info].paramNames[i-1]]; + @Override + public String toString() { + String s = ""; + s += "method_info=" + method_info + " max_stack=" + max_stack + " max_regs=" + max_regs + " scope_depth=" + init_scope_depth + " max_scope=" + max_scope_depth; + s += "\r\nCode:\r\n" + code.toString(); + return s; + } + + public HashMap getLocalRegNames(ABC abc) { + HashMap ret = new HashMap(); + for (int i = 1; i <= abc.method_info[this.method_info].param_types.length; i++) { + String paramName = "param" + i; + if (abc.method_info[this.method_info].flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { + paramName = abc.constants.constant_string[abc.method_info[this.method_info].paramNames[i - 1]]; + } + ret.put(i, paramName); + } + int pos = abc.method_info[this.method_info].param_types.length + 1; + if (abc.method_info[this.method_info].flagNeed_arguments()) { + ret.put(pos, "arguments"); + pos++; + } + if (abc.method_info[this.method_info].flagNeed_rest()) { + ret.put(pos, "rest"); + pos++; + } + + HashMap debugRegNames = code.getLocalRegNamesFromDebug(abc); + for (int k : debugRegNames.keySet()) { + ret.put(k, debugRegNames.get(k)); + } + return ret; + } + + public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[]) { + return toString(pcode, isStatic, classIndex, abc, constants, method_info, false); + } + + public String toString(boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], boolean hilight) { + String s = ""; + + //s+="method_info="+method_info+" max_stack="+max_stack+" max_regs="+max_regs+" scope_depth="+scope_depth+" max_scope="+max_scope; + //s+="\r\nCode:\r\n"+ + if (pcode) { + s += code.toASMSource(constants, this); + } else { + try { + s += code.toSource(isStatic, classIndex, abc, constants, method_info, this, hilight, getLocalRegNames(abc)); + s = s.trim(); + if (hilight) { + s = Highlighting.hilighMethod(s, this.method_info); } - ret.put(i, paramName); - } - int pos=abc.method_info[this.method_info].param_types.length+1; - if(abc.method_info[this.method_info].flagNeed_arguments()) - { - ret.put(pos,"arguments"); - pos++; - } - if(abc.method_info[this.method_info].flagNeed_rest()) - { - ret.put(pos,"rest"); - pos++; - } - - HashMap debugRegNames=code.getLocalRegNamesFromDebug(abc); - for(int k:debugRegNames.keySet()) - { - ret.put(k,debugRegNames.get(k)); - } - return ret; - } - - public String toString(boolean pcode,boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[]) { - return toString(pcode,isStatic, classIndex, abc, constants, method_info, false); - } - - public String toString(boolean pcode,boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], boolean hilight) { - String s = ""; - - //s+="method_info="+method_info+" max_stack="+max_stack+" max_regs="+max_regs+" scope_depth="+scope_depth+" max_scope="+max_scope; - //s+="\r\nCode:\r\n"+ - if(pcode){ - s+=code.toASMSource(constants, this); - }else{ - try { - s += code.toSource(isStatic, classIndex, abc, constants, method_info, this, hilight,getLocalRegNames(abc)); - s=s.trim(); - if(hilight) - { - s=Highlighting.hilighMethod(s, this.method_info); - } - } catch (Exception ex) { + } catch (Exception ex) { s = "//error:" + ex.toString(); - } - } - //s+="----------- ORIGINAL ------------\r\n"; - //s+=code.toString(constants); + } + } + //s+="----------- ORIGINAL ------------\r\n"; + //s+=code.toString(constants); /*s+="Exceptions:"; - for(int i=0;i. */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.Main; @@ -23,285 +22,268 @@ import com.jpexs.asdec.abc.avm2.ConstantPool; import com.jpexs.asdec.helpers.Helper; import java.util.HashMap; - public class MethodInfo { - public int param_types[]; - public int ret_type; - public int name_index; //0=no name - // 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames - public int flags; - public ValueKind optional[]; - public int paramNames[]; - private MethodBody body; + public int param_types[]; + public int ret_type; + public int name_index; //0=no name + // 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames + public int flags; + public ValueKind optional[]; + public int paramNames[]; + private MethodBody body; - public void setFlagSetsdxns() - { - flags|=64; - } + public void setFlagSetsdxns() { + flags |= 64; + } - public void setFlagSetsdxns(boolean val) - { - if(val){ - setFlagSetsdxns(); - }else{ - unsetFlagSetsdxns(); - } - } + public void setFlagSetsdxns(boolean val) { + if (val) { + setFlagSetsdxns(); + } else { + unsetFlagSetsdxns(); + } + } - public void unsetFlagSetsdxns() - { - if(flagSetsdxns()){ - flags-=64; - } - } + public void unsetFlagSetsdxns() { + if (flagSetsdxns()) { + flags -= 64; + } + } - public void setFlagNeed_activation() - { - flags|=2; - } + public void setFlagNeed_activation() { + flags |= 2; + } - public void setFlagNeed_activation(boolean val) - { - if(val){ - setFlagNeed_activation(); - }else{ - unsetFlagNeed_activation(); - } - } + public void setFlagNeed_activation(boolean val) { + if (val) { + setFlagNeed_activation(); + } else { + unsetFlagNeed_activation(); + } + } - public void unsetFlagNeed_activation() - { - if(flagNeed_activation()){ - flags-=2; - } - } + public void unsetFlagNeed_activation() { + if (flagNeed_activation()) { + flags -= 2; + } + } - public void setFlagNeed_rest() - { - flags|=4; - } + public void setFlagNeed_rest() { + flags |= 4; + } - public void unsetFlagNeed_rest() - { - if(flagNeed_rest()){ - flags-=4; - } - } + public void unsetFlagNeed_rest() { + if (flagNeed_rest()) { + flags -= 4; + } + } - public void setFlagNeed_rest(boolean val) - { - if(val){ - setFlagNeed_rest(); - }else{ - unsetFlagNeed_rest(); - } - } + public void setFlagNeed_rest(boolean val) { + if (val) { + setFlagNeed_rest(); + } else { + unsetFlagNeed_rest(); + } + } - public void setFlagHas_optional() - { - flags|=8; - } + public void setFlagHas_optional() { + flags |= 8; + } - public void unsetFlagHas_optional() - { - if(flagHas_optional()){ - flags-=8; - } - } + public void unsetFlagHas_optional() { + if (flagHas_optional()) { + flags -= 8; + } + } - public void setFlagHas_optional(boolean val) - { - if(val){ - setFlagHas_optional(); - }else{ - unsetFlagHas_optional(); - } - } + public void setFlagHas_optional(boolean val) { + if (val) { + setFlagHas_optional(); + } else { + unsetFlagHas_optional(); + } + } - public void setFlagHas_paramnames() - { - flags|=128; - } + public void setFlagHas_paramnames() { + flags |= 128; + } - public void unsetFlagHas_paramnames() - { - if(flagHas_paramnames()){ - flags-=128; - } - } + public void unsetFlagHas_paramnames() { + if (flagHas_paramnames()) { + flags -= 128; + } + } - public void setFlagHas_paramnames(boolean val) - { - if(val){ - setFlagHas_paramnames(); - }else{ - unsetFlagHas_paramnames(); - } - } + public void setFlagHas_paramnames(boolean val) { + if (val) { + setFlagHas_paramnames(); + } else { + unsetFlagHas_paramnames(); + } + } - public boolean flagNeed_arguments() { - return (flags & 1) == 1; - } + public boolean flagNeed_arguments() { + return (flags & 1) == 1; + } - public boolean flagNeed_activation() { - return (flags & 2) == 2; - } + public boolean flagNeed_activation() { + return (flags & 2) == 2; + } - public boolean flagNeed_rest() { - return (flags & 4) == 4; - } + public boolean flagNeed_rest() { + return (flags & 4) == 4; + } - public boolean flagHas_optional() { - return (flags & 8) == 8; - } + public boolean flagHas_optional() { + return (flags & 8) == 8; + } - public boolean flagIgnore_restHas_optional() { - return (flags & 16) == 16; - } + public boolean flagIgnore_restHas_optional() { + return (flags & 16) == 16; + } - public boolean flagExplicit() { - return (flags & 32) == 32; - } + public boolean flagExplicit() { + return (flags & 32) == 32; + } - public boolean flagSetsdxns() { - return (flags & 64) == 64; - } + public boolean flagSetsdxns() { + return (flags & 64) == 64; + } - public boolean flagHas_paramnames() { - return (flags & 128) == 128; - } + public boolean flagHas_paramnames() { + return (flags & 128) == 128; + } - public MethodInfo(int param_types[], int ret_type, int name_index, int flags, ValueKind optional[], int paramNames[]) { - this.param_types = param_types; - this.ret_type = ret_type; - this.name_index = name_index; - this.flags = flags; - this.optional = optional; - this.paramNames = paramNames; - } + public MethodInfo(int param_types[], int ret_type, int name_index, int flags, ValueKind optional[], int paramNames[]) { + this.param_types = param_types; + this.ret_type = ret_type; + this.name_index = name_index; + this.flags = flags; + this.optional = optional; + this.paramNames = paramNames; + } - @Override - public String toString() { - String optionalStr = "["; - if (optional != null) { - for (int i = 0; i < optional.length; i++) { - if (i > 0) { - optionalStr += ","; - } - optionalStr += optional[i].toString(); - } - } - optionalStr += "]"; - return "MethodInfo: param_types=" + Helper.intArrToString(param_types) + " ret_type=" + ret_type + " name_index=" + name_index + " flags=" + flags + " optional=" + optionalStr + " paramNames=" + Helper.intArrToString(paramNames); - } - - public String toString(ConstantPool constants) { - String optionalStr = "["; - if (optional != null) { - for (int i = 0; i < optional.length; i++) { - if (i > 0) { - optionalStr += ","; - } - optionalStr += optional[i].toString(constants); - } - } - optionalStr += "]"; - - String param_typesStr = ""; - for (int i = 0; i < param_types.length; i++) { + @Override + public String toString() { + String optionalStr = "["; + if (optional != null) { + for (int i = 0; i < optional.length; i++) { if (i > 0) { - param_typesStr += ","; + optionalStr += ","; } - if (param_types[i] == 0) { - param_typesStr += "*"; - } else { - param_typesStr += constants.constant_multiname[param_types[i]].toString(constants); - } - } + optionalStr += optional[i].toString(); + } + } + optionalStr += "]"; + return "MethodInfo: param_types=" + Helper.intArrToString(param_types) + " ret_type=" + ret_type + " name_index=" + name_index + " flags=" + flags + " optional=" + optionalStr + " paramNames=" + Helper.intArrToString(paramNames); + } - String paramNamesStr = ""; - for (int i = 0; i < paramNames.length; i++) { + public String toString(ConstantPool constants) { + String optionalStr = "["; + if (optional != null) { + for (int i = 0; i < optional.length; i++) { if (i > 0) { - paramNamesStr += ","; + optionalStr += ","; } - paramNamesStr += constants.constant_string[paramNames[i]]; - } + optionalStr += optional[i].toString(constants); + } + } + optionalStr += "]"; - String ret_typeStr = ""; - if (ret_type == 0) { - ret_typeStr += "*"; - } else { - ret_typeStr += constants.constant_multiname[ret_type].toString(constants); - } + String param_typesStr = ""; + for (int i = 0; i < param_types.length; i++) { + if (i > 0) { + param_typesStr += ","; + } + if (param_types[i] == 0) { + param_typesStr += "*"; + } else { + param_typesStr += constants.constant_multiname[param_types[i]].toString(constants); + } + } - return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + constants.constant_string[name_index] + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr; - } + String paramNamesStr = ""; + for (int i = 0; i < paramNames.length; i++) { + if (i > 0) { + paramNamesStr += ","; + } + paramNamesStr += constants.constant_string[paramNames[i]]; + } + String ret_typeStr = ""; + if (ret_type == 0) { + ret_typeStr += "*"; + } else { + ret_typeStr += constants.constant_multiname[ret_type].toString(constants); + } - public String getName(ConstantPool constants) { - if (name_index == 0) return "UNKNOWN"; - return constants.constant_string[name_index]; - } + return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + constants.constant_string[name_index] + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr; + } - public String getParamStr(ConstantPool constants,MethodBody body,ABC abc) { - HashMap localRegNames=new HashMap(); - if(body!=null) - { - localRegNames=body.code.getLocalRegNamesFromDebug(abc); - } - String paramStr = ""; - for (int i = 0; i < param_types.length; i++) { - if (i > 0) { - paramStr += ", "; - } - if(!localRegNames.isEmpty()) - { - paramStr+=localRegNames.get(i+1); - }else if ((paramNames.length > i) && (paramNames[i] != 0) && Main.PARAM_NAMES_ENABLE) { - paramStr += constants.constant_string[paramNames[i]]; - } else { - paramStr += "param" + (i + 1); - } - paramStr += ":"; - if (param_types[i] == 0) { - paramStr += "*"; - } else { - paramStr += constants.constant_multiname[param_types[i]].getName(constants); - } - if (optional != null) { - if (i >= param_types.length - optional.length) { - paramStr += "=" + optional[i - (param_types.length - optional.length)].toString(constants); - } - } - } - if(flagNeed_rest()){ - if((param_types!=null)&&(param_types.length>0)){ - paramStr+=", "; - } - paramStr+="... "; - if(!localRegNames.isEmpty()) - { - paramStr+=localRegNames.get(param_types.length+1); - }else{ - paramStr+="rest"; + public String getName(ConstantPool constants) { + if (name_index == 0) { + return "UNKNOWN"; + } + return constants.constant_string[name_index]; + } + + public String getParamStr(ConstantPool constants, MethodBody body, ABC abc) { + HashMap localRegNames = new HashMap(); + if (body != null) { + localRegNames = body.code.getLocalRegNamesFromDebug(abc); + } + String paramStr = ""; + for (int i = 0; i < param_types.length; i++) { + if (i > 0) { + paramStr += ", "; + } + if (!localRegNames.isEmpty()) { + paramStr += localRegNames.get(i + 1); + } else if ((paramNames.length > i) && (paramNames[i] != 0) && Main.PARAM_NAMES_ENABLE) { + paramStr += constants.constant_string[paramNames[i]]; + } else { + paramStr += "param" + (i + 1); + } + paramStr += ":"; + if (param_types[i] == 0) { + paramStr += "*"; + } else { + paramStr += constants.constant_multiname[param_types[i]].getName(constants); + } + if (optional != null) { + if (i >= param_types.length - optional.length) { + paramStr += "=" + optional[i - (param_types.length - optional.length)].toString(constants); } + } + } + if (flagNeed_rest()) { + if ((param_types != null) && (param_types.length > 0)) { + paramStr += ", "; + } + paramStr += "... "; + if (!localRegNames.isEmpty()) { + paramStr += localRegNames.get(param_types.length + 1); + } else { + paramStr += "rest"; + } - } - return paramStr; - } + } + return paramStr; + } - public String getReturnTypeStr(ConstantPool constants) { - if (ret_type == 0) return "*"; - return constants.constant_multiname[ret_type].getName(constants); - } + public String getReturnTypeStr(ConstantPool constants) { + if (ret_type == 0) { + return "*"; + } + return constants.constant_multiname[ret_type].getName(constants); + } - public void setBody(MethodBody body) { - this.body = body; - } + public void setBody(MethodBody body) { + this.body = body; + } - public MethodBody getBody() { - return body; - } + public MethodBody getBody() { + return body; + } } - diff --git a/trunk/src/com/jpexs/asdec/abc/types/Multiname.java b/trunk/src/com/jpexs/asdec/abc/types/Multiname.java index 4389cedba..d123c6292 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/Multiname.java +++ b/trunk/src/com/jpexs/asdec/abc/types/Multiname.java @@ -14,192 +14,222 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.ConstantPool; import java.util.List; - public class Multiname { - public static final int QNAME = 7; - public static final int QNAMEA = 0x0d; - public static final int RTQNAME = 0x0f; - public static final int RTQNAMEA = 0x10; - public static final int RTQNAMEL = 0x11; - public static final int RTQNAMELA = 0x12; - public static final int MULTINAME = 0x09; - public static final int MULTINAMEA = 0x0e; - public static final int MULTINAMEL = 0x1b; - public static final int MULTINAMELA = 0x1c; - public static final int TYPENAME = 0x1d; - private static final int multinameKinds[] = new int[]{QNAME, QNAMEA, MULTINAME, MULTINAMEA, RTQNAME, RTQNAMEA, MULTINAMEL, RTQNAMEL, RTQNAMELA,MULTINAMELA,TYPENAME}; - private static final String multinameKindNames[] = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA","MultinameLA","TypeName"}; + public static final int QNAME = 7; + public static final int QNAMEA = 0x0d; + public static final int RTQNAME = 0x0f; + public static final int RTQNAMEA = 0x10; + public static final int RTQNAMEL = 0x11; + public static final int RTQNAMELA = 0x12; + public static final int MULTINAME = 0x09; + public static final int MULTINAMEA = 0x0e; + public static final int MULTINAMEL = 0x1b; + public static final int MULTINAMELA = 0x1c; + public static final int TYPENAME = 0x1d; + private static final int multinameKinds[] = new int[]{QNAME, QNAMEA, MULTINAME, MULTINAMEA, RTQNAME, RTQNAMEA, MULTINAMEL, RTQNAMEL, RTQNAMELA, MULTINAMELA, TYPENAME}; + private static final String multinameKindNames[] = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA", "MultinameLA", "TypeName"}; + public int kind = -1; + public int name_index = -1; + public int namespace_index = -1; + public int namespace_set_index = -1; + public int qname_index = -1; //for TypeName + public List params; //for TypeName + public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List params) { + this.kind = kind; + this.name_index = name_index; + this.namespace_index = namespace_index; + this.namespace_set_index = namespace_set_index; + this.qname_index = qname_index; + this.params = params; + } - public int kind = -1; - public int name_index = -1; - public int namespace_index = -1; - public int namespace_set_index = -1; - public int qname_index = -1; //for TypeName - public List params; //for TypeName + public boolean isAttribute() { + if (kind == QNAMEA) { + return true; + } + if (kind == MULTINAMEA) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } + public boolean isRuntime() { + if (kind == RTQNAME) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == MULTINAMEL) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } - public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index,int qname_index,List params) { - this.kind = kind; - this.name_index = name_index; - this.namespace_index = namespace_index; - this.namespace_set_index = namespace_set_index; - this.qname_index = qname_index; - this.params=params; - } + public boolean needsName() { + if (kind == RTQNAMEL) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + if (kind == MULTINAMEL) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } - public boolean isAttribute() { - if (kind == QNAMEA) return true; - if (kind == MULTINAMEA) return true; - if (kind == RTQNAMEA) return true; - if (kind == RTQNAMELA) return true; - if (kind == MULTINAMELA) return true; - return false; - } + public boolean needsNs() { + if (kind == RTQNAME) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == RTQNAMEL) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + return false; + } - public boolean isRuntime() { - if (kind == RTQNAME) return true; - if (kind == RTQNAMEA) return true; - if (kind == MULTINAMEL) return true; - if (kind == MULTINAMELA) return true; - return false; - } - - public boolean needsName() { - if (kind == RTQNAMEL) return true; - if (kind == RTQNAMELA) return true; - if (kind == MULTINAMEL) return true; - if (kind == MULTINAMELA) return true; - return false; - } - - public boolean needsNs() { - if (kind == RTQNAME) return true; - if (kind == RTQNAMEA) return true; - if (kind == RTQNAMEL) return true; - if (kind == RTQNAMELA) return true; - return false; - } - - public String getKindStr() { - String kindStr = "?"; - for (int k = 0; k < multinameKinds.length; k++) { - if (multinameKinds[k] == kind) { - kindStr = multinameKindNames[k]; - break; - } - } - return kindStr; - } - - @Override - public String toString() { - String kindStr = getKindStr(); - return "kind=" + kindStr + " name_index=" + name_index + " namespace_index=" + namespace_index + " namespace_set_index=" + namespace_set_index+" qname_index="+qname_index+" params_size:"+params.size(); - - } - - public String toString(ConstantPool constants) { - String kindStr = "?"; - for (int k = 0; k < multinameKinds.length; k++) { - if (multinameKinds[k] == kind) { - kindStr = multinameKindNames[k] + " "; - break; - } - } - String nameStr = ""; - if (name_index > 0) { - nameStr = constants.constant_string[name_index]; - } - if (name_index == 0) { - nameStr = "*"; - } - String namespaceStr = ""; - if (namespace_index > 0) { - namespaceStr = constants.constant_namespace[namespace_index].toString(constants); - } - if (!namespaceStr.equals("")) - namespaceStr = namespaceStr + "."; - if (namespace_index == 0) { - namespaceStr = "*."; - } - String namespaceSetStr = ""; - if (namespace_set_index > 0) { - namespaceSetStr = " "; - } - String typeNameStr=""; - if(kind==TYPENAME){ - typeNameStr=typeNameToStr(constants); - } - - return namespaceStr + nameStr + namespaceSetStr + typeNameStr; - - } - - private String typeNameToStr(ConstantPool constants){ - String typeNameStr=constants.constant_multiname[qname_index].getName(constants); - if(!params.isEmpty()){ - typeNameStr+=".<"; - for(int i=0;i0){ - typeNameStr+=","; - } - if(params.get(i)!=0){ //What does value 0 mean? - typeNameStr+=constants.constant_multiname[params.get(i)].getName(constants); - } - } - typeNameStr+=">"; + public String getKindStr() { + String kindStr = "?"; + for (int k = 0; k < multinameKinds.length; k++) { + if (multinameKinds[k] == kind) { + kindStr = multinameKindNames[k]; + break; } - return typeNameStr; - } + } + return kindStr; + } - public String getName(ConstantPool constants) { - if(kind==TYPENAME) - { - return typeNameToStr(constants); - } - if (name_index == -1) { - return ""; - } - if (name_index == 0) { - return "*"; - } else { - return (isAttribute() ? "@" : "") + constants.constant_string[name_index]; - } - } + @Override + public String toString() { + String kindStr = getKindStr(); + return "kind=" + kindStr + " name_index=" + name_index + " namespace_index=" + namespace_index + " namespace_set_index=" + namespace_set_index + " qname_index=" + qname_index + " params_size:" + params.size(); - public String getNameWithNamespace(ConstantPool constants){ - String ret=""; - Namespace ns=getNamespace(constants); - if(ns!=null){ - String nsname=ns.getName(constants); - if(!nsname.equals("")) ret+=nsname+"."; - } - ret+=getName(constants); - return ret; - } + } - public Namespace getNamespace(ConstantPool constants) { - if ((namespace_index == 0) || (namespace_index == -1)) { - return null; - } else { - return constants.constant_namespace[namespace_index]; - } - } + public String toString(ConstantPool constants) { + String kindStr = "?"; + for (int k = 0; k < multinameKinds.length; k++) { + if (multinameKinds[k] == kind) { + kindStr = multinameKindNames[k] + " "; + break; + } + } + String nameStr = ""; + if (name_index > 0) { + nameStr = constants.constant_string[name_index]; + } + if (name_index == 0) { + nameStr = "*"; + } + String namespaceStr = ""; + if (namespace_index > 0) { + namespaceStr = constants.constant_namespace[namespace_index].toString(constants); + } + if (!namespaceStr.equals("")) { + namespaceStr = namespaceStr + "."; + } + if (namespace_index == 0) { + namespaceStr = "*."; + } + String namespaceSetStr = ""; + if (namespace_set_index > 0) { + namespaceSetStr = " "; + } + String typeNameStr = ""; + if (kind == TYPENAME) { + typeNameStr = typeNameToStr(constants); + } - public NamespaceSet getNamespaceSet(ConstantPool constants) { - if (namespace_set_index == 0) { - return null; - } else { - return constants.constant_namespace_set[namespace_set_index]; - } - } + return namespaceStr + nameStr + namespaceSetStr + typeNameStr; + + } + + private String typeNameToStr(ConstantPool constants) { + String typeNameStr = constants.constant_multiname[qname_index].getName(constants); + if (!params.isEmpty()) { + typeNameStr += ".<"; + for (int i = 0; i < params.size(); i++) { + if (i > 0) { + typeNameStr += ","; + } + if (params.get(i) != 0) { //What does value 0 mean? + typeNameStr += constants.constant_multiname[params.get(i)].getName(constants); + } + } + typeNameStr += ">"; + } + return typeNameStr; + } + + public String getName(ConstantPool constants) { + if (kind == TYPENAME) { + return typeNameToStr(constants); + } + if (name_index == -1) { + return ""; + } + if (name_index == 0) { + return "*"; + } else { + return (isAttribute() ? "@" : "") + constants.constant_string[name_index]; + } + } + + public String getNameWithNamespace(ConstantPool constants) { + String ret = ""; + Namespace ns = getNamespace(constants); + if (ns != null) { + String nsname = ns.getName(constants); + if (!nsname.equals("")) { + ret += nsname + "."; + } + } + ret += getName(constants); + return ret; + } + + public Namespace getNamespace(ConstantPool constants) { + if ((namespace_index == 0) || (namespace_index == -1)) { + return null; + } else { + return constants.constant_namespace[namespace_index]; + } + } + + public NamespaceSet getNamespaceSet(ConstantPool constants) { + if (namespace_set_index == 0) { + return null; + } else { + return constants.constant_namespace_set[namespace_set_index]; + } + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/Namespace.java b/trunk/src/com/jpexs/asdec/abc/types/Namespace.java index 4feb2006a..151186799 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/Namespace.java +++ b/trunk/src/com/jpexs/asdec/abc/types/Namespace.java @@ -14,68 +14,65 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.ConstantPool; - public class Namespace { - public static final int nameSpaceKinds[] = new int[]{8, 5, 22, 23, 24, 25, 26}; - public static final String nameSpaceKindNames[] = new String[]{"Namespace", "PrivateNamespace", "PackageNamespace", "PackageInternalNamespace", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNamespace"}; - public static final String namePrefixes[] = new String[]{"", "private", "public", "", "protected", "explicit", ""}; + public static final int nameSpaceKinds[] = new int[]{8, 5, 22, 23, 24, 25, 26}; + public static final String nameSpaceKindNames[] = new String[]{"Namespace", "PrivateNamespace", "PackageNamespace", "PackageInternalNamespace", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNamespace"}; + public static final String namePrefixes[] = new String[]{"", "private", "public", "", "protected", "explicit", ""}; + public int kind; + public int name_index; - public int kind; - public int name_index; + public Namespace(int kind, int name_index) { + this.kind = kind; + this.name_index = name_index; + } - public Namespace(int kind, int name_index) { - this.kind = kind; - this.name_index = name_index; - } + public String getKindStr() { + String kindStr = "?"; + for (int k = 0; k < nameSpaceKinds.length; k++) { + if (nameSpaceKinds[k] == kind) { + kindStr = nameSpaceKindNames[k]; + break; + } + } + return kindStr; + } - public String getKindStr() { - String kindStr = "?"; - for (int k = 0; k < nameSpaceKinds.length; k++) { - if (nameSpaceKinds[k] == kind) { - kindStr = nameSpaceKindNames[k]; - break; - } - } - return kindStr; - } + @Override + public String toString() { - @Override - public String toString() { + return "Namespace: kind=" + getKindStr() + " name_index=" + name_index; + } - return "Namespace: kind=" + getKindStr() + " name_index=" + name_index; - } + public String toString(ConstantPool constants) { + return getName(constants); //getPrefix(constants)+" "+getName(constants); + } - public String toString(ConstantPool constants) { - return getName(constants); //getPrefix(constants)+" "+getName(constants); - } + public String getNameWithKind(ConstantPool constants) { + String kindStr = getKindStr(); + String nameStr = constants.constant_string[name_index]; + return kindStr + (nameStr.equals("") ? "" : " " + nameStr); + } - public String getNameWithKind(ConstantPool constants) { - String kindStr = getKindStr(); - String nameStr = constants.constant_string[name_index]; - return kindStr + (nameStr.equals("") ? "" : " " + nameStr); - } + public String getPrefix(ConstantPool constants) { + String kindStr = "?"; + for (int k = 0; k < nameSpaceKinds.length; k++) { + if (nameSpaceKinds[k] == kind) { + kindStr = namePrefixes[k]; + break; + } + } + return kindStr; + } - public String getPrefix(ConstantPool constants) { - String kindStr = "?"; - for (int k = 0; k < nameSpaceKinds.length; k++) { - if (nameSpaceKinds[k] == kind) { - kindStr = namePrefixes[k]; - break; - } - } - return kindStr; - } - - public String getName(ConstantPool constants) { - if(name_index==0){ - return "-"; - } - return constants.constant_string[name_index]; - } + public String getName(ConstantPool constants) { + if (name_index == 0) { + return "-"; + } + return constants.constant_string[name_index]; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/NamespaceSet.java b/trunk/src/com/jpexs/asdec/abc/types/NamespaceSet.java index 4cc2f4ab9..fbadb813b 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/NamespaceSet.java +++ b/trunk/src/com/jpexs/asdec/abc/types/NamespaceSet.java @@ -14,24 +14,22 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.ConstantPool; - public class NamespaceSet { - public int namespaces[]; - - public String toString(ConstantPool constants) { - String s = ""; - for (int i = 0; i < this.namespaces.length; i++) { - if (i > 0) s += ", "; - s += constants.constant_namespace[namespaces[i]].getNameWithKind(constants); - } - return s; - } - + public int namespaces[]; + public String toString(ConstantPool constants) { + String s = ""; + for (int i = 0; i < this.namespaces.length; i++) { + if (i > 0) { + s += ", "; + } + s += constants.constant_namespace[namespaces[i]].getNameWithKind(constants); + } + return s; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/ScriptInfo.java b/trunk/src/com/jpexs/asdec/abc/types/ScriptInfo.java index 17b629976..adbbcdad1 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/asdec/abc/types/ScriptInfo.java @@ -14,27 +14,22 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.types.traits.Traits; - public class ScriptInfo { - public int init_index; //MethodInfo - public Traits traits; - - @Override - public String toString() { - return "method_index=" + init_index + "\r\n" + traits.toString(); - } - - - public String toString(ABC abc) { - return "method_index=" + init_index + "\r\n" + traits.toString(abc); - } + public int init_index; //MethodInfo + public Traits traits; + @Override + public String toString() { + return "method_index=" + init_index + "\r\n" + traits.toString(); + } + public String toString(ABC abc) { + return "method_index=" + init_index + "\r\n" + traits.toString(abc); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java b/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java index 28d1698f4..c8a181f85 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java +++ b/trunk/src/com/jpexs/asdec/abc/types/ValueKind.java @@ -14,107 +14,105 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types; import com.jpexs.asdec.abc.avm2.ConstantPool; - public class ValueKind { - public static final int CONSTANT_Decimal = 0x02; //decimal - public static final int CONSTANT_Int = 0x03;// integer - public static final int CONSTANT_UInt = 0x04;// uinteger - public static final int CONSTANT_Double = 0x06;// double - public static final int CONSTANT_Utf8 = 0x01;// string - public static final int CONSTANT_True = 0x0B;// - - public static final int CONSTANT_False = 0x0A;// - - public static final int CONSTANT_Null = 0x0C;// - - public static final int CONSTANT_Undefined = 0x00;// - - public static final int CONSTANT_Namespace = 0x08;// namespace - public static final int CONSTANT_PackageNamespace = 0x16;// namespace - public static final int CONSTANT_PackageInternalNs = 0x17;// Namespace - public static final int CONSTANT_ProtectedNamespace = 0x18;// Namespace - public static final int CONSTANT_ExplicitNamespace = 0x19;// Namespace - public static final int CONSTANT_StaticProtectedNs = 0x1A;// Namespace - public static final int CONSTANT_PrivateNs = 0x05;// namespace - private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06,0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; - private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double","Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; - public int value_index; - public int value_kind; + public static final int CONSTANT_Decimal = 0x02; //decimal + public static final int CONSTANT_Int = 0x03;// integer + public static final int CONSTANT_UInt = 0x04;// uinteger + public static final int CONSTANT_Double = 0x06;// double + public static final int CONSTANT_Utf8 = 0x01;// string + public static final int CONSTANT_True = 0x0B;// - + public static final int CONSTANT_False = 0x0A;// - + public static final int CONSTANT_Null = 0x0C;// - + public static final int CONSTANT_Undefined = 0x00;// - + public static final int CONSTANT_Namespace = 0x08;// namespace + public static final int CONSTANT_PackageNamespace = 0x16;// namespace + public static final int CONSTANT_PackageInternalNs = 0x17;// Namespace + public static final int CONSTANT_ProtectedNamespace = 0x18;// Namespace + public static final int CONSTANT_ExplicitNamespace = 0x19;// Namespace + public static final int CONSTANT_StaticProtectedNs = 0x1A;// Namespace + public static final int CONSTANT_PrivateNs = 0x05;// namespace + private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06, 0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; + private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double", "Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; + public int value_index; + public int value_kind; - public ValueKind(int value_index, int value_kind) { - this.value_index = value_index; - this.value_kind = value_kind; - } + public ValueKind(int value_index, int value_kind) { + this.value_index = value_index; + this.value_kind = value_kind; + } - @Override - public String toString() { - String s = ""; - s += value_index + ":"; - boolean found = false; - for (int i = 0; i < optionalKinds.length; i++) { - if (optionalKinds[i] == value_kind) { - s += optionalKindNames[i]; - found = true; - break; - } - } - if (!found) { - s += "?"; - } - return s; - } + @Override + public String toString() { + String s = ""; + s += value_index + ":"; + boolean found = false; + for (int i = 0; i < optionalKinds.length; i++) { + if (optionalKinds[i] == value_kind) { + s += optionalKindNames[i]; + found = true; + break; + } + } + if (!found) { + s += "?"; + } + return s; + } - public String toString(ConstantPool constants) { - String ret = "?"; - switch (value_kind) { - case CONSTANT_Int: - ret = "" + constants.constant_int[value_index]; - break; - case CONSTANT_UInt: - ret = "" + constants.constant_uint[value_index]; - break; - case CONSTANT_Double: - ret = "" + constants.constant_double[value_index]; - break; - case CONSTANT_Decimal: - ret = "" + constants.constant_decimal[value_index]; - break; - case CONSTANT_Utf8: - ret = "\"" + constants.constant_string[value_index] + "\""; - break; - case CONSTANT_True: - ret = "true"; - break; - case CONSTANT_False: - ret = "false"; - break; - case CONSTANT_Null: - ret = "null"; - break; - case CONSTANT_Undefined: - ret = "undefined"; - break; - case CONSTANT_Namespace: - ret = "ns[" +value_index+"]"; - break; - case CONSTANT_PackageInternalNs: - ret = "package internal ns[" +value_index+"]"; - break; - case CONSTANT_ProtectedNamespace: - ret = "protected ns[" +value_index+"]"; - break; - case CONSTANT_ExplicitNamespace: - ret = "explicit ns[" +value_index+"]"; - break; - case CONSTANT_StaticProtectedNs: - ret = "static protected ns[" +value_index+"]"; - break; - case CONSTANT_PrivateNs: - ret = "private ns[" +value_index+"]"; - break; - } - return ret; - } + public String toString(ConstantPool constants) { + String ret = "?"; + switch (value_kind) { + case CONSTANT_Int: + ret = "" + constants.constant_int[value_index]; + break; + case CONSTANT_UInt: + ret = "" + constants.constant_uint[value_index]; + break; + case CONSTANT_Double: + ret = "" + constants.constant_double[value_index]; + break; + case CONSTANT_Decimal: + ret = "" + constants.constant_decimal[value_index]; + break; + case CONSTANT_Utf8: + ret = "\"" + constants.constant_string[value_index] + "\""; + break; + case CONSTANT_True: + ret = "true"; + break; + case CONSTANT_False: + ret = "false"; + break; + case CONSTANT_Null: + ret = "null"; + break; + case CONSTANT_Undefined: + ret = "undefined"; + break; + case CONSTANT_Namespace: + ret = "ns[" + value_index + "]"; + break; + case CONSTANT_PackageInternalNs: + ret = "package internal ns[" + value_index + "]"; + break; + case CONSTANT_ProtectedNamespace: + ret = "protected ns[" + value_index + "]"; + break; + case CONSTANT_ExplicitNamespace: + ret = "explicit ns[" + value_index + "]"; + break; + case CONSTANT_StaticProtectedNs: + ret = "static protected ns[" + value_index + "]"; + break; + case CONSTANT_PrivateNs: + ret = "private ns[" + value_index + "]"; + break; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/Trait.java b/trunk/src/com/jpexs/asdec/abc/types/traits/Trait.java index bd96aa5c6..54e1600cf 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/Trait.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/Trait.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; @@ -24,72 +23,70 @@ import com.jpexs.asdec.abc.types.Multiname; import com.jpexs.asdec.abc.types.Namespace; import com.jpexs.asdec.helpers.Helper; - public class Trait { - public int name_index; - public int kindType; - public int kindFlags; - public int metadata[] = new int[0]; - public long fileOffset; - public byte bytes[]; - public static final int ATTR_Final = 0x1; - public static final int ATTR_Override = 0x2; - public static final int ATTR_Metadata = 0x4; + public int name_index; + public int kindType; + public int kindFlags; + public int metadata[] = new int[0]; + public long fileOffset; + public byte bytes[]; + public static final int ATTR_Final = 0x1; + public static final int ATTR_Override = 0x2; + public static final int ATTR_Metadata = 0x4; + public static final int TRAIT_SLOT = 0; + public static final int TRAIT_METHOD = 1; + public static final int TRAIT_GETTER = 2; + public static final int TRAIT_SETTER = 3; + public static final int TRAIT_CLASS = 4; + public static final int TRAIT_FUNCTION = 5; + public static final int TRAIT_CONST = 6; - public static final int TRAIT_SLOT = 0; - public static final int TRAIT_METHOD = 1; - public static final int TRAIT_GETTER = 2; - public static final int TRAIT_SETTER = 3; - public static final int TRAIT_CLASS = 4; - public static final int TRAIT_FUNCTION = 5; - public static final int TRAIT_CONST = 6; + public String getModifiers(ConstantPool constants, boolean isStatic) { + String ret = ""; + if ((kindFlags & ATTR_Override) > 0) { + ret += "override"; + } + Multiname m = getMultiName(constants); + if (m != null) { + Namespace ns = m.getNamespace(constants); + if (ns != null) { + ret += " " + ns.getPrefix(constants); + } + } + if (isStatic) { + ret += " static"; + } + if ((kindFlags & ATTR_Final) > 0) { + if (!isStatic) { + ret += " final"; + } + } + return ret.trim(); + } + @Override + public String toString() { + return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - public String getModifiers(ConstantPool constants, boolean isStatic) { - String ret = ""; - if ((kindFlags & ATTR_Override) > 0) { - ret += "override"; - } - Multiname m = getMultiName(constants); - if (m != null) { - Namespace ns = m.getNamespace(constants); - if (ns != null) { - ret += " " + ns.getPrefix(constants); - } - } - if (isStatic) - ret += " static"; - if ((kindFlags & ATTR_Final) > 0) { - if (!isStatic) { - ret += " final"; - } - } - return ret.trim(); - } + public String toString(ABC abc) { + return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - @Override - public String toString() { - return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } + public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc) { + return convert(constants, methodInfo, abc, false); + } - public String toString(ABC abc) { - return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } + public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) { + return constants.constant_multiname[name_index].toString(constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc) { - return convert(constants, methodInfo, abc,false); - } - - public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc,boolean isStatic) { - return constants.constant_multiname[name_index].toString(constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } - - public Multiname getMultiName(ConstantPool constants) { - if (name_index == 0) { - return null; - } else { - return constants.constant_multiname[name_index]; - } - } + public Multiname getMultiName(ConstantPool constants) { + if (name_index == 0) { + return null; + } else { + return constants.constant_multiname[name_index]; + } + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitClass.java index d88994e3e..0f8a8bbfb 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitClass.java @@ -14,20 +14,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.helpers.Helper; - public class TraitClass extends Trait { - public int slot_id; - public int class_info; + public int slot_id; + public int class_info; - @Override - public String toString(ABC abc) { - return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc) { + return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitFunction.java index 3db6866d6..3ad7813ad 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitFunction.java @@ -14,20 +14,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.helpers.Helper; - public class TraitFunction extends Trait { - public int slot_index; - public int method_info; + public int slot_index; + public int method_info; - @Override - public String toString(ABC abc) { - return "Function " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_index + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc) { + return "Function " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_index + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitMethodGetterSetter.java index 41703222d..be896a682 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitMethodGetterSetter.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; @@ -23,32 +22,34 @@ import com.jpexs.asdec.abc.types.MethodBody; import com.jpexs.asdec.abc.types.MethodInfo; import com.jpexs.asdec.helpers.Helper; - public class TraitMethodGetterSetter extends Trait { - public int disp_id; //compiler assigned value that helps overriding - public int method_info; + public int disp_id; //compiler assigned value that helps overriding + public int method_info; - @Override - public String toString(ABC abc) { - return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); - } - - @Override - public String convert(ConstantPool constants, MethodInfo[] methodInfo,ABC abc, boolean isStatic) { - String modifier = getModifiers(constants, isStatic) + " "; - if (modifier.equals(" ")) modifier = ""; - String addKind = ""; - if (kindType == TRAIT_GETTER) addKind = "get "; - if (kindType == TRAIT_SETTER) addKind = "set "; - MethodBody body=abc.findBody(method_info); - return modifier + "function " + addKind + getMethodName(constants) + "(" + methodInfo[method_info].getParamStr(constants,body,abc) + ") : " + methodInfo[method_info].getReturnTypeStr(constants); - } - - - public String getMethodName(ConstantPool constants) { - return constants.constant_multiname[name_index].getName(constants); - } + @Override + public String toString(ABC abc) { + return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); + } + @Override + public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) { + String modifier = getModifiers(constants, isStatic) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + String addKind = ""; + if (kindType == TRAIT_GETTER) { + addKind = "get "; + } + if (kindType == TRAIT_SETTER) { + addKind = "set "; + } + MethodBody body = abc.findBody(method_info); + return modifier + "function " + addKind + getMethodName(constants) + "(" + methodInfo[method_info].getParamStr(constants, body, abc) + ") : " + methodInfo[method_info].getReturnTypeStr(constants); + } + public String getMethodName(ConstantPool constants) { + return constants.constant_multiname[name_index].getName(constants); + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitSlotConst.java index f955c8364..7e5f74176 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/TraitSlotConst.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; @@ -26,64 +25,62 @@ import com.jpexs.asdec.helpers.Helper; import com.jpexs.asdec.helpers.Highlighting; import java.util.HashMap; - public class TraitSlotConst extends Trait { - public int slot_id; - public int type_index; - public int value_index; - public int value_kind; + public int slot_id; + public int type_index; + public int value_index; + public int value_kind; + public TreeItem assignedValue; - public TreeItem assignedValue; + @Override + public String toString(ABC abc) { + String typeStr = "*"; + if (type_index > 0) { + typeStr = abc.constants.constant_multiname[type_index].toString(abc.constants); + } + return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc.constants) + " metadata=" + Helper.intArrToString(metadata); + } - @Override - public String toString(ABC abc) { - String typeStr = "*"; - if (type_index > 0) { - typeStr = abc.constants.constant_multiname[type_index].toString(abc.constants); - } - return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc.constants) + " metadata=" + Helper.intArrToString(metadata); - } + public String getNameValueStr(ConstantPool constants) { + String typeStr = "*"; + if (type_index > 0) { + typeStr = constants.constant_multiname[type_index].getName(constants); + } + String valueStr = ""; + if (value_kind != 0) { + valueStr = " = " + (new ValueKind(value_index, value_kind)).toString(constants); + } - public String getNameValueStr(ConstantPool constants) { - String typeStr = "*"; - if (type_index > 0) { - typeStr = constants.constant_multiname[type_index].getName(constants); - } - String valueStr = ""; - if (value_kind != 0) { - valueStr = " = " + (new ValueKind(value_index, value_kind)).toString(constants); - } + if (assignedValue != null) { + valueStr = " = " + Highlighting.stripHilights(assignedValue.toString(constants, new HashMap())); + } - if (assignedValue != null) { - valueStr = " = " + Highlighting.stripHilights(assignedValue.toString(constants,new HashMap())); - } + String slotconst = "var"; + if (kindType == TRAIT_CONST) { + slotconst = "const"; + } + return slotconst + " " + getName(constants) + ":" + typeStr + valueStr; + } - String slotconst = "var"; - if (kindType == TRAIT_CONST) { - slotconst = "const"; - } - return slotconst + " " + getName(constants) + ":" + typeStr + valueStr; - } + public String getName(ConstantPool constants) { + return constants.constant_multiname[name_index].getName(constants); + } - public String getName(ConstantPool constants) - { - return constants.constant_multiname[name_index].getName(constants); - } - - @Override - public String convert(ConstantPool constants, MethodInfo[] methodInfo,ABC abc, boolean isStatic) { - String modifier = getModifiers(constants, isStatic) + " "; - if (modifier.equals(" ")) modifier = ""; - return modifier + getNameValueStr(constants); - } + @Override + public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) { + String modifier = getModifiers(constants, isStatic) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + return modifier + getNameValueStr(constants); + } - public boolean isConst(){ - return kindType == TRAIT_CONST; - } - - public boolean isVar(){ - return kindType == TRAIT_SLOT; - } + public boolean isConst() { + return kindType == TRAIT_CONST; + } + public boolean isVar() { + return kindType == TRAIT_SLOT; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/types/traits/Traits.java b/trunk/src/com/jpexs/asdec/abc/types/traits/Traits.java index 9f9b0d6e3..6c6516dbd 100644 --- a/trunk/src/com/jpexs/asdec/abc/types/traits/Traits.java +++ b/trunk/src/com/jpexs/asdec/abc/types/traits/Traits.java @@ -14,44 +14,46 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.types.traits; import com.jpexs.asdec.abc.ABC; import com.jpexs.asdec.abc.avm2.ConstantPool; - public class Traits { - public Trait traits[] = new Trait[0]; - @Override - public String toString() { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) s += "\r\n"; - s += traits[t].toString(); - } - return s; - } + public Trait traits[] = new Trait[0]; + @Override + public String toString() { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n"; + } + s += traits[t].toString(); + } + return s; + } - public String toString(ABC abc) { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) s += "\r\n"; - s += traits[t].toString(abc); - } - return s; - } - - public String convert(ConstantPool constants, String prefix,ABC abc) { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) s += "\r\n"; - s += prefix + traits[t].convert(constants, null,abc); - } - return s; - } - + public String toString(ABC abc) { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n"; + } + s += traits[t].toString(abc); + } + return s; + } + public String convert(ConstantPool constants, String prefix, ABC abc) { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n"; + } + s += prefix + traits[t].convert(constants, null, abc); + } + return s; + } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java index af1dc1660..eb4255aad 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ClassNameMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -23,16 +22,14 @@ import com.jpexs.asdec.abc.ABC; * * @author JPEXS */ -public class ClassNameMultinameUsage extends InsideClassMultinameUsage -{ +public class ClassNameMultinameUsage extends InsideClassMultinameUsage { - public ClassNameMultinameUsage(int multinameIndex,int classIndex) - { - super(multinameIndex,classIndex); + public ClassNameMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); } @Override public String toString(ABC abc) { - return "class "+abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java index 0e86ad1bb..b03b81e26 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -28,23 +27,19 @@ import com.jpexs.asdec.abc.types.traits.Traits; */ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { - public ConstVarMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,traits,parentTraitIndex); + public ConstVarMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); } @Override public String toString(ABC abc) { - return super.toString(abc)+" "+ - (parentTraitIndex>-1? - (isStatic? - (((TraitMethodGetterSetter)abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc,isStatic)): - (((TraitMethodGetterSetter)abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc,isStatic)) - ) - : - "")+ - ((TraitSlotConst)traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,isStatic) - ; + return super.toString(abc) + " " + + (parentTraitIndex > -1 + ? (isStatic + ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic)) + : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))) + : "") + + ((TraitSlotConst) traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc, isStatic); } public int getTraitIndex() { @@ -54,8 +49,4 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { public boolean isStatic() { return isStatic; } - - - - } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java index 769a8837d..42458bb6c 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarNameMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -24,15 +23,14 @@ import com.jpexs.asdec.abc.types.traits.Traits; * * @author JPEXS */ -public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage{ +public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage { - public ConstVarNameMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,traits,parentTraitIndex); + public ConstVarNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); } @Override public String toString(ABC abc) { - return super.toString(abc)+" name"; + return super.toString(abc) + " name"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java index 93a05aeed..d6c92178f 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ConstVarTypeMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -24,15 +23,14 @@ import com.jpexs.asdec.abc.types.traits.Traits; * * @author JPEXS */ -public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage{ +public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage { - public ConstVarTypeMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,traits,parentTraitIndex); + public ConstVarTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); } @Override public String toString(ABC abc) { - return super.toString(abc)+" type"; + return super.toString(abc) + " type"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java index a75b56e8e..cfe2c178d 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ExtendsMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -25,15 +24,12 @@ import com.jpexs.asdec.abc.ABC; */ public class ExtendsMultinameUsage extends InsideClassMultinameUsage { - - public ExtendsMultinameUsage(int multinameIndex,int classIndex) - { - super(multinameIndex,classIndex); + public ExtendsMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); } @Override public String toString(ABC abc) { - return super.toString(abc)+" extends"; + return super.toString(abc) + " extends"; } - } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java index f250bd999..b6232ea7f 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/ImplementsMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -25,15 +24,12 @@ import com.jpexs.asdec.abc.ABC; */ public class ImplementsMultinameUsage extends InsideClassMultinameUsage { - - public ImplementsMultinameUsage(int multinameIndex,int classIndex) - { - super(multinameIndex,classIndex); + public ImplementsMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); } @Override public String toString(ABC abc) { - return super.toString(abc)+" implements"; + return super.toString(abc) + " implements"; } - } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java index 5a0f14d15..df43814d6 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/InsideClassMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -24,25 +23,24 @@ import com.jpexs.asdec.abc.ABC; * @author JPEXS */ public abstract class InsideClassMultinameUsage extends MultinameUsage { + public int multinameIndex; public int classIndex; - public InsideClassMultinameUsage(int multinameIndex,int classIndex){ - this.multinameIndex=multinameIndex; - this.classIndex=classIndex; + public InsideClassMultinameUsage(int multinameIndex, int classIndex) { + this.multinameIndex = multinameIndex; + this.classIndex = classIndex; } - public String toString(ABC abc){ - return "class "+abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + public String toString(ABC abc) { + return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); } - public int getMultinameIndex(){ + public int getMultinameIndex() { return multinameIndex; } public int getClassIndex() { return classIndex; } - - } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java index 9a09b3531..557434fe4 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodBodyMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -26,13 +25,12 @@ import com.jpexs.asdec.abc.types.traits.Traits; */ public class MethodBodyMultinameUsage extends MethodMultinameUsage { - public MethodBodyMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer,traits,parentTraitIndex); - } + public MethodBodyMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } @Override public String toString(ABC abc) { - return super.toString(abc)+" body"; + return super.toString(abc) + " body"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java index aa0b8a46e..0189416ed 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -29,36 +28,27 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { public boolean isInitializer; - public MethodMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,traits,parentTraitIndex); - this.isInitializer=isInitializer; + public MethodMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); + this.isInitializer = isInitializer; } public boolean isInitializer() { return isInitializer; } - - @Override public String toString(ABC abc) { - return super.toString(abc)+" "+( - isInitializer? - (isStatic? - "class initializer": - "instance initializer") - :( - (parentTraitIndex>-1? - (isStatic? - (((TraitMethodGetterSetter)abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc,isStatic)): - (((TraitMethodGetterSetter)abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc,isStatic)) - )+" " - : - "") - + - (((TraitMethodGetterSetter)traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc,isStatic))) - ); + return super.toString(abc) + " " + (isInitializer + ? (isStatic + ? "class initializer" + : "instance initializer") + : ((parentTraitIndex > -1 + ? (isStatic + ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic)) + : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))) + " " + : "") + + (((TraitMethodGetterSetter) traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc, isStatic)))); } public int getTraitIndex() { @@ -68,8 +58,4 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { public boolean isStatic() { return isStatic; } - - - - } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java index 93d604b10..f1f9317a0 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodNameMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -26,13 +25,12 @@ import com.jpexs.asdec.abc.types.traits.Traits; */ public class MethodNameMultinameUsage extends MethodMultinameUsage { - public MethodNameMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer,traits,parentTraitIndex); - } + public MethodNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } @Override public String toString(ABC abc) { - return super.toString(abc)+" name"; + return super.toString(abc) + " name"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java index a16ed7873..04e59c16f 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodParamsMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -26,13 +25,12 @@ import com.jpexs.asdec.abc.types.traits.Traits; */ public class MethodParamsMultinameUsage extends MethodMultinameUsage { - public MethodParamsMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer,traits,parentTraitIndex); - } + public MethodParamsMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } @Override public String toString(ABC abc) { - return super.toString(abc)+" params"; + return super.toString(abc) + " params"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java index cae8a2b34..52837f3b8 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MethodReturnTypeMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -26,13 +25,12 @@ import com.jpexs.asdec.abc.types.traits.Traits; */ public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage { - public MethodReturnTypeMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,boolean isInitializer,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex,traitIndex,isStatic,isInitializer,traits,parentTraitIndex); - } + public MethodReturnTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } @Override public String toString(ABC abc) { - return super.toString(abc)+" return type"; + return super.toString(abc) + " return type"; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java index d711c982b..d66d4bee6 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/MultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -24,5 +23,6 @@ import com.jpexs.asdec.abc.ABC; * @author JPEXS */ public abstract class MultinameUsage { + public abstract String toString(ABC abc); } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/TraitMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/TraitMultinameUsage.java index e62034df8..785ea4309 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/TraitMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/TraitMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.types.traits.Traits; @@ -24,16 +23,17 @@ import com.jpexs.asdec.abc.types.traits.Traits; * @author JPEXS */ public abstract class TraitMultinameUsage extends InsideClassMultinameUsage { - public int traitIndex ; + + public int traitIndex; public boolean isStatic; public Traits traits; public int parentTraitIndex; - public TraitMultinameUsage(int multinameIndex,int classIndex,int traitIndex,boolean isStatic,Traits traits,int parentTraitIndex) - { - super(multinameIndex,classIndex); - this.traitIndex=traitIndex; - this.isStatic=isStatic; - this.traits=traits; - this.parentTraitIndex=parentTraitIndex; + + public TraitMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex); + this.traitIndex = traitIndex; + this.isStatic = isStatic; + this.traits = traits; + this.parentTraitIndex = parentTraitIndex; } } diff --git a/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java b/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java index 421930c00..6e04cc18a 100644 --- a/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java +++ b/trunk/src/com/jpexs/asdec/abc/usages/TypeNameMultinameUsage.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.abc.usages; import com.jpexs.asdec.abc.ABC; @@ -24,15 +23,15 @@ import com.jpexs.asdec.abc.ABC; * @author JPEXS */ public class TypeNameMultinameUsage extends MultinameUsage { + public int typename_index; - public TypeNameMultinameUsage(int typename_index){ - this.typename_index=typename_index; + public TypeNameMultinameUsage(int typename_index) { + this.typename_index = typename_index; } @Override public String toString(ABC abc) { - return "TypeName "+abc.constants.constant_multiname[typename_index].toString(abc.constants); + return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants); } - } diff --git a/trunk/src/com/jpexs/asdec/action/Action.java b/trunk/src/com/jpexs/asdec/action/Action.java index 1d98c2974..927c67046 100644 --- a/trunk/src/com/jpexs/asdec/action/Action.java +++ b/trunk/src/com/jpexs/asdec/action/Action.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action; import com.jpexs.asdec.Main; @@ -40,915 +39,942 @@ import java.io.IOException; import java.util.*; /** - * Represents one ACTIONRECORD, - * also has some static method to work with Actions + * Represents one ACTIONRECORD, also has some static method to work with Actions */ public class Action { - /** - * Action type identifier - */ - public int actionCode; - /** - * Length of action data - */ - public int actionLength; - private long address; + /** + * Action type identifier + */ + public int actionCode; + /** + * Length of action data + */ + public int actionLength; + private long address; + /** + * String used to indent line when converting to string + */ + public static final String INDENTOPEN = "INDENTOPEN"; + /** + * String used to unindent line when converting to string + */ + public static final String INDENTCLOSE = "INDENTCLOSE"; + /** + * Names of ActionScript properties + */ + public static final String[] propertyNames = new String[]{ + "_x", + "_y", + "_xscale", + "_yscale", + "_currentframe", + "_totalframes", + "_alpha", + "_visible", + "_width", + "_height", + "_rotation", + "_target", + "_framesloaded", + "_name", + "_droptarget", + "_url", + "_highquality", + "_focusrect", + "_soundbuftime", + "_quality", + "_xmouse", + "_ymouse" + }; - /** - * String used to indent line when converting to string - */ - public static final String INDENTOPEN = "INDENTOPEN"; - /** - * String used to unindent line when converting to string - */ - public static final String INDENTCLOSE = "INDENTCLOSE"; + /** + * Constructor + * + * @param actionCode Action type identifier + * @param actionLength Length of action data + */ + public Action(int actionCode, int actionLength) { + this.actionCode = actionCode; + this.actionLength = actionLength; + } - /** - * Names of ActionScript properties - */ - public static final String[] propertyNames = new String[]{ - "_x", - "_y", - "_xscale", - "_yscale", - "_currentframe", - "_totalframes", - "_alpha", - "_visible", - "_width", - "_height", - "_rotation", - "_target", - "_framesloaded", - "_name", - "_droptarget", - "_url", - "_highquality", - "_focusrect", - "_soundbuftime", - "_quality", - "_xmouse", - "_ymouse" - }; + /** + * Returns address of this action + * + * @return + */ + public long getAddress() { + return address; + } - /** - * Constructor - * - * @param actionCode Action type identifier - * @param actionLength Length of action data - */ - public Action(int actionCode, int actionLength) { - this.actionCode = actionCode; - this.actionLength = actionLength; - } + /** + * Gets all addresses which are referenced from this action and/or subactions + * + * @param version SWF version + * @return List of addresses + */ + public List getAllRefs(int version) { + List ret = new ArrayList(); + return ret; + } + /** + * Gets all ActionIf or ActionJump actions from subactions + * + * @return List of actions + */ + public List getAllIfsOrJumps() { + List ret = new ArrayList(); + return ret; + } - /** - * Returns address of this action - * - * @return - */ - public long getAddress() { - return address; - } + /** + * Gets all ActionIf or ActionJump actions from list of actions + * + * @param list List of actions + * @return List of actions + */ + public static List getActionsAllIfsOrJumps(List list) { + List ret = new ArrayList(); + for (Action a : list) { + List part = a.getAllIfsOrJumps(); + ret.addAll(part); + } + return ret; + } - /** - * Gets all addresses which are referenced from this action and/or subactions - * - * @param version SWF version - * @return List of addresses - */ - public List getAllRefs(int version) { - List ret = new ArrayList(); - return ret; - } + /** + * Gets all addresses which are referenced from the list of actions + * + * @param list List of actions + * @param version SWF version + * @return List of addresses + */ + public static List getActionsAllRefs(List list, int version) { + List ret = new ArrayList(); + for (Action a : list) { + List part = a.getAllRefs(version); + ret.addAll(part); + } + return ret; + } - /** - * Gets all ActionIf or ActionJump actions from subactions - * - * @return List of actions - */ - public List getAllIfsOrJumps() { - List ret = new ArrayList(); - return ret; - } + /** + * Sets address of this instruction + * + * @param address Address + * @param version SWF version + */ + public void setAddress(long address, int version) { + this.address = address; + } + /** + * Returns a string representation of the object + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return "Action" + actionCode; + } - /** - * Gets all ActionIf or ActionJump actions from list of actions - * - * @param list List of actions - * @return List of actions - */ - public static List getActionsAllIfsOrJumps(List list) { - List ret = new ArrayList(); - for (Action a : list) { - List part = a.getAllIfsOrJumps(); - ret.addAll(part); - } - return ret; - } + /** + * Reads String from FlasmLexer + * + * @param lex FlasmLexer + * @return String value + * @throws IOException + * @throws ParseException When read object is not String + */ + protected String lexString(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_STRING) { + throw new ParseException("String expected", lex.yyline()); + } + return (String) symb.value; + } - /** - * Gets all addresses which are referenced from the list of actions - * - * @param list List of actions - * @param version SWF version - * @return List of addresses - */ - public static List getActionsAllRefs(List list, int version) { - List ret = new ArrayList(); - for (Action a : list) { - List part = a.getAllRefs(version); - ret.addAll(part); - } - return ret; - } + /** + * Reads Block startServer from FlasmLexer + * + * @param lex FlasmLexer + * @throws IOException + * @throws ParseException When read object is not Block startServer + */ + protected void lexBlockOpen(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_BLOCK_START) { + throw new ParseException("Block startServer ", lex.yyline()); + } + } - /** - * Sets address of this instruction - * - * @param address Address - * @param version SWF version - */ - public void setAddress(long address, int version) { - this.address = address; - } + /** + * Reads Identifier from FlasmLexer + * + * @param lex FlasmLexer + * @return Identifier name + * @throws IOException + * @throws ParseException When read object is not Identifier + */ + protected String lexIdentifier(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { + throw new ParseException("Identifier expected", lex.yyline()); + } + return (String) symb.value; + } + /** + * Reads long value from FlasmLexer + * + * @param lex FlasmLexer + * @return long value + * @throws IOException + * @throws ParseException When read object is not long value + */ + protected long lexLong(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_INTEGER) { + throw new ParseException("Integer expected", lex.yyline()); + } + return (Long) symb.value; + } - /** - * Returns a string representation of the object - * - * @return a string representation of the object. - */ - @Override - public String toString() { - return "Action" + actionCode; - } + /** + * Reads boolean value from FlasmLexer + * + * @param lex FlasmLexer + * @return boolean value + * @throws IOException + * @throws ParseException When read object is not boolean value + */ + protected boolean lexBoolean(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_BOOLEAN) { + throw new ParseException("Boolean expected", lex.yyline()); + } + return (Boolean) symb.value; + } - /** - * Reads String from FlasmLexer - * - * @param lex FlasmLexer - * @return String value - * @throws IOException - * @throws ParseException When read object is not String - */ - protected String lexString(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_STRING) throw new ParseException("String expected", lex.yyline()); - return (String) symb.value; - } + /** + * Gets action converted to bytes + * + * @param version SWF version + * @return Array of bytes + */ + public byte[] getBytes(int version) { + byte ret[] = new byte[1]; + ret[0] = (byte) actionCode; + return ret; + } - /** - * Reads Block startServer from FlasmLexer - * - * @param lex FlasmLexer - * @throws IOException - * @throws ParseException When read object is not Block startServer - */ - protected void lexBlockOpen(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_BLOCK_START) throw new ParseException("Block startServer ", lex.yyline()); - } + /** + * Surrounds byte array with Action header + * + * @param data Byte array + * @param version SWF version + * @return Byte array + */ + protected byte[] surroundWithAction(byte[] data, int version) { + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + try { + sos2.writeUI8(actionCode); + sos2.writeUI16(data.length); + sos2.write(data); + sos2.close(); + } catch (IOException e) { + } + return baos2.toByteArray(); + } - /** - * Reads Identifier from FlasmLexer - * - * @param lex FlasmLexer - * @return Identifier name - * @throws IOException - * @throws ParseException When read object is not Identifier - */ - protected String lexIdentifier(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) throw new ParseException("Identifier expected", lex.yyline()); - return (String) symb.value; - } + /** + * Converts list of Actions to bytes + * + * @param list List of actions + * @param addZero Whether or not to add 0 UI8 value to the end + * @param version SWF version + * @return Array of bytes + */ + public static byte[] actionsToBytes(List list, boolean addZero, int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + for (Action a : list) { + try { + baos.write(a.getBytes(version)); + } catch (IOException e) { + } + } + if (addZero) { + baos.write(0); + } + return baos.toByteArray(); + } - /** - * Reads long value from FlasmLexer - * - * @param lex FlasmLexer - * @return long value - * @throws IOException - * @throws ParseException When read object is not long value - */ - protected long lexLong(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_INTEGER) throw new ParseException("Integer expected", lex.yyline()); - return (Long) symb.value; - } + /** + * Set addresses of actions in the list + * + * @param list List of actions + * @param baseAddress Address of first action in the list + * @param version SWF version + */ + public static void setActionsAddresses(List list, long baseAddress, int version) { + long offset = baseAddress; + for (Action a : list) { + a.setAddress(offset, version); + offset += a.getBytes(version).length; + } + } - /** - * Reads boolean value from FlasmLexer - * - * @param lex FlasmLexer - * @return boolean value - * @throws IOException - * @throws ParseException When read object is not boolean value - */ - protected boolean lexBoolean(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_BOOLEAN) throw new ParseException("Boolean expected", lex.yyline()); - return (Boolean) symb.value; - } + /** + * Converts list of actions to ASM source + * + * @param list List of actions + * @param importantOffsets List of important offsets to mark as labels + * @param version SWF version + * @return ASM source as String + */ + public static String actionsToString(List list, List importantOffsets, int version) { + return actionsToString(list, importantOffsets, new ArrayList(), version); + } - /** - * Gets action converted to bytes - * - * @param version SWF version - * @return Array of bytes - */ - public byte[] getBytes(int version) { - byte ret[] = new byte[1]; - ret[0] = (byte) actionCode; - return ret; - } - - /** - * Surrounds byte array with Action header - * - * @param data Byte array - * @param version SWF version - * @return Byte array - */ - protected byte[] surroundWithAction(byte[] data, int version) { - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - SWFOutputStream sos2 = new SWFOutputStream(baos2, version); - try { - sos2.writeUI8(actionCode); - sos2.writeUI16(data.length); - sos2.write(data); - sos2.close(); - } catch (IOException e) { - - } - return baos2.toByteArray(); - } - - /** - * Converts list of Actions to bytes - * - * @param list List of actions - * @param addZero Whether or not to add 0 UI8 value to the end - * @param version SWF version - * @return Array of bytes - */ - public static byte[] actionsToBytes(List list, boolean addZero, int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (Action a : list) { - try { - baos.write(a.getBytes(version)); - } catch (IOException e) { + /** + * Converts list of actions to ASM source + * + * @param list List of actions + * @param importantOffsets List of important offsets to mark as labels + * @param constantPool Constant pool + * @param version SWF version + * @return ASM source as String + */ + public static String actionsToString(List list, List importantOffsets, List constantPool, int version) { + String ret = ""; + long offset = 0; + if (importantOffsets == null) { + setActionsAddresses(list, 0, version); + importantOffsets = getActionsAllRefs(list, version); + } + offset = 0; + if (Main.LATEST_CONSTANTPOOL_HACK) { + for (Action a : list) { + if (a instanceof ActionConstantPool) { + constantPool.clear(); + constantPool.addAll(((ActionConstantPool) a).constantPool); } - } - if (addZero) baos.write(0); - return baos.toByteArray(); - } - - /** - * Set addresses of actions in the list - * - * @param list List of actions - * @param baseAddress Address of first action in the list - * @param version SWF version - */ - public static void setActionsAddresses(List list, long baseAddress, int version) { - long offset = baseAddress; - for (Action a : list) { - a.setAddress(offset, version); - offset += a.getBytes(version).length; - } - } - - - /** - * Converts list of actions to ASM source - * - * @param list List of actions - * @param importantOffsets List of important offsets to mark as labels - * @param version SWF version - * @return ASM source as String - */ - public static String actionsToString(List list, List importantOffsets, int version) { - return actionsToString(list, importantOffsets, new ArrayList(), version); - } - - /** - * Converts list of actions to ASM source - * - * @param list List of actions - * @param importantOffsets List of important offsets to mark as labels - * @param constantPool Constant pool - * @param version SWF version - * @return ASM source as String - */ - public static String actionsToString(List list, List importantOffsets, List constantPool, int version) { - String ret = ""; - long offset = 0; - if (importantOffsets == null) { - setActionsAddresses(list, 0, version); - importantOffsets = getActionsAllRefs(list, version); - } - - offset = 0; - if(Main.LATEST_CONSTANTPOOL_HACK){ - for (Action a : list) { - if (a instanceof ActionConstantPool) { - constantPool.clear(); - constantPool.addAll(((ActionConstantPool) a).constantPool); + } + } + for (Action a : list) { + if (!Main.LATEST_CONSTANTPOOL_HACK) { + if (a instanceof ActionConstantPool) { + constantPool.clear(); + constantPool.addAll(((ActionConstantPool) a).constantPool); } - } - } - for (Action a : list) { - if(!Main.LATEST_CONSTANTPOOL_HACK) - { - if (a instanceof ActionConstantPool) { - constantPool.clear(); - constantPool.addAll(((ActionConstantPool) a).constantPool); + } + if (a instanceof ActionPush) { + ((ActionPush) a).constantPool = constantPool; + } + offset = a.getAddress(); + if (importantOffsets.contains(offset)) { + ret += "loc" + Helper.formatAddress(offset) + ":"; + } + offset += a.getBytes(version).length; + ret += a.getASMSource(importantOffsets, constantPool, version) + "\r\n"; + } + if (importantOffsets.contains(offset)) { + ret += "loc" + Helper.formatAddress(offset) + ":\r\n"; + } + return ret; + } + + /** + * Convert action to ASM source + * + * @param knownAddreses List of important offsets to mark as labels + * @param constantPool Constant pool + * @param version SWF version + * @return + */ + public String getASMSource(List knownAddreses, List constantPool, int version) { + return toString(); + } + + /** + * Translates this function to stack and output. + * + * @param stack Stack + * @param constants Constant pool + * @param output Output + * @param regNames Register names + */ + public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { + } + + /** + * Pops long value off the stack + * + * @param stack Stack + * @return long value + */ + protected long popLong(Stack stack) { + TreeItem item = stack.pop(); + if (item instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) item).value instanceof Long) { + return (long) (Long) ((DirectValueTreeItem) item).value; + } + } + return 0; + } + + /** + * Converts action index to address in the specified list of actions + * + * @param actions List of actions + * @param ip Action index + * @param version SWF version + * @return address + */ + public static long ip2adr(List actions, int ip, int version) { + if (ip >= actions.size()) { + if (actions.size() == 0) { + return 0; + } + return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; + } + if (ip == -1) { + return 0; + } + return actions.get(ip).getAddress(); + } + + /** + * Converts address to action index in the specified list of actions + * + * @param actions List of actions + * @param addr Address + * @param version SWF version + * @return action index + */ + public static int adr2ip(List actions, long addr, int version) { + for (int ip = 0; ip < actions.size(); ip++) { + if (actions.get(ip).getAddress() == addr) { + return ip; + } + } + if (actions.size() > 0) { + long outpos = actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; + if (addr == outpos) { + return actions.size(); + } + } + return -1; + } + + /** + * Converts list of TreeItems to string + * + * @param tree List of TreeItem + * @return String + */ + public static String treeToString(List tree) { + String ret = ""; + for (TreeItem ti : tree) { + ret += ti.toString() + "\r\n"; + } + String parts[] = ret.split("\r\n"); + ret = ""; + + + try { + Stack loopStack = new Stack(); + for (int p = 0; p < parts.length; p++) { + String stripped = Highlighting.stripHilights(parts[p]); + if (stripped.endsWith(":") && (!stripped.startsWith("case ")) && (!stripped.equals("default:"))) { + loopStack.add(stripped.substring(0, stripped.length() - 1)); } + if (stripped.startsWith("break ")) { + if (stripped.equals("break " + loopStack.peek() + ";")) { + parts[p] = parts[p].replace(" " + loopStack.peek(), ""); + } } - if (a instanceof ActionPush) { - ((ActionPush) a).constantPool = constantPool; + if (stripped.startsWith("continue ")) { + if (loopStack.size() > 0) { + if (stripped.equals("continue " + loopStack.peek() + ";")) { + parts[p] = parts[p].replace(" " + loopStack.peek(), ""); + } + } } - offset = a.getAddress(); - if (importantOffsets.contains(offset)) { - ret += "loc" + Helper.formatAddress(offset) + ":"; + if (stripped.startsWith(":")) { + loopStack.pop(); } - offset += a.getBytes(version).length; - ret += a.getASMSource(importantOffsets, constantPool, version) + "\r\n"; - } - if (importantOffsets.contains(offset)) { - ret += "loc" + Helper.formatAddress(offset) + ":\r\n"; - } - return ret; - } + } + } catch (Exception ex) { + } - /** - * Convert action to ASM source - * - * @param knownAddreses List of important offsets to mark as labels - * @param constantPool Constant pool - * @param version SWF version - * @return - */ - public String getASMSource(List knownAddreses, List constantPool, int version) { - return toString(); - } - - /** - * Translates this function to stack and output. - * - * @param stack Stack - * @param constants Constant pool - * @param output Output - * @param regNames Register names - */ - public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { - - } - - /** - * Pops long value off the stack - * - * @param stack Stack - * @return long value - */ - protected long popLong(Stack stack) { - TreeItem item = stack.pop(); - if (item instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) item).value instanceof Long) { - return (long) (Long) ((DirectValueTreeItem) item).value; + int level = 0; + for (int p = 0; p < parts.length; p++) { + String strippedP = Highlighting.stripHilights(parts[p]); + if (strippedP.endsWith(":") && (!strippedP.startsWith("case ")) && (!strippedP.equals("default:"))) { + String loopname = strippedP.substring(0, strippedP.length() - 1); + boolean dorefer = false; + for (int q = p + 1; q < parts.length; q++) { + String strippedQ = Highlighting.stripHilights(parts[q]); + if (strippedQ.equals("break " + loopname + ";")) { + dorefer = true; + break; + } + if (strippedQ.equals("continue " + loopname + ";")) { + dorefer = true; + break; + } + if (strippedQ.equals(":" + loopname)) { + break; + } } - } - return 0; - } - - /** - * Converts action index to address in the specified list of actions - * - * @param actions List of actions - * @param ip Action index - * @param version SWF version - * @return address - */ - public static long ip2adr(List actions, int ip, int version) { - if (ip >= actions.size()) { - if (actions.size() == 0) return 0; - return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; - } - if(ip==-1) - { - return 0; - } - return actions.get(ip).getAddress(); - } - - /** - * Converts address to action index in the specified list of actions - * - * @param actions List of actions - * @param addr Address - * @param version SWF version - * @return action index - */ - public static int adr2ip(List actions, long addr, int version) { - for (int ip = 0; ip < actions.size(); ip++) { - if (actions.get(ip).getAddress() == addr) return ip; - } - if (actions.size() > 0) { - long outpos = actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; - if (addr == outpos) { - return actions.size(); - } - } - return -1; - } - - - /** - * Converts list of TreeItems to string - * - * @param tree List of TreeItem - * @return String - */ - public static String treeToString(List tree) { - String ret = ""; - for (TreeItem ti : tree) { - ret += ti.toString() + "\r\n"; - } - String parts[] = ret.split("\r\n"); - ret = ""; - - - try { - Stack loopStack = new Stack(); - for (int p = 0; p < parts.length; p++) { - String stripped = Highlighting.stripHilights(parts[p]); - if (stripped.endsWith(":") && (!stripped.startsWith("case ")) && (!stripped.equals("default:"))) { - loopStack.add(stripped.substring(0, stripped.length() - 1)); - } - if (stripped.startsWith("break ")) { - if (stripped.equals("break " + loopStack.peek() + ";")) { - parts[p] = parts[p].replace(" " + loopStack.peek(), ""); - } - } - if (stripped.startsWith("continue ")) { - if (loopStack.size() > 0) { - if (stripped.equals("continue " + loopStack.peek() + ";")) { - parts[p] = parts[p].replace(" " + loopStack.peek(), ""); - } - } - } - if (stripped.startsWith(":")) { - loopStack.pop(); - } - } - } catch (Exception ex) { - } - - int level = 0; - for (int p = 0; p < parts.length; p++) { - String strippedP = Highlighting.stripHilights(parts[p]); - if (strippedP.endsWith(":") && (!strippedP.startsWith("case ")) && (!strippedP.equals("default:"))) { - String loopname = strippedP.substring(0, strippedP.length() - 1); - boolean dorefer = false; - for (int q = p + 1; q < parts.length; q++) { - String strippedQ = Highlighting.stripHilights(parts[q]); - if (strippedQ.equals("break " + loopname + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals("continue " + loopname + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals(":" + loopname)) { - break; - } - } - if (!dorefer) { - continue; - } - } - if (strippedP.startsWith(":")) { - continue; - } - if (Highlighting.stripHilights(parts[p]).equals(INDENTOPEN)) { - level++; - continue; - } - if (Highlighting.stripHilights(parts[p]).equals(INDENTCLOSE)) { - level--; - continue; - } - if (Highlighting.stripHilights(parts[p]).equals("}")) level--; - if (Highlighting.stripHilights(parts[p]).equals("};")) level--; - ret += tabString(level) + parts[p] + "\r\n"; - if (Highlighting.stripHilights(parts[p]).equals("{")) level++; - } - return ret; - } - - private static final String INDENT_STRING = " "; - - - private static String tabString(int len) { - String ret = ""; - for (int i = 0; i < len; i++) { - ret += INDENT_STRING; - } - return ret; - } - - /** - * Converts list of actions to ActionScript source code - * - * @param actions List of actions - * @param version SWF version - * @return String with Source code - */ - public static String actionsToSource(List actions, int version) { - List tree = actionsToTree(new HashMap(),actions, version); - return treeToString(tree); - } - - /** - * Converts list of actions to List of treeItems - * - * @param regNames Register names - * @param actions List of actions - * @param version SWF version - * @return List of treeItems - */ - public static List actionsToTree(HashMap regNames,List actions, int version) { - return actionsToTree(regNames,new ArrayList(), new ArrayList(), getActionsAllIfsOrJumps(actions), new Stack(), new ConstantPool(), actions, 0, actions.size() - 1, version); - } - - private static Stack actionsToStackTree(HashMap regNames,List jumpsOrIfs, List actions, ConstantPool constants, int start, int end, int version) { - Stack ret = new Stack(); - actionsToTree(regNames,new ArrayList(), new ArrayList(), jumpsOrIfs, ret, constants, actions, start, end, version); - return ret; - } - - - private static class Loop { - - public long loopContinue; - public long loopBreak; - public int continueCount = 0; - public int breakCount = 0; - - public Loop(long loopContinue, long loopBreak) { - this.loopContinue = loopContinue; - this.loopBreak = loopBreak; - } - } - - private static List actionsToTree(HashMap registerNames,List unknownJumps, List loopList, List jumpsOrIfs, Stack stack, ConstantPool constants, List actions, int start, int end, int version) { - List output = new ArrayList(); - int ip = start; - boolean isWhile = false; - boolean isForIn = false; - TreeItem inItem=null; - int loopStart = 0; - loopip: - while (ip <= end + 1) { - - long addr = ip2adr(actions, ip, version); - if (unknownJumps.contains(addr)) { - unknownJumps.remove(new Long(addr)); - boolean switchFound = false; - for (int i = output.size() - 1; i >= 0; i--) { - if (output.get(i) instanceof SwitchTreeItem) { - if (((SwitchTreeItem) output.get(i)).defaultCommands == null) { - List continues = ((SwitchTreeItem) output.get(i)).getContinues(); - boolean breakFound = false; - for (ContinueTreeItem cti : continues) { - if (cti.loopPos == addr) { - cti.isKnown = true; - cti.isBreak = true; - ((SwitchTreeItem) output.get(i)).loopBreak = addr; - breakFound = true; - } - } - if (breakFound) { - switchFound = true; - ((SwitchTreeItem) output.get(i)).defaultCommands = new ArrayList(); - for (int k = i + 1; k < output.size(); k++) { - ((SwitchTreeItem) output.get(i)).defaultCommands.add(output.remove(i + 1)); - } - } - } - break; - } - } - if (!switchFound) { - throw new UnknownJumpException(stack, addr, output); - } - } - if (ip > end) break; - Action action = actions.get(ip); - for (int j = 0; j < jumpsOrIfs.size(); j++) { - Action jif = jumpsOrIfs.get(j); - if (jif instanceof ActionIf) { - if (((ActionIf) jif).getRef(version) == addr) { - if (jif.getAddress() > addr) { - jumpsOrIfs.remove(j); - List doBody = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, ip, adr2ip(actions, jif.getAddress(), version) - 1, version); - Loop currentLoop = new Loop(ip, adr2ip(actions, jif.getAddress(), version) + 1); - loopList.add(currentLoop); - output.add(new DoWhileTreeItem(action, adr2ip(actions, jif.getAddress(), version) + 1, ip, doBody, stack.pop())); - ip = adr2ip(actions, jif.getAddress(), version) + 1; - continue loopip; - } - } - } - - } - for (int j = 0; j < jumpsOrIfs.size(); j++) { - Action jif = jumpsOrIfs.get(j); - if (jif instanceof ActionJump) { - if (((ActionJump) jif).getRef(version) == addr) { - if (jif.getAddress() > addr) { - isWhile = true; - loopStart = ip; - break; - } - } - } - } - if (action instanceof ActionJump) { - int jumpIp = adr2ip(actions, ((ActionJump) action).getRef(version), version); - //if (jumpIp > ip) { - for (Loop l : loopList) { - if (l.loopBreak == ((ActionJump) action).getRef(version)) { - output.add(new BreakTreeItem(action, l.loopBreak)); - ip = ip + 1; - continue loopip; - } - if (l.loopContinue == ((ActionJump) action).getRef(version)) { - l.continueCount++; - output.add(new ContinueTreeItem(action, l.loopBreak)); - ip = ip + 1; - continue loopip; - } - } - - output.add(new ContinueTreeItem(action, ((ActionJump) action).getRef(version), false)); - - if (!unknownJumps.contains(((ActionJump) action).getRef(version))) { - unknownJumps.add(((ActionJump) action).getRef(version)); - } - ip = ip + 1; - break; - - } else if (action instanceof ActionIf) { - int jumpIp = adr2ip(actions, ((ActionIf) action).getRef(version), version); - if (jumpIp < ip) { - output.add(new UnsupportedTreeItem(action, "ActionIf to jump back")); - break; - } - TreeItem expression = null; - if(!isForIn){ - expression=stack.pop(); - if (expression instanceof NotTreeItem) { - expression = ((NotTreeItem) expression).value; - } else { - expression = new NotTreeItem(action, expression); - } - } - List onTrue = new ArrayList(); - List onFalse = new ArrayList(); - boolean hasElse = false; - int jumpElseIp = 0; - Stack falseStack = new Stack(); - Stack trueStack = new Stack(); - //if (!isWhile) { - if (actions.get(jumpIp - 1) instanceof ActionJump) { - long ref = ((ActionJump) actions.get(jumpIp - 1)).getRef(version); - int refIp = adr2ip(actions, ref, version); - if ((refIp > jumpIp) && (refIp <= end + 1)) { - hasElse = true; - jumpElseIp = adr2ip(actions, ((ActionJump) actions.get(jumpIp - 1)).getRef(version), version); - onFalse = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, falseStack, constants, actions, jumpIp, jumpElseIp - 1, version); - } - } - //} - Loop currentLoop = null; - if (isWhile||isForIn) { - currentLoop = new Loop(loopStart, jumpIp); - loopList.add(currentLoop); - } - boolean isFor = false; - boolean isTernar = false; - List finalExpression = null; - - TreeItem variableName=null; - if(isForIn){ - for(int t=ip+1;t<=end;t++){ - Action actionSV=actions.get(t); - actionSV.translate(stack, constants, output, registerNames); - if(actionSV instanceof ActionSetVariable){ - SetVariableTreeItem svt=(SetVariableTreeItem)output.remove(output.size()-1); - variableName=svt.name; - ip=t; - break; - } - } - } - - try { - - onTrue = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, trueStack, constants, actions, ip + 1, jumpIp - 1 - (hasElse || isWhile || isForIn ? 1 : 0), version); - if (onTrue.size() == 0 && trueStack.size() > 0) { - isTernar = true; - } - } catch (UnknownJumpException uje) { - if ((adr2ip(actions, uje.addr, version) >= start) && (adr2ip(actions, uje.addr, version) <= end)) { - currentLoop.loopContinue = uje.addr; - onTrue = uje.output; - List contList = new ArrayList(); - for (TreeItem ti : onTrue) { - if (ti instanceof ContinueTreeItem) { - contList.add((ContinueTreeItem) ti); - } - if (ti instanceof Block) { - List subcont = ((Block) ti).getContinues(); - for (int k = 0; k < subcont.size(); k++) - contList.add(subcont.get(k)); - } - } - for (int u = 0; u < contList.size(); u++) { - if (contList.get(u) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) contList.get(u)).loopPos == uje.addr) { - if (!((ContinueTreeItem) contList.get(u)).isKnown) { - ((ContinueTreeItem) contList.get(u)).isKnown = true; - ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; - } - } - } - } - finalExpression = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version); - isFor = true; - } else { - //throw new ConvertException("Unknown pattern: jump to nowhere", ip); - } - } - if(isForIn){ - output.add(new ForInTreeItem(action,jumpIp, loopStart,variableName,inItem,onTrue)); - }else if (isFor) { - output.add(new ForTreeItem(action, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList(), expression, finalExpression, onTrue)); - } else if (isTernar) { - stack.push(new TernarOpTreeItem(action, expression, trueStack.pop(), falseStack.pop())); - } else if (isWhile) { - output.add(new WhileTreeItem(action, jumpIp, loopStart, expression, onTrue)); - } else { - output.add(new IfTreeItem(action, expression, onTrue, onFalse)); - } - ip = (hasElse ? jumpElseIp : jumpIp); - isWhile = false; - isFor = false; - isForIn = false; - continue; - } else if((action instanceof ActionEnumerate2)||(action instanceof ActionEnumerate)){ - loopStart=ip+1; - isForIn=true; - inItem=stack.pop(); - ip+=4; + if (!dorefer) { continue; - }else if (action instanceof ActionTry) { - ActionTry atry = (ActionTry) action; - List tryCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.tryBody, 0, atry.tryBody.size() - 1, version); - TreeItem catchName; - if (atry.catchInRegisterFlag) { - catchName = new DirectValueTreeItem(atry, new RegisterNumber(atry.catchRegister), constants); - } else { - catchName = new DirectValueTreeItem(atry, atry.catchName, constants); - } - List catchExceptions = new ArrayList(); - catchExceptions.add(catchName); - List> catchCommands = new ArrayList>(); - catchCommands.add(actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.catchBody, 0, atry.catchBody.size() - 1, version)); - List finallyCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.finallyBody, 0, atry.finallyBody.size() - 1, version); - output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); - } else if (action instanceof ActionWith) { - ActionWith awith = (ActionWith) action; - List withCommands = actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, awith.actions, 0, awith.actions.size() - 1, version); - output.add(new WithTreeItem(action, stack.pop(), withCommands)); - } else if (action instanceof ActionDefineFunction) { - FunctionTreeItem fti = new FunctionTreeItem(action,((ActionDefineFunction)action).functionName,((ActionDefineFunction)action).paramNames, actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, ((ActionDefineFunction) action).code, 0, ((ActionDefineFunction) action).code.size() - 1, version), constants); - stack.push(fti); - } else if (action instanceof ActionDefineFunction2) { - HashMap funcRegNames=(HashMap)registerNames.clone(); - for(int f=0;f<((ActionDefineFunction2)action).paramNames.size();f++){ - int reg=((ActionDefineFunction2)action).paramRegisters.get(f); - if(reg!=0) - funcRegNames.put(reg, ((ActionDefineFunction2)action).paramNames.get(f)); - } - int pos=1; - if(((ActionDefineFunction2)action).preloadThisFlag) {funcRegNames.put(pos, "this");pos++;} - if(((ActionDefineFunction2)action).preloadArgumentsFlag) {funcRegNames.put(pos, "arguments");pos++;} - if(((ActionDefineFunction2)action).preloadSuperFlag) {funcRegNames.put(pos, "super");pos++;} - if(((ActionDefineFunction2)action).preloadRootFlag) {funcRegNames.put(pos, "_root");pos++;} - if(((ActionDefineFunction2)action).preloadParentFlag) {funcRegNames.put(pos, "_parent");pos++;} - if(((ActionDefineFunction2)action).preloadGlobalFlag) {funcRegNames.put(pos, "_global");pos++;} + } + } + if (strippedP.startsWith(":")) { + continue; + } + if (Highlighting.stripHilights(parts[p]).equals(INDENTOPEN)) { + level++; + continue; + } + if (Highlighting.stripHilights(parts[p]).equals(INDENTCLOSE)) { + level--; + continue; + } + if (Highlighting.stripHilights(parts[p]).equals("}")) { + level--; + } + if (Highlighting.stripHilights(parts[p]).equals("};")) { + level--; + } + ret += tabString(level) + parts[p] + "\r\n"; + if (Highlighting.stripHilights(parts[p]).equals("{")) { + level++; + } + } + return ret; + } + private static final String INDENT_STRING = " "; - FunctionTreeItem fti = new FunctionTreeItem(action,((ActionDefineFunction2)action).functionName,((ActionDefineFunction2)action).paramNames, actionsToTree(funcRegNames,unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, ((ActionDefineFunction2) action).code, 0, ((ActionDefineFunction2) action).code.size() - 1, version), constants); - stack.push(fti); - } else if (action instanceof ActionPushDuplicate) { - do { - if (actions.get(ip + 1) instanceof ActionNot) { - if (actions.get(ip + 2) instanceof ActionIf) { - int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version); - stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, ip + 4 /*je tam pop*/, nextPos - 1, version).pop())); - ip = nextPos; - } else { - output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not")); - break; + private static String tabString(int len) { + String ret = ""; + for (int i = 0; i < len; i++) { + ret += INDENT_STRING; + } + return ret; + } + + /** + * Converts list of actions to ActionScript source code + * + * @param actions List of actions + * @param version SWF version + * @return String with Source code + */ + public static String actionsToSource(List actions, int version) { + List tree = actionsToTree(new HashMap(), actions, version); + return treeToString(tree); + } + + /** + * Converts list of actions to List of treeItems + * + * @param regNames Register names + * @param actions List of actions + * @param version SWF version + * @return List of treeItems + */ + public static List actionsToTree(HashMap regNames, List actions, int version) { + return actionsToTree(regNames, new ArrayList(), new ArrayList(), getActionsAllIfsOrJumps(actions), new Stack(), new ConstantPool(), actions, 0, actions.size() - 1, version); + } + + private static Stack actionsToStackTree(HashMap regNames, List jumpsOrIfs, List actions, ConstantPool constants, int start, int end, int version) { + Stack ret = new Stack(); + actionsToTree(regNames, new ArrayList(), new ArrayList(), jumpsOrIfs, ret, constants, actions, start, end, version); + return ret; + } + + private static class Loop { + + public long loopContinue; + public long loopBreak; + public int continueCount = 0; + public int breakCount = 0; + + public Loop(long loopContinue, long loopBreak) { + this.loopContinue = loopContinue; + this.loopBreak = loopBreak; + } + } + + private static List actionsToTree(HashMap registerNames, List unknownJumps, List loopList, List jumpsOrIfs, Stack stack, ConstantPool constants, List actions, int start, int end, int version) { + List output = new ArrayList(); + int ip = start; + boolean isWhile = false; + boolean isForIn = false; + TreeItem inItem = null; + int loopStart = 0; + loopip: + while (ip <= end + 1) { + + long addr = ip2adr(actions, ip, version); + if (unknownJumps.contains(addr)) { + unknownJumps.remove(new Long(addr)); + boolean switchFound = false; + for (int i = output.size() - 1; i >= 0; i--) { + if (output.get(i) instanceof SwitchTreeItem) { + if (((SwitchTreeItem) output.get(i)).defaultCommands == null) { + List continues = ((SwitchTreeItem) output.get(i)).getContinues(); + boolean breakFound = false; + for (ContinueTreeItem cti : continues) { + if (cti.loopPos == addr) { + cti.isKnown = true; + cti.isBreak = true; + ((SwitchTreeItem) output.get(i)).loopBreak = addr; + breakFound = true; } - } else if (actions.get(ip + 1) instanceof ActionIf) { - int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version); - stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, ip + 3, nextPos - 1, version).pop())); - ip = nextPos; - } else { - output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If")); - break loopip; - } - action = actions.get(ip); - } - while (action instanceof ActionPushDuplicate); - continue; - } else if (action instanceof ActionStoreRegister) { - if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) { - action.translate(stack, constants, output, registerNames); - stack.pop(); - ip++; - } else { - action.translate(stack, constants, output, registerNames); - } - } else if (action instanceof ActionStrictEquals) { - if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) { - List caseValues = new ArrayList(); - List> caseCommands = new ArrayList>(); - caseValues.add(stack.pop()); - TreeItem switchedObject = stack.pop(); - if (output.size() > 0) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - output.remove(output.size() - 1); + } + if (breakFound) { + switchFound = true; + ((SwitchTreeItem) output.get(i)).defaultCommands = new ArrayList(); + for (int k = i + 1; k < output.size(); k++) { + ((SwitchTreeItem) output.get(i)).defaultCommands.add(output.remove(i + 1)); } - } - int caseStart = ip + 2; - List caseBodyIps = new ArrayList(); - long defaultAddr = 0; - caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version)); - ip++; - do { - ip++; - if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) { - caseValues.add(actionsToStackTree(registerNames,jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop()); - caseStart = ip + 1; - caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version)); - if (actions.get(ip + 1) instanceof ActionJump) { - defaultAddr = ((ActionJump) actions.get(ip + 1)).getRef(version); - ip = adr2ip(actions, defaultAddr, version); - break; - } + } + } + break; + } + } + if (!switchFound) { + throw new UnknownJumpException(stack, addr, output); + } + } + if (ip > end) { + break; + } + Action action = actions.get(ip); + for (int j = 0; j < jumpsOrIfs.size(); j++) { + Action jif = jumpsOrIfs.get(j); + if (jif instanceof ActionIf) { + if (((ActionIf) jif).getRef(version) == addr) { + if (jif.getAddress() > addr) { + jumpsOrIfs.remove(j); + List doBody = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, ip, adr2ip(actions, jif.getAddress(), version) - 1, version); + Loop currentLoop = new Loop(ip, adr2ip(actions, jif.getAddress(), version) + 1); + loopList.add(currentLoop); + output.add(new DoWhileTreeItem(action, adr2ip(actions, jif.getAddress(), version) + 1, ip, doBody, stack.pop())); + ip = adr2ip(actions, jif.getAddress(), version) + 1; + continue loopip; + } + } + } + + } + for (int j = 0; j < jumpsOrIfs.size(); j++) { + Action jif = jumpsOrIfs.get(j); + if (jif instanceof ActionJump) { + if (((ActionJump) jif).getRef(version) == addr) { + if (jif.getAddress() > addr) { + isWhile = true; + loopStart = ip; + break; + } + } + } + } + if (action instanceof ActionJump) { + int jumpIp = adr2ip(actions, ((ActionJump) action).getRef(version), version); + //if (jumpIp > ip) { + for (Loop l : loopList) { + if (l.loopBreak == ((ActionJump) action).getRef(version)) { + output.add(new BreakTreeItem(action, l.loopBreak)); + ip = ip + 1; + continue loopip; + } + if (l.loopContinue == ((ActionJump) action).getRef(version)) { + l.continueCount++; + output.add(new ContinueTreeItem(action, l.loopBreak)); + ip = ip + 1; + continue loopip; + } + } + + output.add(new ContinueTreeItem(action, ((ActionJump) action).getRef(version), false)); + + if (!unknownJumps.contains(((ActionJump) action).getRef(version))) { + unknownJumps.add(((ActionJump) action).getRef(version)); + } + ip = ip + 1; + break; + + } else if (action instanceof ActionIf) { + int jumpIp = adr2ip(actions, ((ActionIf) action).getRef(version), version); + if (jumpIp < ip) { + output.add(new UnsupportedTreeItem(action, "ActionIf to jump back")); + break; + } + TreeItem expression = null; + if (!isForIn) { + expression = stack.pop(); + if (expression instanceof NotTreeItem) { + expression = ((NotTreeItem) expression).value; + } else { + expression = new NotTreeItem(action, expression); + } + } + List onTrue = new ArrayList(); + List onFalse = new ArrayList(); + boolean hasElse = false; + int jumpElseIp = 0; + Stack falseStack = new Stack(); + Stack trueStack = new Stack(); + //if (!isWhile) { + if (actions.get(jumpIp - 1) instanceof ActionJump) { + long ref = ((ActionJump) actions.get(jumpIp - 1)).getRef(version); + int refIp = adr2ip(actions, ref, version); + if ((refIp > jumpIp) && (refIp <= end + 1)) { + hasElse = true; + jumpElseIp = adr2ip(actions, ((ActionJump) actions.get(jumpIp - 1)).getRef(version), version); + onFalse = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, falseStack, constants, actions, jumpIp, jumpElseIp - 1, version); + } + } + //} + Loop currentLoop = null; + if (isWhile || isForIn) { + currentLoop = new Loop(loopStart, jumpIp); + loopList.add(currentLoop); + } + boolean isFor = false; + boolean isTernar = false; + List finalExpression = null; + + TreeItem variableName = null; + if (isForIn) { + for (int t = ip + 1; t <= end; t++) { + Action actionSV = actions.get(t); + actionSV.translate(stack, constants, output, registerNames); + if (actionSV instanceof ActionSetVariable) { + SetVariableTreeItem svt = (SetVariableTreeItem) output.remove(output.size() - 1); + variableName = svt.name; + ip = t; + break; + } + } + } + + try { + + onTrue = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, trueStack, constants, actions, ip + 1, jumpIp - 1 - (hasElse || isWhile || isForIn ? 1 : 0), version); + if (onTrue.size() == 0 && trueStack.size() > 0) { + isTernar = true; + } + } catch (UnknownJumpException uje) { + if ((adr2ip(actions, uje.addr, version) >= start) && (adr2ip(actions, uje.addr, version) <= end)) { + currentLoop.loopContinue = uje.addr; + onTrue = uje.output; + List contList = new ArrayList(); + for (TreeItem ti : onTrue) { + if (ti instanceof ContinueTreeItem) { + contList.add((ContinueTreeItem) ti); + } + if (ti instanceof Block) { + List subcont = ((Block) ti).getContinues(); + for (int k = 0; k < subcont.size(); k++) { + contList.add(subcont.get(k)); } - } while (ip < end); - for (int i = 0; i < caseBodyIps.size(); i++) { - int caseEnd = ip - 1; - if (i < caseBodyIps.size() - 1) { - caseEnd = caseBodyIps.get(i + 1) - 1; + } + } + for (int u = 0; u < contList.size(); u++) { + if (contList.get(u) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) contList.get(u)).loopPos == uje.addr) { + if (!((ContinueTreeItem) contList.get(u)).isKnown) { + ((ContinueTreeItem) contList.get(u)).isKnown = true; + ((ContinueTreeItem) contList.get(u)).loopPos = currentLoop.loopBreak; + } } - caseCommands.add(actionsToTree(registerNames,unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version)); - } - output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); - continue; - } else { - action.translate(stack, constants, output, registerNames); - } + } + } + finalExpression = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, adr2ip(actions, uje.addr, version), jumpIp - 2, version); + isFor = true; + } else { + //throw new ConvertException("Unknown pattern: jump to nowhere", ip); + } + } + if (isForIn) { + output.add(new ForInTreeItem(action, jumpIp, loopStart, variableName, inItem, onTrue)); + } else if (isFor) { + output.add(new ForTreeItem(action, currentLoop.loopBreak, currentLoop.loopContinue, new ArrayList(), expression, finalExpression, onTrue)); + } else if (isTernar) { + stack.push(new TernarOpTreeItem(action, expression, trueStack.pop(), falseStack.pop())); + } else if (isWhile) { + output.add(new WhileTreeItem(action, jumpIp, loopStart, expression, onTrue)); } else { - try { - action.translate(stack, constants, output, registerNames); - } catch (EmptyStackException ese) { - output.add(new UnsupportedTreeItem(action, "Empty stack")); - } + output.add(new IfTreeItem(action, expression, onTrue, onFalse)); + } + ip = (hasElse ? jumpElseIp : jumpIp); + isWhile = false; + isFor = false; + isForIn = false; + continue; + } else if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) { + loopStart = ip + 1; + isForIn = true; + inItem = stack.pop(); + ip += 4; + continue; + } else if (action instanceof ActionTry) { + ActionTry atry = (ActionTry) action; + List tryCommands = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.tryBody, 0, atry.tryBody.size() - 1, version); + TreeItem catchName; + if (atry.catchInRegisterFlag) { + catchName = new DirectValueTreeItem(atry, new RegisterNumber(atry.catchRegister), constants); + } else { + catchName = new DirectValueTreeItem(atry, atry.catchName, constants); + } + List catchExceptions = new ArrayList(); + catchExceptions.add(catchName); + List> catchCommands = new ArrayList>(); + catchCommands.add(actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.catchBody, 0, atry.catchBody.size() - 1, version)); + List finallyCommands = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, atry.finallyBody, 0, atry.finallyBody.size() - 1, version); + output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); + } else if (action instanceof ActionWith) { + ActionWith awith = (ActionWith) action; + List withCommands = actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, awith.actions, 0, awith.actions.size() - 1, version); + output.add(new WithTreeItem(action, stack.pop(), withCommands)); + } else if (action instanceof ActionDefineFunction) { + FunctionTreeItem fti = new FunctionTreeItem(action, ((ActionDefineFunction) action).functionName, ((ActionDefineFunction) action).paramNames, actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, ((ActionDefineFunction) action).code, 0, ((ActionDefineFunction) action).code.size() - 1, version), constants); + stack.push(fti); + } else if (action instanceof ActionDefineFunction2) { + HashMap funcRegNames = (HashMap) registerNames.clone(); + for (int f = 0; f < ((ActionDefineFunction2) action).paramNames.size(); f++) { + int reg = ((ActionDefineFunction2) action).paramRegisters.get(f); + if (reg != 0) { + funcRegNames.put(reg, ((ActionDefineFunction2) action).paramNames.get(f)); + } + } + int pos = 1; + if (((ActionDefineFunction2) action).preloadThisFlag) { + funcRegNames.put(pos, "this"); + pos++; + } + if (((ActionDefineFunction2) action).preloadArgumentsFlag) { + funcRegNames.put(pos, "arguments"); + pos++; + } + if (((ActionDefineFunction2) action).preloadSuperFlag) { + funcRegNames.put(pos, "super"); + pos++; + } + if (((ActionDefineFunction2) action).preloadRootFlag) { + funcRegNames.put(pos, "_root"); + pos++; + } + if (((ActionDefineFunction2) action).preloadParentFlag) { + funcRegNames.put(pos, "_parent"); + pos++; + } + if (((ActionDefineFunction2) action).preloadGlobalFlag) { + funcRegNames.put(pos, "_global"); + pos++; } - ip++; - } - if (stack.size() > 0) { - for (int i = stack.size() - 1; i >= 0; i--) { - if (stack.get(i) instanceof FunctionTreeItem) { - output.add(0, stack.get(i)); - stack.remove(i); - } + FunctionTreeItem fti = new FunctionTreeItem(action, ((ActionDefineFunction2) action).functionName, ((ActionDefineFunction2) action).paramNames, actionsToTree(funcRegNames, unknownJumps, loopList, jumpsOrIfs, new Stack(), constants, ((ActionDefineFunction2) action).code, 0, ((ActionDefineFunction2) action).code.size() - 1, version), constants); + stack.push(fti); + } else if (action instanceof ActionPushDuplicate) { + do { + if (actions.get(ip + 1) instanceof ActionNot) { + if (actions.get(ip + 2) instanceof ActionIf) { + int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version); + stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(registerNames, jumpsOrIfs, actions, constants, ip + 4 /*je tam pop*/, nextPos - 1, version).pop())); + ip = nextPos; + } else { + output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not")); + break; + } + } else if (actions.get(ip + 1) instanceof ActionIf) { + int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version); + stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(registerNames, jumpsOrIfs, actions, constants, ip + 3, nextPos - 1, version).pop())); + ip = nextPos; + } else { + output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If")); + break loopip; + } + action = actions.get(ip); + } while (action instanceof ActionPushDuplicate); + continue; + } else if (action instanceof ActionStoreRegister) { + if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) { + action.translate(stack, constants, output, registerNames); + stack.pop(); + ip++; + } else { + action.translate(stack, constants, output, registerNames); } - } - return output; - } + } else if (action instanceof ActionStrictEquals) { + if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) { + List caseValues = new ArrayList(); + List> caseCommands = new ArrayList>(); + caseValues.add(stack.pop()); + TreeItem switchedObject = stack.pop(); + if (output.size() > 0) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + output.remove(output.size() - 1); + } + } + int caseStart = ip + 2; + List caseBodyIps = new ArrayList(); + long defaultAddr = 0; + caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version)); + ip++; + do { + ip++; + if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) { + caseValues.add(actionsToStackTree(registerNames, jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop()); + caseStart = ip + 1; + caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version)); + if (actions.get(ip + 1) instanceof ActionJump) { + defaultAddr = ((ActionJump) actions.get(ip + 1)).getRef(version); + ip = adr2ip(actions, defaultAddr, version); + break; + } + } + } while (ip < end); + for (int i = 0; i < caseBodyIps.size(); i++) { + int caseEnd = ip - 1; + if (i < caseBodyIps.size() - 1) { + caseEnd = caseBodyIps.get(i + 1) - 1; + } + caseCommands.add(actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version)); + } + output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); + continue; + } else { + action.translate(stack, constants, output, registerNames); + } + } else { + try { + action.translate(stack, constants, output, registerNames); + } catch (EmptyStackException ese) { + output.add(new UnsupportedTreeItem(action, "Empty stack")); + } + } + + ip++; + } + if (stack.size() > 0) { + for (int i = stack.size() - 1; i >= 0; i--) { + if (stack.get(i) instanceof FunctionTreeItem) { + output.add(0, stack.get(i)); + stack.remove(i); + } + } + } + return output; + } } diff --git a/trunk/src/com/jpexs/asdec/action/UnknownJumpException.java b/trunk/src/com/jpexs/asdec/action/UnknownJumpException.java index c032c0f97..1e1ea36ac 100644 --- a/trunk/src/com/jpexs/asdec/action/UnknownJumpException.java +++ b/trunk/src/com/jpexs/asdec/action/UnknownJumpException.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action; import com.jpexs.asdec.action.treemodel.TreeItem; @@ -27,41 +26,40 @@ import java.util.Stack; * @author JPEXS */ public class UnknownJumpException extends RuntimeException { - /** - * Actual stack - */ - public Stack stack; - /** - * Actual address - */ - public long addr; - /** - * Output of the method before raising the exception - */ - public List output; - /** - * Constructor - * - * @param stack Actual stack - * @param addr Actual address - * @param output Output of the method before raising the exception - */ - public UnknownJumpException(Stack stack, long addr, List output) { - this.stack = stack; - this.addr = addr; - this.output = output; - } - - /** - * Returns a string representation of the object - * - * @return a string representation of the object. - */ - @Override - public String toString() { - return "Unknown jump to " + addr; - } + /** + * Actual stack + */ + public Stack stack; + /** + * Actual address + */ + public long addr; + /** + * Output of the method before raising the exception + */ + public List output; + /** + * Constructor + * + * @param stack Actual stack + * @param addr Actual address + * @param output Output of the method before raising the exception + */ + public UnknownJumpException(Stack stack, long addr, List output) { + this.stack = stack; + this.addr = addr; + this.output = output; + } + /** + * Returns a string representation of the object + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return "Unknown jump to " + addr; + } } diff --git a/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java b/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java index dde8cd907..4dfaa2b37 100644 --- a/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java +++ b/trunk/src/com/jpexs/asdec/action/flashlite/ActionFSCommand2.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.flashlite; import com.jpexs.asdec.action.Action; @@ -27,23 +26,23 @@ import java.util.Stack; public class ActionFSCommand2 extends Action { - public ActionFSCommand2() { - super(0x2D, 0); - } + public ActionFSCommand2() { + super(0x2D, 0); + } - @Override - public String toString() { - return "FSCommand2"; - } + @Override + public String toString() { + return "FSCommand2"; + } - @Override - public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { - long numArgs = popLong(stack); - TreeItem command = stack.pop(); - List args = new ArrayList(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new FSCommand2TreeItem(this, command, args)); - } + @Override + public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { + long numArgs = popLong(stack); + TreeItem command = stack.pop(); + List args = new ArrayList(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new FSCommand2TreeItem(this, command, args)); + } } diff --git a/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java b/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java index bb8081dcd..16c7049c7 100644 --- a/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java +++ b/trunk/src/com/jpexs/asdec/action/flashlite/ActionStrictMode.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.flashlite; import com.jpexs.asdec.SWFInputStream; @@ -31,37 +30,37 @@ import java.util.List; import java.util.Stack; public class ActionStrictMode extends Action { - public int mode; - public ActionStrictMode(SWFInputStream sis) throws IOException { - super(0x89, 1); - mode = sis.readUI8(); - } + public int mode; - public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { - super(0x89, 1); - mode = (int) lexLong(lexer); - } + public ActionStrictMode(SWFInputStream sis) throws IOException { + super(0x89, 1); + mode = sis.readUI8(); + } - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI8(mode); - sos.close(); - } catch (IOException e) { + public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { + super(0x89, 1); + mode = (int) lexLong(lexer); + } - } - return surroundWithAction(baos.toByteArray(), version); - } + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(mode); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } - @Override - public String toString() { - return "StrictMode " + mode; - } + @Override + public String toString() { + return "StrictMode " + mode; + } - @Override - public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { - output.add(new StrictModeTreeItem(this, mode)); - } + @Override + public void translate(Stack stack, ConstantPool constants, List output, java.util.HashMap regNames) { + output.add(new StrictModeTreeItem(this, mode)); + } } diff --git a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java index 056a062f2..97f56aa30 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java +++ b/trunk/src/com/jpexs/asdec/action/gui/MainFrame.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.gui; import com.jpexs.asdec.Main; @@ -47,266 +46,266 @@ import jsyntaxpane.DefaultSyntaxKit; public class MainFrame extends JFrame implements TreeSelectionListener, ActionListener { - public JTree tagTree; - public JEditorPane editor; - public JEditorPane decompiledEditor; - public List list; - public JSplitPane splitPane; - public JSplitPane splitPane2; - public JButton saveButton = new JButton("Save"); - public JButton saveHexButton = new JButton("Save hex"); - public JButton loadHexButton = new JButton("Load hex"); - public JLabel asmLabel = new JLabel("P-code source (editable)"); - public JLabel decLabel = new JLabel("ActionScript source"); - public JPanel statusPanel = new JPanel(); - public LoadingPanel loadingPanel = new LoadingPanel(20, 20); - public JLabel statusLabel = new JLabel(""); + public JTree tagTree; + public JEditorPane editor; + public JEditorPane decompiledEditor; + public List list; + public JSplitPane splitPane; + public JSplitPane splitPane2; + public JButton saveButton = new JButton("Save"); + public JButton saveHexButton = new JButton("Save hex"); + public JButton loadHexButton = new JButton("Load hex"); + public JLabel asmLabel = new JLabel("P-code source (editable)"); + public JLabel decLabel = new JLabel("ActionScript source"); + public JPanel statusPanel = new JPanel(); + public LoadingPanel loadingPanel = new LoadingPanel(20, 20); + public JLabel statusLabel = new JLabel(""); - public MainFrame(List list) { - this.list = list; - DefaultSyntaxKit.initKit(); - editor = new JEditorPane(); - decompiledEditor = new JEditorPane(); - tagTree = new JTree(new TagTreeModel(list)); + public MainFrame(List list) { + this.list = list; + DefaultSyntaxKit.initKit(); + editor = new JEditorPane(); + decompiledEditor = new JEditorPane(); + tagTree = new JTree(new TagTreeModel(list)); - DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); - ClassLoader cldr = this.getClass().getClassLoader(); - java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/action/gui/graphics/class.png"); - ImageIcon leafIcon = new ImageIcon(imageURL); - treeRenderer.setLeafIcon(leafIcon); - tagTree.setCellRenderer(treeRenderer); + DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); + ClassLoader cldr = this.getClass().getClassLoader(); + java.net.URL imageURL = cldr.getResource("com/jpexs/asdec/action/gui/graphics/class.png"); + ImageIcon leafIcon = new ImageIcon(imageURL); + treeRenderer.setLeafIcon(leafIcon); + tagTree.setCellRenderer(treeRenderer); - JPanel panB = new JPanel(); - panB.setLayout(new BorderLayout()); - asmLabel.setHorizontalAlignment(SwingConstants.CENTER); - asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - panB.add(asmLabel, BorderLayout.NORTH); - panB.add(new JScrollPane(editor), BorderLayout.CENTER); + JPanel panB = new JPanel(); + panB.setLayout(new BorderLayout()); + asmLabel.setHorizontalAlignment(SwingConstants.CENTER); + asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + panB.add(asmLabel, BorderLayout.NORTH); + panB.add(new JScrollPane(editor), BorderLayout.CENTER); - JPanel buttonsPan = new JPanel(); - buttonsPan.setLayout(new FlowLayout()); - buttonsPan.add(saveButton); - //buttonsPan.add(saveHexButton); - //buttonsPan.add(loadHexButton); - panB.add(buttonsPan, BorderLayout.SOUTH); + JPanel buttonsPan = new JPanel(); + buttonsPan.setLayout(new FlowLayout()); + buttonsPan.add(saveButton); + //buttonsPan.add(saveHexButton); + //buttonsPan.add(loadHexButton); + panB.add(buttonsPan, BorderLayout.SOUTH); - saveHexButton.addActionListener(this); - saveHexButton.setActionCommand("SAVEHEXACTION"); - loadHexButton.addActionListener(this); - loadHexButton.setActionCommand("LOADHEXACTION"); - saveButton.addActionListener(this); - saveButton.setActionCommand("SAVEACTION"); + saveHexButton.addActionListener(this); + saveHexButton.setActionCommand("SAVEHEXACTION"); + loadHexButton.addActionListener(this); + loadHexButton.setActionCommand("LOADHEXACTION"); + saveButton.addActionListener(this); + saveButton.setActionCommand("SAVEACTION"); - JPanel panA = new JPanel(); - panA.setLayout(new BorderLayout()); - panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER); - panA.add(decLabel, BorderLayout.NORTH); - decLabel.setHorizontalAlignment(SwingConstants.CENTER); - decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + JPanel panA = new JPanel(); + panA.setLayout(new BorderLayout()); + panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER); + panA.add(decLabel, BorderLayout.NORTH); + decLabel.setHorizontalAlignment(SwingConstants.CENTER); + decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - loadingPanel.setPreferredSize(new Dimension(30, 30)); - statusPanel = new JPanel(); - statusPanel.setPreferredSize(new Dimension(1, 30)); - statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); - statusPanel.setLayout(new BorderLayout()); - statusPanel.add(loadingPanel, BorderLayout.WEST); - statusPanel.add(statusLabel, BorderLayout.CENTER); - loadingPanel.setVisible(false); + loadingPanel.setPreferredSize(new Dimension(30, 30)); + statusPanel = new JPanel(); + statusPanel.setPreferredSize(new Dimension(1, 30)); + statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)); + statusPanel.setLayout(new BorderLayout()); + statusPanel.add(loadingPanel, BorderLayout.WEST); + statusPanel.add(statusLabel, BorderLayout.CENTER); + loadingPanel.setVisible(false); - Container cont = getContentPane(); - cont.setLayout(new BorderLayout()); - cont.add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER); - cont.add(statusPanel, BorderLayout.SOUTH); + Container cont = getContentPane(); + cont.setLayout(new BorderLayout()); + cont.add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER); + cont.add(statusPanel, BorderLayout.SOUTH); - editor.setContentType("text/flasm"); - decompiledEditor.setContentType("text/actionscript"); - setSize(640, 480); - tagTree.addTreeSelectionListener(this); - addWindowListener(new WindowAdapter() { - - @Override - public void windowClosing(WindowEvent e) { - if (Main.proxyFrame != null) { - if (Main.proxyFrame.isVisible()) { - return; - } - } - Main.exit(); + editor.setContentType("text/flasm"); + decompiledEditor.setContentType("text/actionscript"); + setSize(640, 480); + tagTree.addTreeSelectionListener(this); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + if (Main.proxyFrame != null) { + if (Main.proxyFrame.isVisible()) { + return; + } } - }); - View.setWindowIcon(this); - View.centerScreen(this); + Main.exit(); + } + }); + View.setWindowIcon(this); + View.centerScreen(this); - JMenuBar menuBar = new JMenuBar(); + JMenuBar menuBar = new JMenuBar(); - JMenu menuFile = new JMenu("File"); - JMenuItem miOpen = new JMenuItem("Open..."); - miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png"))); - miOpen.setActionCommand("OPEN"); - miOpen.addActionListener(this); - JMenuItem miSave = new JMenuItem("Save"); - miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); - miSave.setActionCommand("SAVE"); - miSave.addActionListener(this); - JMenuItem miSaveAs = new JMenuItem("Save as..."); - miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); - miSaveAs.setActionCommand("SAVEAS"); - miSaveAs.addActionListener(this); - JMenuItem miExport = new JMenuItem("Export..."); - miExport.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png"))); - miExport.setActionCommand("EXPORT"); - miExport.addActionListener(this); - menuFile.add(miOpen); - menuFile.add(miSave); - menuFile.add(miSaveAs); - //menuFile.add(miExport); - menuFile.addSeparator(); - JMenuItem miClose = new JMenuItem("Exit"); - miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png"))); - miClose.setActionCommand("EXIT"); - miClose.addActionListener(this); - menuFile.add(miClose); - menuBar.add(menuFile); + JMenu menuFile = new JMenu("File"); + JMenuItem miOpen = new JMenuItem("Open..."); + miOpen.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/open16.png"))); + miOpen.setActionCommand("OPEN"); + miOpen.addActionListener(this); + JMenuItem miSave = new JMenuItem("Save"); + miSave.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); + miSave.setActionCommand("SAVE"); + miSave.addActionListener(this); + JMenuItem miSaveAs = new JMenuItem("Save as..."); + miSaveAs.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/save16.png"))); + miSaveAs.setActionCommand("SAVEAS"); + miSaveAs.addActionListener(this); + JMenuItem miExport = new JMenuItem("Export..."); + miExport.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exportas16.png"))); + miExport.setActionCommand("EXPORT"); + miExport.addActionListener(this); + menuFile.add(miOpen); + menuFile.add(miSave); + menuFile.add(miSaveAs); + //menuFile.add(miExport); + menuFile.addSeparator(); + JMenuItem miClose = new JMenuItem("Exit"); + miClose.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/exit16.png"))); + miClose.setActionCommand("EXIT"); + miClose.addActionListener(this); + menuFile.add(miClose); + menuBar.add(menuFile); - JMenu menuTools = new JMenu("Tools"); - JMenuItem miProxy = new JMenuItem("Proxy"); - miProxy.setActionCommand("SHOWPROXY"); - miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"))); - miProxy.addActionListener(this); - menuTools.add(miProxy); - menuBar.add(menuTools); + JMenu menuTools = new JMenu("Tools"); + JMenuItem miProxy = new JMenuItem("Proxy"); + miProxy.setActionCommand("SHOWPROXY"); + miProxy.setIcon(new ImageIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"))); + miProxy.addActionListener(this); + menuTools.add(miProxy); + menuBar.add(menuTools); - JMenu menuHelp = new JMenu("Help"); - JMenuItem miAbout = new JMenuItem("About..."); - miAbout.setActionCommand("ABOUT"); - miAbout.addActionListener(this); - menuHelp.add(miAbout); - menuBar.add(menuHelp); - - setJMenuBar(menuBar); + JMenu menuHelp = new JMenu("Help"); + JMenuItem miAbout = new JMenuItem("About..."); + miAbout.setActionCommand("ABOUT"); + miAbout.addActionListener(this); + menuHelp.add(miAbout); + menuBar.add(menuHelp); - setTitle(Main.applicationName + " - " + Main.getFileTitle()); - } + setJMenuBar(menuBar); - public void valueChanged(TreeSelectionEvent e) { - if (Main.isWorking()) return; - Object obj = tagTree.getLastSelectedPathComponent(); - if (obj instanceof TagTreeItem) { - obj = ((TagTreeItem) obj).tag; - if (obj instanceof ASMSource) { - Main.startWork("Decompiling..."); - final ASMSource asm = (ASMSource) obj; - (new Thread() { + setTitle(Main.applicationName + " - " + Main.getFileTitle()); + } - @Override - public void run() { - editor.setText(asm.getASMSource(10)); //TODO:Ensure correct version here - if(Main.DO_DECOMPILE){ - List as=asm.getActions(10);//TODO:Ensure correct version here - com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, 10);//TODO:Ensure correct version here + public void valueChanged(TreeSelectionEvent e) { + if (Main.isWorking()) { + return; + } + Object obj = tagTree.getLastSelectedPathComponent(); + if (obj instanceof TagTreeItem) { + obj = ((TagTreeItem) obj).tag; + if (obj instanceof ASMSource) { + Main.startWork("Decompiling..."); + final ASMSource asm = (ASMSource) obj; + (new Thread() { + @Override + public void run() { + editor.setText(asm.getASMSource(10)); //TODO:Ensure correct version here + if (Main.DO_DECOMPILE) { + List as = asm.getActions(10);//TODO:Ensure correct version here + com.jpexs.asdec.action.Action.setActionsAddresses(as, 0, 10);//TODO:Ensure correct version here - decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, 10))); //TODO:Ensure correct version here - } - Main.stopWork(); - } - }).start(); - } - } - } + decompiledEditor.setText(Highlighting.stripHilights(com.jpexs.asdec.action.Action.actionsToSource(as, 10))); //TODO:Ensure correct version here + } + Main.stopWork(); + } + }).start(); + } + } + } - public void display() { - setVisible(true); - splitPane.setDividerLocation(0.5); - splitPane2.setDividerLocation(0.5); - } + public void display() { + setVisible(true); + splitPane.setDividerLocation(0.5); + splitPane2.setDividerLocation(0.5); + } - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("EXIT")) { - System.exit(0); - } - if (e.getActionCommand().equals("ABOUT")) { - Main.about(); - } - if (e.getActionCommand().equals("SHOWPROXY")) { - Main.showProxy(); - } - if (Main.isWorking()) return; + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("EXIT")) { + System.exit(0); + } + if (e.getActionCommand().equals("ABOUT")) { + Main.about(); + } + if (e.getActionCommand().equals("SHOWPROXY")) { + Main.showProxy(); + } + if (Main.isWorking()) { + return; + } - if(e.getActionCommand().equals("SAVEHEXACTION")){ - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); - if (ti.tag instanceof ASMSource) { - ASMSource dat = (ASMSource) ti.tag; - FileOutputStream fos; - try { - fos = new FileOutputStream("out.hex"); - fos.write(dat.getActionBytes()); - fos.close(); - } catch (IOException ex) { - - } - - } - } - - if(e.getActionCommand().equals("LOADHEXACTION")){ - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); - if (ti.tag instanceof ASMSource) { - ASMSource dat = (ASMSource) ti.tag; - FileInputStream fis; - try { - fis = new FileInputStream("out.hex"); - byte data[]=new byte[fis.available()]; - dat.setActionBytes(data); - fis.read(data); - fis.close(); - editor.setText(dat.getASMSource(10)); - } catch (IOException ex) { - - } - - } - } - - if (e.getActionCommand().equals("SAVEACTION")) { - TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); - if (ti.tag instanceof ASMSource) { - ASMSource dat = (ASMSource) ti.tag; - try { - dat.setActions(ASMParser.parse(new ByteArrayInputStream(editor.getText().getBytes()), 10),10); //TODO:Ensure correct version here - valueChanged(null); - JOptionPane.showMessageDialog(this, "Code successfully saved"); - } catch (IOException ex) { - } catch (ParseException ex) { - JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); - } - } - } - if (e.getActionCommand().equals("SAVE")) { + if (e.getActionCommand().equals("SAVEHEXACTION")) { + TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + if (ti.tag instanceof ASMSource) { + ASMSource dat = (ASMSource) ti.tag; + FileOutputStream fos; try { - Main.saveFile(Main.file); + fos = new FileOutputStream("out.hex"); + fos.write(dat.getActionBytes()); + fos.close(); } catch (IOException ex) { } - } - if (e.getActionCommand().equals("SAVEAS")) { - if (Main.saveFileDialog()) { - setTitle(Main.applicationName + " - " + Main.getFileTitle()); - } - } - if (e.getActionCommand().equals("OPEN")) { - Main.openFileDialog(); - } - } - public void setStatus(String s) { - if (s.equals("")) { - loadingPanel.setVisible(false); - } else { - loadingPanel.setVisible(true); - } - statusLabel.setText(s); - } + } + } + + if (e.getActionCommand().equals("LOADHEXACTION")) { + TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + if (ti.tag instanceof ASMSource) { + ASMSource dat = (ASMSource) ti.tag; + FileInputStream fis; + try { + fis = new FileInputStream("out.hex"); + byte data[] = new byte[fis.available()]; + dat.setActionBytes(data); + fis.read(data); + fis.close(); + editor.setText(dat.getASMSource(10)); + } catch (IOException ex) { + } + + } + } + + if (e.getActionCommand().equals("SAVEACTION")) { + TagTreeItem ti = (TagTreeItem) tagTree.getLastSelectedPathComponent(); + if (ti.tag instanceof ASMSource) { + ASMSource dat = (ASMSource) ti.tag; + try { + dat.setActions(ASMParser.parse(new ByteArrayInputStream(editor.getText().getBytes()), 10), 10); //TODO:Ensure correct version here + valueChanged(null); + JOptionPane.showMessageDialog(this, "Code successfully saved"); + } catch (IOException ex) { + } catch (ParseException ex) { + JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); + } + } + } + if (e.getActionCommand().equals("SAVE")) { + try { + Main.saveFile(Main.file); + } catch (IOException ex) { + } + } + if (e.getActionCommand().equals("SAVEAS")) { + if (Main.saveFileDialog()) { + setTitle(Main.applicationName + " - " + Main.getFileTitle()); + } + } + if (e.getActionCommand().equals("OPEN")) { + Main.openFileDialog(); + } + } + + public void setStatus(String s) { + if (s.equals("")) { + loadingPanel.setVisible(false); + } else { + loadingPanel.setVisible(true); + } + statusLabel.setText(s); + } } diff --git a/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java b/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java index 63e52b0ee..0265726a8 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java +++ b/trunk/src/com/jpexs/asdec/action/gui/TagTreeItem.java @@ -14,23 +14,23 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.gui; import java.util.ArrayList; import java.util.List; public class TagTreeItem { - public List subItems; - public Object tag; - public TagTreeItem(Object tag) { - this.tag = tag; - this.subItems = new ArrayList(); - } + public List subItems; + public Object tag; - @Override - public String toString() { - return tag.toString(); - } + public TagTreeItem(Object tag) { + this.tag = tag; + this.subItems = new ArrayList(); + } + + @Override + public String toString() { + return tag.toString(); + } } diff --git a/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java b/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java index 39f1b1beb..11ebf6d52 100644 --- a/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java +++ b/trunk/src/com/jpexs/asdec/action/gui/TagTreeModel.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.gui; import com.jpexs.asdec.tags.*; @@ -25,131 +24,134 @@ import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; public class TagTreeModel implements TreeModel { - private String root = ""; - private List list = new ArrayList(); - public TagTreeModel(List list) { - List list2 = new ArrayList(); - list2.addAll(list); - this.list = processTagList(list2); - } + private String root = ""; + private List list = new ArrayList(); - public List processTagList(List list) { - List ret = new ArrayList(); - int frame = 1; - List frames = new ArrayList(); + public TagTreeModel(List list) { + List list2 = new ArrayList(); + list2.addAll(list); + this.list = processTagList(list2); + } - List exportAssetsTags = new ArrayList(); - for (Object t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } - if (t instanceof ShowFrameTag) { - TagTreeItem tti = new TagTreeItem("frame" + frame); + public List processTagList(List list) { + List ret = new ArrayList(); + int frame = 1; + List frames = new ArrayList(); - for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).tag instanceof DefineSpriteTag)) { - if (!(ret.get(r).tag instanceof DefineButtonTag)) { - if (!(ret.get(r).tag instanceof DefineButton2Tag)) { - if (!(ret.get(r).tag instanceof DoInitActionTag)) { - tti.subItems.add(ret.get(r)); - ret.remove(r); - } - } + List exportAssetsTags = new ArrayList(); + for (Object t : list) { + if (t instanceof ExportAssetsTag) { + exportAssetsTags.add((ExportAssetsTag) t); + } + if (t instanceof ShowFrameTag) { + TagTreeItem tti = new TagTreeItem("frame" + frame); + + for (int r = ret.size() - 1; r >= 0; r--) { + if (!(ret.get(r).tag instanceof DefineSpriteTag)) { + if (!(ret.get(r).tag instanceof DefineButtonTag)) { + if (!(ret.get(r).tag instanceof DefineButton2Tag)) { + if (!(ret.get(r).tag instanceof DoInitActionTag)) { + tti.subItems.add(ret.get(r)); + ret.remove(r); } - } - } - frame++; - frames.add(tti); - } else if (t instanceof ASMSource) { - TagTreeItem tti = new TagTreeItem(t); - ret.add(tti); - } else if (t instanceof Container) { - if (((Container) t).getItemCount() > 0) { - - TagTreeItem tti = new TagTreeItem(t); - List subItems = ((Container) t).getSubItems(); - - tti.subItems = processTagList(subItems); - ret.add(tti); - } + } + } + } } + frame++; + frames.add(tti); + } else if (t instanceof ASMSource) { + TagTreeItem tti = new TagTreeItem(t); + ret.add(tti); + } else if (t instanceof Container) { + if (((Container) t).getItemCount() > 0) { - } - ret.addAll(frames); - for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).tag instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + TagTreeItem tti = new TagTreeItem(t); + List subItems = ((Container) t).getSubItems(); + + tti.subItems = processTagList(subItems); + ret.add(tti); } - if (ret.get(i).tag instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + + } + ret.addAll(frames); + for (int i = ret.size() - 1; i >= 0; i--) { + if (ret.get(i).tag instanceof DefineSpriteTag) { + ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButtonTag) { + ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButton2Tag) { + ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DoInitActionTag) { + ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof ASMSource) { + ASMSource ass = (ASMSource) ret.get(i).tag; + if (ass.containsSource()) { + continue; } - if (ret.get(i).tag instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).subItems.size() == 0) { + ret.remove(i); + } + } + return ret; + } + + public Object getRoot() { + return root; + } + + public Object getChild(Object parent, int index) { + if (parent == root) { + return list.get(index); + } else { + return ((TagTreeItem) parent).subItems.get(index); + } + } + + public int getChildCount(Object parent) { + if (parent == root) { + return list.size(); + } else { + return ((TagTreeItem) parent).subItems.size(); + } + } + + public boolean isLeaf(Object node) { + return (getChildCount(node) == 0); + } + + public void valueForPathChanged(TreePath path, Object newValue) { + } + + public int getIndexOfChild(Object parent, Object child) { + if (parent == root) { + for (int t = 0; t < list.size(); t++) { + if (list.get(t) == child) { + return t; } - if (ret.get(i).tag instanceof DoInitActionTag) { - ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + return -1; + } else { + List subTags = ((TagTreeItem) parent).subItems; + for (int t = 0; t < subTags.size(); t++) { + if (subTags.get(t) == child) { + return t; } - if (ret.get(i).tag instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).tag; - if (ass.containsSource()) continue; - } - if (ret.get(i).subItems.size() == 0) { - ret.remove(i); - } - } - return ret; - } + } + return -1; + } + } + public void addTreeModelListener(TreeModelListener l) { + } - public Object getRoot() { - return root; - } - - public Object getChild(Object parent, int index) { - if (parent == root) { - return list.get(index); - } else { - return ((TagTreeItem) parent).subItems.get(index); - } - } - - public int getChildCount(Object parent) { - if (parent == root) { - return list.size(); - } else { - return ((TagTreeItem) parent).subItems.size(); - } - } - - public boolean isLeaf(Object node) { - return (getChildCount(node) == 0); - } - - public void valueForPathChanged(TreePath path, Object newValue) { - - } - - public int getIndexOfChild(Object parent, Object child) { - if (parent == root) { - for (int t = 0; t < list.size(); t++) { - if (list.get(t) == child) return t; - } - return -1; - } else { - List subTags = ((TagTreeItem) parent).subItems; - for (int t = 0; t < subTags.size(); t++) { - if (subTags.get(t) == child) return t; - } - return -1; - } - } - - public void addTreeModelListener(TreeModelListener l) { - - } - - public void removeTreeModelListener(TreeModelListener l) { - - } + public void removeTreeModelListener(TreeModelListener l) { + } } diff --git a/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java b/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java index 7249134a0..670001cfb 100644 --- a/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java +++ b/trunk/src/com/jpexs/asdec/action/parser/ASMParser.java @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package com.jpexs.asdec.action.parser; import com.jpexs.asdec.action.Action; @@ -32,254 +31,253 @@ import java.util.List; public class ASMParser { - public static List parse(List