mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-17 02:45:07 +00:00
- Rewrote the whole damn typecasting system. Now uses a more flexible and more structure casting rule system.
- Improved function literals. Function recipes are a thing! - Added mirrored shaped recipes - Fixed a few "any" type - related errors - Added environment to the bracket handlers. Breaks existing bracket handlers!! - Turned JavaMethod into an interface. Can now be used both for existing methods and generated ones. Makes a few things simpler :) - Added creative and adventure getters to player info
This commit is contained in:
1 parent
c67ad22270
commit
154c2242f9
172 files changed
+5400
-2134
No files matched your search
@@ -50,8 +50,9 @@ public class ZenModule {
|
||||
* @param mainFileName main filename (used for debug info)
|
||||
* @param scripts scripts to compile
|
||||
* @param environmentGlobal global compile environment
|
||||
* @param debug enable debug mode (outputs classes to generated directory)
|
||||
*/
|
||||
public static void compileScripts(String mainFileName, List<ZenParsedFile> scripts, IEnvironmentGlobal environmentGlobal) {
|
||||
public static void compileScripts(String mainFileName, List<ZenParsedFile> scripts, IEnvironmentGlobal environmentGlobal, boolean debug) {
|
||||
ClassWriter clsMain = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
clsMain.visitSource(mainFileName, null);
|
||||
|
||||
@@ -117,6 +118,7 @@ public class ZenModule {
|
||||
if (script.getStatements().size() > 0) {
|
||||
MethodOutput scriptOutput = new MethodOutput(clsScript, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "__script__", "()V", null, null);
|
||||
IEnvironmentMethod functionMethod = new EnvironmentMethod(scriptOutput, environmentScript);
|
||||
//scriptOutput.enableDebug();
|
||||
scriptOutput.start();
|
||||
for (Statement statement : script.getStatements()) {
|
||||
statement.compile(functionMethod);
|
||||
@@ -143,6 +145,28 @@ public class ZenModule {
|
||||
constructor.visitMaxs(0, 0);
|
||||
constructor.visitEnd();
|
||||
|
||||
// debug: output classes
|
||||
if (debug) {
|
||||
try {
|
||||
File outputDir = new File("generated");
|
||||
outputDir.mkdir();
|
||||
|
||||
for (String className : environmentGlobal.getClassNames()) {
|
||||
File outputFile = new File(outputDir, className.replace('.', '/') + ".class");
|
||||
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
outputFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
FileOutputStream output = new FileOutputStream(outputFile);
|
||||
output.write(environmentGlobal.getClass(className));
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
environmentGlobal.putClass("__ZenMain__", clsMain.toByteArray());
|
||||
}
|
||||
|
||||
@@ -176,7 +200,7 @@ public class ZenModule {
|
||||
List<ZenParsedFile> files = new ArrayList<ZenParsedFile>();
|
||||
files.add(file);
|
||||
|
||||
compileScripts(filename, files, environmentGlobal);
|
||||
compileScripts(filename, files, environmentGlobal, false);
|
||||
|
||||
// debug: output classes
|
||||
File outputDir = new File("generated");
|
||||
@@ -238,18 +262,7 @@ public class ZenModule {
|
||||
}
|
||||
|
||||
String filename = file.getName();
|
||||
compileScripts(filename, files, environmentGlobal);
|
||||
|
||||
// debug: output classes
|
||||
File outputDir = new File("generated");
|
||||
outputDir.mkdir();
|
||||
|
||||
for (Map.Entry<String, byte[]> entry : classes.entrySet()) {
|
||||
File outputFile = new File(outputDir, entry.getKey().replace('.', '/') + ".class");
|
||||
FileOutputStream output = new FileOutputStream(outputFile);
|
||||
output.write(entry.getValue());
|
||||
output.close();
|
||||
}
|
||||
compileScripts(filename, files, environmentGlobal, true);
|
||||
|
||||
return new ZenModule(classes, baseClassLoader);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user