Browse Source

Merge remote-tracking branch 'kindlich/development' into development

Jared 5 years ago
parent
commit
1c81df7e77
No account linked to committer's email address

+ 3
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java View File

36
  */
36
  */
37
 public class JavaCompiler {
37
 public class JavaCompiler {
38
 	private int generatedScriptBlockCounter = 0;
38
 	private int generatedScriptBlockCounter = 0;
39
-	
39
+	private int expansionCounter = 0;
40
+
40
 	public JavaCompiler() {}
41
 	public JavaCompiler() {}
41
 	
42
 	
42
 	public JavaBytecodeModule compile(String packageName, SemanticModule module, JavaCompileSpace space) {
43
 	public JavaBytecodeModule compile(String packageName, SemanticModule module, JavaCompileSpace space) {
47
 		context.addModule(module.module, target);
48
 		context.addModule(module.module, target);
48
 		
49
 		
49
 		for (HighLevelDefinition definition : module.definitions.getAll()) {
50
 		for (HighLevelDefinition definition : module.definitions.getAll()) {
50
-			String filename = getFilename(definition);
51
+			String filename = getFilename(definition) + "_" + (definition.name == null ? "generated" : definition.name) + "_" + expansionCounter++;
51
 			JavaPrepareDefinitionVisitor definitionPreparer = new JavaPrepareDefinitionVisitor(context, target, filename, null);
52
 			JavaPrepareDefinitionVisitor definitionPreparer = new JavaPrepareDefinitionVisitor(context, target, filename, null);
52
 			definition.accept(definitionPreparer);
53
 			definition.accept(definitionPreparer);
53
 		}
54
 		}

+ 0
- 17
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java View File

21
 import org.openzen.zenscript.javabytecode.compiler.JavaModificationExpressionVisitor.PushOption;
21
 import org.openzen.zenscript.javabytecode.compiler.JavaModificationExpressionVisitor.PushOption;
22
 import org.openzen.zenscript.javashared.*;
22
 import org.openzen.zenscript.javashared.*;
23
 
23
 
24
-import java.io.FileOutputStream;
25
-import java.io.IOException;
26
 import java.lang.reflect.Method;
24
 import java.lang.reflect.Method;
27
 import java.lang.reflect.Modifier;
25
 import java.lang.reflect.Modifier;
28
 import java.util.Arrays;
26
 import java.util.Arrays;
2086
 
2084
 
2087
 		context.register(className, lambdaCW.toByteArray());
2085
 		context.register(className, lambdaCW.toByteArray());
2088
 
2086
 
2089
-		try (FileOutputStream out = new FileOutputStream(className + ".class")) {
2090
-			out.write(lambdaCW.toByteArray());
2091
-		} catch (IOException e) {
2092
-			e.printStackTrace();
2093
-		}
2094
-
2095
 		return null;
2087
 		return null;
2096
 	}
2088
 	}
2097
 
2089
 
4119
 		javaWriter.dupX1();
4111
 		javaWriter.dupX1();
4120
 		javaWriter.swap();
4112
 		javaWriter.swap();
4121
 		javaWriter.invokeSpecial(className, "<init>", constructorDesc);
4113
 		javaWriter.invokeSpecial(className, "<init>", constructorDesc);
4122
-
4123
-		//Debug-only, remove later
4124
-		if(true) {
4125
-			try (FileOutputStream out = new FileOutputStream(className + ".class")) {
4126
-				out.write(lambdaCW.toByteArray());
4127
-			} catch (IOException e) {
4128
-				e.printStackTrace();
4129
-			}
4130
-		}
4131
 	}
4114
 	}
4132
 
4115
 
4133
 	@Override
4116
 	@Override

+ 1
- 18
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaDefinitionVisitor.java View File

28
 import org.openzen.zenscript.javashared.JavaTypeGenericVisitor;
28
 import org.openzen.zenscript.javashared.JavaTypeGenericVisitor;
29
 import org.openzen.zenscript.javashared.JavaVariantOption;
29
 import org.openzen.zenscript.javashared.JavaVariantOption;
30
 
30
 
31
-import java.io.FileOutputStream;
32
-import java.io.IOException;
33
 import java.util.ArrayList;
31
 import java.util.ArrayList;
34
 import java.util.List;
32
 import java.util.List;
35
 
33
 
186
 		writer.visitEnd();
184
 		writer.visitEnd();
187
 
185
 
188
 
186
 
189
-		final byte[] classBytes = writer.toByteArray();
190
-
191
-		try (FileOutputStream out = new FileOutputStream("ttt.class")) {
192
-			out.write(classBytes);
193
-		} catch (IOException e) {
194
-			e.printStackTrace();
195
-		}
196
-
197
-		return classBytes;
187
+		return writer.toByteArray();
198
 	}
188
 	}
199
 
189
 
200
 	@Override
190
 	@Override
303
 			optionWriter.visitEnd();
293
 			optionWriter.visitEnd();
304
 			final byte[] byteArray = optionWriter.toByteArray();
294
 			final byte[] byteArray = optionWriter.toByteArray();
305
 			context.register(optionTag.variantOptionClass.internalName, byteArray);
295
 			context.register(optionTag.variantOptionClass.internalName, byteArray);
306
-
307
-			//Print the option files, won't be in production
308
-			try (FileOutputStream out = new FileOutputStream(optionTag.variantOptionClass.internalName.replace('/', '_') + ".class")) {
309
-				out.write(byteArray);
310
-			} catch (IOException e) {
311
-				e.printStackTrace();
312
-			}
313
 		}
296
 		}
314
 
297
 
315
 
298
 

Loading…
Cancel
Save