mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-02 14:14:21 +00:00
AS3 assembly testdata template generator
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2018 JPEXS, All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3.0 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.generators;
|
||||
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AS3NewAssemblyGenerator {
|
||||
public static void main(String[] args) throws UnsupportedEncodingException {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
System.out.print("Enter test class name:");
|
||||
final String DIR = "testdata/custom/abc/custom-0/";
|
||||
String className = sc.nextLine();
|
||||
String templateClassData = Helper.readTextFile(DIR + "tests/Template.class.asasm");
|
||||
String templateScriptData = Helper.readTextFile(DIR + "tests/Template.script.asasm");
|
||||
String mainData = Helper.readTextFile(DIR + "custom-0.main.asasm");
|
||||
|
||||
String classData = templateClassData.replace("Template", className);;
|
||||
String scriptData = templateScriptData.replace("Template", className);
|
||||
final String PLACEHOLDER = " ; place to add next\n";
|
||||
|
||||
String mainDataUpdated = mainData.replace(PLACEHOLDER, " #include \"tests/" + className + ".script.asasm\"\n" + PLACEHOLDER);
|
||||
|
||||
Helper.writeFile(DIR + "tests/" + className + ".class.asasm", classData.getBytes("UTF-8"));
|
||||
Helper.writeFile(DIR + "tests/" + className + ".script.asasm", scriptData.getBytes("UTF-8"));
|
||||
Helper.writeFile(DIR + "custom-0.main.asasm", mainDataUpdated.getBytes("UTF-8"));
|
||||
|
||||
}
|
||||
}
|
||||
62
libsrc/ffdec_lib/testdata/custom/abc/custom-0/tests/Template.class.asasm
vendored
Normal file
62
libsrc/ffdec_lib/testdata/custom/abc/custom-0/tests/Template.class.asasm
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
class
|
||||
refid "tests:Template"
|
||||
instance QName(PackageNamespace("tests"), "Template")
|
||||
extends QName(PackageNamespace(""), "Object")
|
||||
flag SEALED
|
||||
flag PROTECTEDNS
|
||||
protectedns ProtectedNamespace("tests:Template")
|
||||
iinit
|
||||
refid "tests:Template/instance/init"
|
||||
body
|
||||
maxstack 1
|
||||
localcount 1
|
||||
initscopedepth 4
|
||||
maxscopedepth 5
|
||||
code
|
||||
getlocal0
|
||||
pushscope
|
||||
|
||||
getlocal0
|
||||
constructsuper 0
|
||||
|
||||
returnvoid
|
||||
end ; code
|
||||
end ; body
|
||||
end ; method
|
||||
trait method QName(PackageNamespace(""), "run")
|
||||
method
|
||||
refid "tests:Template/instance/run"
|
||||
returns QName(PackageNamespace(""), "void")
|
||||
body
|
||||
maxstack 2
|
||||
localcount 4
|
||||
initscopedepth 4
|
||||
maxscopedepth 5
|
||||
code
|
||||
getlocal0
|
||||
pushscope
|
||||
|
||||
; TODO: insertcode here
|
||||
|
||||
returnvoid
|
||||
end ; code
|
||||
end ; body
|
||||
end ; method
|
||||
end ; trait
|
||||
end ; instance
|
||||
cinit
|
||||
refid "tests:Template/class/init"
|
||||
body
|
||||
maxstack 1
|
||||
localcount 1
|
||||
initscopedepth 3
|
||||
maxscopedepth 4
|
||||
code
|
||||
getlocal0
|
||||
pushscope
|
||||
|
||||
returnvoid
|
||||
end ; code
|
||||
end ; body
|
||||
end ; method
|
||||
end ; class
|
||||
29
libsrc/ffdec_lib/testdata/custom/abc/custom-0/tests/Template.script.asasm
vendored
Normal file
29
libsrc/ffdec_lib/testdata/custom/abc/custom-0/tests/Template.script.asasm
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
script
|
||||
sinit
|
||||
refid "tests:Template/init"
|
||||
body
|
||||
maxstack 2
|
||||
localcount 1
|
||||
initscopedepth 1
|
||||
maxscopedepth 3
|
||||
code
|
||||
getlocal0
|
||||
pushscope
|
||||
|
||||
findpropstrict Multiname("Template", [PackageNamespace("tests")])
|
||||
getlex QName(PackageNamespace(""), "Object")
|
||||
pushscope
|
||||
|
||||
getlex Multiname("Object", [PrivateNamespace(null, "tests:Template"), PackageNamespace(""), PackageNamespace("tests"), PackageInternalNs("tests"), Namespace("http://adobe.com/AS3/2006/builtin")])
|
||||
newclass "tests:Template"
|
||||
popscope
|
||||
initproperty QName(PackageNamespace("tests"), "Template")
|
||||
|
||||
returnvoid
|
||||
end ; code
|
||||
end ; body
|
||||
end ; method
|
||||
trait class QName(PackageNamespace("tests"), "Template")
|
||||
#include "Template.class.asasm"
|
||||
end ; trait
|
||||
end ; script
|
||||
Reference in New Issue
Block a user