Browse Source

Added script parameter system. Also refactored SourceFile info, it's no longer a tag but available as field in ScriptBlock.

Stan Hebben 6 years ago
parent
commit
0d31f0cd9a
22 changed files with 207 additions and 50 deletions
  1. 8
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/ScriptBlock.java
  2. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/SemanticModule.java
  3. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java
  4. 14
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java
  5. 2
    1
      Constructor/src/main/java/org/openzen/zenscript/constructor/module/DirectoryModuleReference.java
  6. 6
    5
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeModule.java
  7. 84
    6
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeRunUnit.java
  8. 20
    6
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java
  9. 1
    1
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaNonPushingExpressionVisitor.java
  10. 2
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaScriptFile.java
  11. 2
    1
      JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java
  12. 17
    4
      JavaIntegration/src/main/java/org/openzen/zencode/java/ScriptingEngine.java
  13. 3
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java
  14. 4
    0
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java
  15. 4
    3
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceCompiler.java
  16. 3
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceModule.java
  17. 11
    6
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java
  18. 5
    3
      Parser/src/main/java/org/openzen/zenscript/parser/ZippedPackage.java
  19. 3
    0
      ScriptingExample/scripts/scriptparameters.zs
  20. 11
    2
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java
  21. 1
    1
      Shared/src/main/java/org/openzen/zencode/shared/SourceFile.java
  22. 1
    0
      Validator/src/main/java/org/openzen/zenscript/validator/Validator.java

+ 8
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/ScriptBlock.java View File

@@ -8,6 +8,7 @@ package org.openzen.zenscript.codemodel;
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zencode.shared.ConcatMap;
11
+import org.openzen.zencode.shared.SourceFile;
11 12
 import org.openzen.zencode.shared.Taggable;
12 13
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
13 14
 import org.openzen.zenscript.codemodel.scope.TypeScope;
@@ -19,18 +20,22 @@ import org.openzen.zenscript.codemodel.statement.Statement;
19 20
  * @author Hoofdgebruiker
20 21
  */
21 22
 public class ScriptBlock extends Taggable {
23
+	public final SourceFile file;
22 24
 	public final Module module;
23 25
 	public final ZSPackage pkg;
26
+	public final FunctionHeader scriptHeader;
24 27
 	public final List<Statement> statements;
25 28
 	
26
-	public ScriptBlock(Module module, ZSPackage pkg, List<Statement> statements) {
29
+	public ScriptBlock(SourceFile file, Module module, ZSPackage pkg, FunctionHeader scriptHeader, List<Statement> statements) {
30
+		this.file = file;
27 31
 		this.module = module;
28 32
 		this.pkg = pkg;
33
+		this.scriptHeader = scriptHeader;
29 34
 		this.statements = statements;
30 35
 	}
31 36
 	
32 37
 	public ScriptBlock withStatements(List<Statement> newStatements) {
33
-		ScriptBlock result = new ScriptBlock(module, pkg, newStatements);
38
+		ScriptBlock result = new ScriptBlock(file, module, pkg, scriptHeader, newStatements);
34 39
 		result.addAllTagsFrom(this);
35 40
 		return result;
36 41
 	}
@@ -40,7 +45,7 @@ public class ScriptBlock extends Taggable {
40 45
 		for (Statement statement : statements) {
41 46
 			normalized.add(statement.normalize(scope, ConcatMap.empty(LoopStatement.class, LoopStatement.class)));
42 47
 		}
43
-		ScriptBlock result = new ScriptBlock(module, pkg, normalized);
48
+		ScriptBlock result = new ScriptBlock(file, module, pkg, scriptHeader, normalized);
44 49
 		result.addAllTagsFrom(this);
45 50
 		return result;
46 51
 	}

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/SemanticModule.java View File

@@ -29,6 +29,7 @@ public class SemanticModule {
29 29
 	
30 30
 	public final String name;
31 31
 	public final SemanticModule[] dependencies;
32
+	public final FunctionParameter[] parameters;
32 33
 	
33 34
 	public final State state;
34 35
 	public final Module module;
@@ -46,6 +47,7 @@ public class SemanticModule {
46 47
 	public SemanticModule(
47 48
 			Module module,
48 49
 			SemanticModule[] dependencies,
50
+			FunctionParameter[] parameters,
49 51
 			State state,
50 52
 			ZSPackage rootPackage,
51 53
 			ZSPackage modulePackage,
@@ -59,6 +61,7 @@ public class SemanticModule {
59 61
 		this.name = module.name;
60 62
 		this.module = module;
61 63
 		this.dependencies = dependencies;
64
+		this.parameters = parameters;
62 65
 		
63 66
 		this.state = state;
64 67
 		this.rootPackage = rootPackage;
@@ -96,6 +99,7 @@ public class SemanticModule {
96 99
 		return new SemanticModule(
97 100
 				module,
98 101
 				dependencies,
102
+				parameters,
99 103
 				State.NORMALIZED,
100 104
 				rootPackage,
101 105
 				modulePackage,

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/AnnotationProcessor.java View File

@@ -58,7 +58,7 @@ public class AnnotationProcessor implements ModuleProcessor {
58 58
 	@Override
59 59
 	public ScriptBlock process(ScriptBlock block) {
60 60
 		FileScope fileScope = new FileScope(context, expansions, new HashMap<>(), member -> {});
61
-		StatementScope scope = new GlobalScriptScope(fileScope);
61
+		StatementScope scope = new GlobalScriptScope(fileScope, block.scriptHeader);
62 62
 		List<Statement> transformed = new ArrayList<>();
63 63
 		boolean unchanged = true;
64 64
 		for (Statement statement : block.statements) {

+ 14
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/scope/GlobalScriptScope.java View File

@@ -10,11 +10,13 @@ import org.openzen.zencode.shared.CodePosition;
10 10
 import org.openzen.zencode.shared.CompileException;
11 11
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
12 12
 import org.openzen.zenscript.codemodel.FunctionHeader;
13
+import org.openzen.zenscript.codemodel.FunctionParameter;
13 14
 import org.openzen.zenscript.codemodel.GenericMapper;
14 15
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
15 16
 import org.openzen.zenscript.codemodel.statement.LoopStatement;
16 17
 import org.openzen.zenscript.codemodel.GenericName;
17 18
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
19
+import org.openzen.zenscript.codemodel.expression.GetFunctionParameterExpression;
18 20
 import org.openzen.zenscript.codemodel.type.StoredType;
19 21
 import org.openzen.zenscript.codemodel.type.TypeID;
20 22
 import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
@@ -27,9 +29,11 @@ import org.openzen.zenscript.codemodel.type.storage.StorageTag;
27 29
  */
28 30
 public class GlobalScriptScope extends StatementScope {
29 31
 	private final BaseScope file;
32
+	private final FunctionHeader header;
30 33
 	
31
-	public GlobalScriptScope(BaseScope file) {
34
+	public GlobalScriptScope(BaseScope file, FunctionHeader scriptHeader) {
32 35
 		this.file = file;
36
+		header = scriptHeader;
33 37
 	}
34 38
 	
35 39
 	@Override
@@ -48,6 +52,14 @@ public class GlobalScriptScope extends StatementScope {
48 52
 		if (result != null)
49 53
 			return result;
50 54
 		
55
+		if (name.hasNoArguments()) {
56
+			for (FunctionParameter parameter : header.parameters) {
57
+				if (parameter.name.equals(name.name)) {
58
+					return new GetFunctionParameterExpression(position, parameter);
59
+				}
60
+			}
61
+		}
62
+		
51 63
 		return file.get(position, name);
52 64
 	}
53 65
 
@@ -68,7 +80,7 @@ public class GlobalScriptScope extends StatementScope {
68 80
 
69 81
 	@Override
70 82
 	public FunctionHeader getFunctionHeader() {
71
-		return null;
83
+		return header;
72 84
 	}
73 85
 
74 86
 	@Override

+ 2
- 1
Constructor/src/main/java/org/openzen/zenscript/constructor/module/DirectoryModuleReference.java View File

@@ -14,6 +14,7 @@ import org.json.JSONArray;
14 14
 import org.json.JSONObject;
15 15
 import org.openzen.zencode.shared.CompileException;
16 16
 import org.openzen.zencode.shared.FileSourceFile;
17
+import org.openzen.zenscript.codemodel.FunctionParameter;
17 18
 import org.openzen.zenscript.codemodel.Module;
18 19
 import org.openzen.zenscript.codemodel.ModuleSpace;
19 20
 import org.openzen.zenscript.codemodel.SemanticModule;
@@ -94,7 +95,7 @@ public class DirectoryModuleReference implements ModuleReference {
94 95
 			CompilingPackage compilingPackage = new CompilingPackage(pkg, module);
95 96
 			
96 97
 			ParsedFile[] parsedFiles = parsedModule.parse(compilingPackage);
97
-			SemanticModule result = ParsedFile.compileSyntaxToSemantic(dependencies, compilingPackage, parsedFiles, space, exceptionLogger);
98
+			SemanticModule result = ParsedFile.compileSyntaxToSemantic(dependencies, compilingPackage, parsedFiles, space, FunctionParameter.NONE, exceptionLogger);
98 99
 			
99 100
 			JSONObject globals = json.optJSONObject("globals");
100 101
 			if (globals != null) {

+ 6
- 5
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeModule.java View File

@@ -9,6 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.HashMap;
10 10
 import java.util.List;
11 11
 import java.util.Map;
12
+import org.openzen.zenscript.codemodel.FunctionParameter;
12 13
 import org.openzen.zenscript.codemodel.Module;
13 14
 import org.openzen.zenscript.javashared.JavaCompiledModule;
14 15
 import org.openzen.zenscript.javashared.JavaMethod;
@@ -19,10 +20,10 @@ import org.openzen.zenscript.javashared.JavaMethod;
19 20
  */
20 21
 public class JavaBytecodeModule extends JavaCompiledModule {
21 22
 	private final Map<String, byte[]> classes = new HashMap<>();
22
-	private final List<JavaMethod> scripts = new ArrayList<>();
23
+	private final List<JavaScriptMethod> scripts = new ArrayList<>();
23 24
 	
24
-	public JavaBytecodeModule(Module module) {
25
-		super(module);
25
+	public JavaBytecodeModule(Module module, FunctionParameter[] parameters) {
26
+		super(module, parameters);
26 27
 	}
27 28
 	
28 29
 	public void addClass(String name, byte[] bytecode) {
@@ -32,7 +33,7 @@ public class JavaBytecodeModule extends JavaCompiledModule {
32 33
 		classes.put(name, bytecode);
33 34
 	}
34 35
 	
35
-	public void addScript(JavaMethod method) {
36
+	public void addScript(JavaScriptMethod method) {
36 37
 		scripts.add(method);
37 38
 	}
38 39
 	
@@ -40,7 +41,7 @@ public class JavaBytecodeModule extends JavaCompiledModule {
40 41
 		return classes;
41 42
 	}
42 43
 	
43
-	public List<JavaMethod> getScripts() {
44
+	public List<JavaScriptMethod> getScripts() {
44 45
 		return scripts;
45 46
 	}
46 47
 }

+ 84
- 6
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaBytecodeRunUnit.java View File

@@ -10,6 +10,7 @@ import java.io.FileOutputStream;
10 10
 import java.io.IOException;
11 11
 import java.lang.reflect.InvocationTargetException;
12 12
 import java.util.ArrayList;
13
+import java.util.Collections;
13 14
 import java.util.HashMap;
14 15
 import java.util.List;
15 16
 import java.util.Map;
@@ -17,11 +18,16 @@ import java.util.logging.Level;
17 18
 import java.util.logging.Logger;
18 19
 import org.objectweb.asm.ClassWriter;
19 20
 import org.objectweb.asm.Opcodes;
21
+import org.objectweb.asm.Type;
20 22
 import org.openzen.zencode.shared.CodePosition;
23
+import org.openzen.zenscript.codemodel.FunctionHeader;
24
+import org.openzen.zenscript.codemodel.FunctionParameter;
25
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
21 26
 import org.openzen.zenscript.javabytecode.compiler.JavaClassWriter;
22 27
 import org.openzen.zenscript.javabytecode.compiler.JavaWriter;
23 28
 import org.openzen.zenscript.javashared.JavaClass;
24 29
 import org.openzen.zenscript.javashared.JavaMethod;
30
+import org.openzen.zenscript.javashared.JavaParameterInfo;
25 31
 
26 32
 /**
27 33
  *
@@ -29,7 +35,9 @@ import org.openzen.zenscript.javashared.JavaMethod;
29 35
  */
30 36
 public class JavaBytecodeRunUnit {
31 37
 	private final Map<String, byte[]> classes = new HashMap<>();
32
-	private final List<JavaMethod> scripts = new ArrayList<>();
38
+	private final List<JavaScriptMethod> scripts = new ArrayList<>();
39
+	private final List<FunctionParameter> scriptParameters = new ArrayList<>();
40
+	private final List<JavaParameterInfo> scriptParameterInfo = new ArrayList<>();
33 41
 	
34 42
 	private boolean scriptsWritten = false;
35 43
 	
@@ -39,16 +47,41 @@ public class JavaBytecodeRunUnit {
39 47
 		for (Map.Entry<String, byte[]> classEntry : module.getClasses().entrySet())
40 48
 			classes.put(classEntry.getKey().replace('/', '.'), classEntry.getValue());
41 49
 		
42
-		scripts.addAll(module.getScripts());
50
+		for (JavaScriptMethod script : module.getScripts()) {
51
+			scripts.add(script);
52
+			
53
+			for (int i = 0; i < script.parameters.length; i++) {
54
+				FunctionParameter parameter = script.parameters[i];
55
+				if (!scriptParameters.contains(parameter)) {
56
+					scriptParameters.add(parameter);
57
+					scriptParameterInfo.add(script.parametersInfo[i]);
58
+				}
59
+			}
60
+		}
43 61
 	}
44 62
 	
45 63
 	public void run() {
64
+		run(Collections.emptyMap());
65
+	}
66
+	
67
+	public void run(Map<FunctionParameter, Object> arguments) {
46 68
 		writeScripts();
47 69
 		
48 70
 		ScriptClassLoader classLoader = new ScriptClassLoader();
49 71
 
72
+		Object[] argumentsArray = new Object[scriptParameters.size()];
73
+		for (int i = 0; i < scriptParameters.size(); i++) {
74
+			FunctionParameter parameter = scriptParameters.get(i);
75
+			if (!arguments.containsKey(parameter))
76
+				throw new IllegalArgumentException("Missing script argument for parameter " + parameter.name);
77
+			
78
+			argumentsArray[i] = arguments.get(parameter);
79
+		}
50 80
 		try {
51
-			classLoader.loadClass("Scripts").getMethod("run").invoke(null);
81
+			Class[] classes = new Class[scriptParameters.size()];
82
+			for (int i = 0; i < classes.length; i++)
83
+				classes[i] = loadClass(classLoader, scriptParameterInfo.get(i).typeDescriptor);
84
+			classLoader.loadClass("Scripts").getMethod("run", classes).invoke(null, argumentsArray);
52 85
 		} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | SecurityException | IllegalArgumentException ex) {
53 86
 			Logger.getLogger(JavaBytecodeRunUnit.class.getName()).log(Level.SEVERE, null, ex);
54 87
 		}
@@ -70,6 +103,10 @@ public class JavaBytecodeRunUnit {
70 103
 		}
71 104
 	}
72 105
 	
106
+	private int getParameterIndex(FunctionParameter parameter) {
107
+		return scriptParameters.indexOf(parameter);
108
+	}
109
+	
73 110
 	private void writeScripts() {
74 111
 		if (scriptsWritten)
75 112
 			return;
@@ -77,11 +114,23 @@ public class JavaBytecodeRunUnit {
77 114
 		JavaClassWriter scriptsClassWriter = new JavaClassWriter(ClassWriter.COMPUTE_FRAMES);
78 115
 		scriptsClassWriter.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, "Scripts", null, "java/lang/Object", null);
79 116
 		
80
-		JavaMethod runMethod = JavaMethod.getStatic(new JavaClass("script", "Scripts", JavaClass.Kind.CLASS), "run", "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
117
+		FunctionHeader header = new FunctionHeader(BasicTypeID.VOID, scriptParameters.toArray(new FunctionParameter[scriptParameters.size()]));
118
+		StringBuilder headerBuilder = new StringBuilder();
119
+		headerBuilder.append('(');
120
+		for (int i = 0; i < scriptParameters.size(); i++) {
121
+			headerBuilder.append(scriptParameterInfo.get(i).typeDescriptor);
122
+		}
123
+		headerBuilder.append(")V");
124
+		
125
+		JavaMethod runMethod = JavaMethod.getStatic(new JavaClass("script", "Scripts", JavaClass.Kind.CLASS), "run", headerBuilder.toString(), Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
81 126
 		final JavaWriter runWriter = new JavaWriter(CodePosition.GENERATED, scriptsClassWriter, runMethod, null, null, null);
82 127
 		runWriter.start();
83
-		for (JavaMethod method : scripts)
84
-			runWriter.invokeStatic(method);
128
+		for (JavaScriptMethod method : scripts) {
129
+			for (int i = 0; i < method.parameters.length; i++) {
130
+				runWriter.load(Type.getType(method.parametersInfo[i].typeDescriptor), getParameterIndex(method.parameters[i]));
131
+			}
132
+			runWriter.invokeStatic(method.method);
133
+		}
85 134
 		
86 135
 		runWriter.ret();
87 136
 		runWriter.end();
@@ -107,4 +156,33 @@ public class JavaBytecodeRunUnit {
107 156
 			return super.loadClass(name);
108 157
 		}
109 158
 	}
159
+	
160
+	private static Class<?> loadClass(ClassLoader classLoader, String descriptor) throws ClassNotFoundException {
161
+		switch (descriptor) {
162
+			case "Z": return boolean.class;
163
+			case "B": return byte.class;
164
+			case "S": return short.class;
165
+			case "I": return int.class;
166
+			case "J": return long.class;
167
+			case "F": return float.class;
168
+			case "D": return double.class;
169
+			case "C": return char.class;
170
+			case "Ljava/lang/Object;": return Object.class;
171
+			case "Ljava/lang/String;": return String.class;
172
+			case "[Ljava/lang/Object;": return Object[].class;
173
+			case "[Ljava/lang/String;": return String[].class;
174
+		}
175
+		
176
+		return classLoader.loadClass(getClassName(descriptor));
177
+	}
178
+	
179
+	private static String getClassName(String descriptor) {
180
+		if (descriptor.startsWith("[")) {
181
+			return "[" + getClassName(descriptor.substring(1));
182
+		} else if (descriptor.startsWith("L")) {
183
+			return descriptor.substring(1, descriptor.length() - 1);
184
+		} else {
185
+			throw new IllegalArgumentException("Invalid descriptor: " + descriptor);
186
+		}
187
+	}
110 188
 }

+ 20
- 6
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java View File

@@ -11,11 +11,14 @@ import org.objectweb.asm.ClassWriter;
11 11
 import org.objectweb.asm.Opcodes;
12 12
 import org.openzen.zencode.shared.CodePosition;
13 13
 import org.openzen.zencode.shared.SourceFile;
14
+import org.openzen.zenscript.codemodel.FunctionHeader;
15
+import org.openzen.zenscript.codemodel.FunctionParameter;
14 16
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15 17
 import org.openzen.zenscript.codemodel.ScriptBlock;
16 18
 import org.openzen.zenscript.codemodel.SemanticModule;
17 19
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
18 20
 import org.openzen.zenscript.codemodel.statement.Statement;
21
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
19 22
 import org.openzen.zenscript.javabytecode.compiler.JavaClassWriter;
20 23
 import org.openzen.zenscript.javabytecode.compiler.JavaScriptFile;
21 24
 import org.openzen.zenscript.javabytecode.compiler.JavaStatementVisitor;
@@ -24,6 +27,7 @@ import org.openzen.zenscript.javabytecode.compiler.definitions.JavaDefinitionVis
24 27
 import org.openzen.zenscript.javashared.JavaClass;
25 28
 import org.openzen.zenscript.javashared.JavaCompileSpace;
26 29
 import org.openzen.zenscript.javashared.JavaMethod;
30
+import org.openzen.zenscript.javashared.JavaParameterInfo;
27 31
 import org.openzen.zenscript.javashared.prepare.JavaPrepareDefinitionMemberVisitor;
28 32
 import org.openzen.zenscript.javashared.prepare.JavaPrepareDefinitionVisitor;
29 33
 
@@ -38,7 +42,7 @@ public class JavaCompiler {
38 42
 	public JavaBytecodeModule compile(String packageName, SemanticModule module, JavaCompileSpace space) {
39 43
 		Map<String, JavaScriptFile> scriptBlocks = new HashMap<>();
40 44
 		
41
-		JavaBytecodeModule target = new JavaBytecodeModule(module.module);
45
+		JavaBytecodeModule target = new JavaBytecodeModule(module.module, module.parameters);
42 46
 		JavaBytecodeContext context = new JavaBytecodeContext(target, space, module.modulePackage, packageName);
43 47
 		context.addModule(module.module, target);
44 48
 		
@@ -61,8 +65,18 @@ public class JavaCompiler {
61 65
 			target.addClass(cls.internalName, definition.accept(new JavaDefinitionVisitor(context, scriptFile.classWriter)));
62 66
 		}
63 67
 		
68
+		FunctionHeader scriptHeader = new FunctionHeader(BasicTypeID.VOID, module.parameters);
69
+		String scriptDescriptor = context.getMethodDescriptor(scriptHeader);
70
+		JavaParameterInfo[] javaScriptParameters = new JavaParameterInfo[module.parameters.length];
71
+		for (int i = 0; i < module.parameters.length; i++) {
72
+			FunctionParameter parameter = module.parameters[i];
73
+			JavaParameterInfo javaParameter = new JavaParameterInfo(i, context.getDescriptor(parameter.type));
74
+			target.setParameterInfo(parameter, javaParameter);
75
+			javaScriptParameters[i] = javaParameter;
76
+		}
77
+		
64 78
 		for (ScriptBlock script : module.scripts) {
65
-			final SourceFile sourceFile = script.getTag(SourceFile.class);
79
+			final SourceFile sourceFile = script.file;
66 80
 			final String className = getClassName(sourceFile == null ? null : sourceFile.getFilename());
67 81
 			JavaScriptFile scriptFile = getScriptFile(scriptBlocks, script.pkg.fullName + "/" + className);
68 82
 
@@ -71,8 +85,8 @@ public class JavaCompiler {
71 85
 			// convert scripts into methods (add them to a Scripts class?)
72 86
 			// (TODO: can we break very long scripts into smaller methods? for the extreme scripts)
73 87
 			final JavaClassWriter visitor = scriptFile.classWriter;
74
-			JavaMethod method = JavaMethod.getStatic(new JavaClass(context.getPackageName(script.pkg), className, JavaClass.Kind.CLASS), methodName, "()V", Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
75
-			scriptFile.scriptMethods.add(method);
88
+			JavaMethod method = JavaMethod.getStatic(new JavaClass(context.getPackageName(script.pkg), className, JavaClass.Kind.CLASS), methodName, scriptDescriptor, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC);
89
+			scriptFile.scriptMethods.add(new JavaScriptMethod(method, module.parameters, javaScriptParameters));
76 90
 
77 91
 			final JavaStatementVisitor statementVisitor = new JavaStatementVisitor(context, context.getJavaModule(script.module), new JavaWriter(CodePosition.UNKNOWN, visitor, method, null, null, null));
78 92
 			statementVisitor.start();
@@ -83,7 +97,7 @@ public class JavaCompiler {
83 97
 		}
84 98
 		
85 99
 		for (Map.Entry<String, JavaScriptFile> entry : scriptBlocks.entrySet()) {
86
-			for (JavaMethod method : entry.getValue().scriptMethods)
100
+			for (JavaScriptMethod method : entry.getValue().scriptMethods)
87 101
 				target.addScript(method);
88 102
 
89 103
 			entry.getValue().classWriter.visitEnd();
@@ -94,7 +108,7 @@ public class JavaCompiler {
94 108
 	}
95 109
 	
96 110
 	private String getFilename(HighLevelDefinition definition) {
97
-		SourceFile source = definition.getTag(SourceFile.class);
111
+		SourceFile source = definition.position.file;
98 112
 		if (source != null) {
99 113
 			int slash = Math.max(source.getFilename().lastIndexOf('/'), source.getFilename().lastIndexOf('\\'));
100 114
 			String filename = source.getFilename().substring(slash < 0 ? 0 : slash + 1);

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

@@ -429,7 +429,7 @@ public class JavaNonPushingExpressionVisitor implements ExpressionVisitor<Void>
429 429
 		}
430 430
 
431 431
 		for (Expression argument : expression.arguments.arguments) {
432
-			argument.accept(this);
432
+			argument.accept(original);
433 433
 		}
434 434
 		String internalName = context.getInternalName(expression.objectType);
435 435
 		javaWriter.invokeSpecial(internalName, "<init>", javaWriter.method.cls.isEnum()

+ 2
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaScriptFile.java View File

@@ -7,14 +7,14 @@ package org.openzen.zenscript.javabytecode.compiler;
7 7
 
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10
-import org.openzen.zenscript.javashared.JavaMethod;
10
+import org.openzen.zenscript.javabytecode.JavaScriptMethod;
11 11
 
12 12
 /**
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public class JavaScriptFile {
16 16
 	public final JavaClassWriter classWriter;
17
-	public final List<JavaMethod> scriptMethods;
17
+	public final List<JavaScriptMethod> scriptMethods;
18 18
 
19 19
 	public JavaScriptFile(JavaClassWriter classWriter) {
20 20
 		this.classWriter = classWriter;

+ 2
- 1
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

@@ -95,7 +95,7 @@ public class JavaNativeModule {
95 95
 		}
96 96
 		
97 97
 		this.allowNonAnnonated = allowNonAnnotated;
98
-		compiled = new JavaCompiledModule(module);
98
+		compiled = new JavaCompiledModule(module, FunctionParameter.NONE);
99 99
 		
100 100
 		typeByClass.put(void.class, BasicTypeID.VOID);
101 101
 		typeByClass.put(boolean.class, BasicTypeID.BOOL);
@@ -128,6 +128,7 @@ public class JavaNativeModule {
128 128
 		return new SemanticModule(
129 129
 				module,
130 130
 				SemanticModule.NONE,
131
+				FunctionParameter.NONE,
131 132
 				SemanticModule.State.NORMALIZED,
132 133
 				space.rootPackage,
133 134
 				pkg,

+ 17
- 4
JavaIntegration/src/main/java/org/openzen/zencode/java/ScriptingEngine.java View File

@@ -8,10 +8,12 @@ package org.openzen.zencode.java;
8 8
 import java.io.File;
9 9
 import java.io.IOException;
10 10
 import java.util.ArrayList;
11
+import java.util.Collections;
11 12
 import java.util.List;
12 13
 import java.util.Map;
13 14
 import org.openzen.zencode.shared.CompileException;
14 15
 import org.openzen.zencode.shared.SourceFile;
16
+import org.openzen.zenscript.codemodel.FunctionParameter;
15 17
 import org.openzen.zenscript.codemodel.Module;
16 18
 import org.openzen.zenscript.codemodel.ModuleSpace;
17 19
 import org.openzen.zenscript.codemodel.SemanticModule;
@@ -49,7 +51,7 @@ public class ScriptingEngine {
49 51
 		
50 52
 		try {
51 53
 			ZippedPackage stdlibs = new ZippedPackage(ScriptingEngine.class.getResourceAsStream("/StdLibs.zip"));
52
-			SemanticModule stdlibModule = stdlibs.loadModule(space, "stdlib", null, new SemanticModule[0], stdlib);
54
+			SemanticModule stdlibModule = stdlibs.loadModule(space, "stdlib", null, new SemanticModule[0], FunctionParameter.NONE, stdlib);
53 55
 			stdlibModule = Validator.validate(stdlibModule, error -> System.out.println(error.toString()));
54 56
 			space.addModule("stdlib", stdlibModule);
55 57
 		} catch (IOException ex) {
@@ -81,10 +83,16 @@ public class ScriptingEngine {
81 83
 	}
82 84
 	
83 85
 	public SemanticModule createScriptedModule(String name, SourceFile[] sources, String... dependencies) throws ParseException {
84
-		return createScriptedModule(name, sources, null, dependencies);
86
+		return createScriptedModule(name, sources, null, FunctionParameter.NONE, dependencies);
85 87
 	}
86 88
 	
87
-	public SemanticModule createScriptedModule(String name, SourceFile[] sources, BracketExpressionParser bracketParser, String... dependencies) throws ParseException {
89
+	public SemanticModule createScriptedModule(
90
+			String name,
91
+			SourceFile[] sources,
92
+			BracketExpressionParser bracketParser,
93
+			FunctionParameter[] scriptParameters,
94
+			String... dependencies) throws ParseException
95
+	{
88 96
 		Module scriptModule = new Module(name);
89 97
 		CompilingPackage scriptPackage = new CompilingPackage(new ZSPackage(space.rootPackage, name), scriptModule);
90 98
 		
@@ -103,6 +111,7 @@ public class ScriptingEngine {
103 111
 				scriptPackage,
104 112
 				files,
105 113
 				space,
114
+				scriptParameters,
106 115
 				ex -> ex.printStackTrace());
107 116
 		if (!scripts.isValid())
108 117
 			return scripts;
@@ -117,6 +126,10 @@ public class ScriptingEngine {
117 126
 	}
118 127
 	
119 128
 	public void run() {
129
+		run(Collections.emptyMap());
130
+	}
131
+	
132
+	public void run(Map<FunctionParameter, Object> arguments) {
120 133
 		SimpleJavaCompileSpace javaSpace = new SimpleJavaCompileSpace(registry);
121 134
 		for (JavaNativeModule nativeModule : nativeModules)
122 135
 			javaSpace.register(nativeModule.getCompiled());
@@ -128,6 +141,6 @@ public class ScriptingEngine {
128 141
 			runUnit.add(compiler.compile(compiled.name, compiled, javaSpace));
129 142
 		if (debug)
130 143
 			runUnit.dump(new File("classes"));
131
-		runUnit.run();
144
+		runUnit.run(arguments);
132 145
 	}
133 146
 }

+ 3
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaCompiledModule.java View File

@@ -24,6 +24,7 @@ import org.openzen.zenscript.codemodel.type.member.BuiltinID;
24 24
  */
25 25
 public class JavaCompiledModule {
26 26
 	public final Module module;
27
+	public final FunctionParameter[] scriptParameters;
27 28
 	
28 29
 	private final Map<HighLevelDefinition, JavaClass> classes = new HashMap<>();
29 30
 	private final Map<HighLevelDefinition, JavaClass> expansionClasses = new HashMap<>();
@@ -34,8 +35,9 @@ public class JavaCompiledModule {
34 35
 	private final Map<FunctionParameter, JavaParameterInfo> parameters = new HashMap<>();
35 36
 	private final Map<VariantDefinition.Option, JavaVariantOption> variantOptions = new HashMap<>();
36 37
 	
37
-	public JavaCompiledModule(Module module) {
38
+	public JavaCompiledModule(Module module, FunctionParameter[] scriptParameters) {
38 39
 		this.module = module;
40
+		this.scriptParameters = scriptParameters;
39 41
 	}
40 42
 	
41 43
 	public void loadMappings(String mappings) {

+ 4
- 0
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaMemberCompiler.java View File

@@ -35,6 +35,7 @@ import org.openzen.zenscript.codemodel.statement.BlockStatement;
35 35
 import org.openzen.zenscript.codemodel.statement.EmptyStatement;
36 36
 import org.openzen.zenscript.codemodel.statement.Statement;
37 37
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
38
+import org.openzen.zenscript.codemodel.type.member.BuiltinID;
38 39
 import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
39 40
 import org.openzen.zenscript.javasource.scope.JavaSourceFileScope;
40 41
 import org.openzen.zenscript.javashared.JavaClass;
@@ -155,6 +156,9 @@ public class JavaMemberCompiler extends BaseMemberCompiler {
155 156
 
156 157
 	@Override
157 158
 	public Void visitConstructor(ConstructorMember member) {
159
+		if (member.body == null)
160
+			return null; // happens with default constructors
161
+		
158 162
 		begin(ElementType.CONSTRUCTOR);
159 163
 		
160 164
 		output.append(indent);

+ 4
- 3
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceCompiler.java View File

@@ -8,6 +8,7 @@ package org.openzen.zenscript.javasource;
8 8
 import java.util.HashMap;
9 9
 import java.util.Map;
10 10
 import org.openzen.zencode.shared.SourceFile;
11
+import org.openzen.zenscript.codemodel.FunctionParameter;
11 12
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 13
 import org.openzen.zenscript.codemodel.Module;
13 14
 import org.openzen.zenscript.codemodel.ScriptBlock;
@@ -26,14 +27,14 @@ public class JavaSourceCompiler {
26 27
 	public final JavaSourceModule helpers;
27 28
 	
28 29
 	public JavaSourceCompiler(GlobalTypeRegistry registry) {
29
-		helpers = new JavaSourceModule(new Module("helpers"));
30
+		helpers = new JavaSourceModule(new Module("helpers"), FunctionParameter.NONE);
30 31
 		settings = new JavaSourceFormattingSettings.Builder().build();
31 32
 	}
32 33
 	
33 34
 	public JavaSourceModule compile(SemanticModule module, JavaCompileSpace space, String basePackage) {
34 35
 		JavaSourceContext context = new JavaSourceContext(helpers, settings, space, module.modulePackage, basePackage);
35 36
 		
36
-		JavaSourceModule result = new JavaSourceModule(module.module);
37
+		JavaSourceModule result = new JavaSourceModule(module.module, module.parameters);
37 38
 		context.addModule(module.module, result);
38 39
 		
39 40
 		Map<String, JavaSourceFile> sourceFiles = new HashMap<>();
@@ -72,7 +73,7 @@ public class JavaSourceCompiler {
72 73
 	}
73 74
 	
74 75
 	private String getFilename(HighLevelDefinition definition) {
75
-		SourceFile source = definition.getTag(SourceFile.class);
76
+		SourceFile source = definition.position.file;
76 77
 		if (source != null) {
77 78
 			int slash = Math.max(source.getFilename().lastIndexOf('/'), source.getFilename().lastIndexOf('\\'));
78 79
 			String filename = source.getFilename().substring(slash < 0 ? 0 : slash + 1);

+ 3
- 2
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceModule.java View File

@@ -7,6 +7,7 @@ package org.openzen.zenscript.javasource;
7 7
 
8 8
 import java.util.ArrayList;
9 9
 import java.util.List;
10
+import org.openzen.zenscript.codemodel.FunctionParameter;
10 11
 import org.openzen.zenscript.codemodel.Module;
11 12
 import org.openzen.zenscript.javashared.JavaCompiledModule;
12 13
 
@@ -17,8 +18,8 @@ import org.openzen.zenscript.javashared.JavaCompiledModule;
17 18
 public class JavaSourceModule extends JavaCompiledModule {
18 19
 	public final List<SourceFile> sourceFiles = new ArrayList<>();
19 20
 	
20
-	public JavaSourceModule(Module module) {
21
-		super(module);
21
+	public JavaSourceModule(Module module, FunctionParameter[] parameters) {
22
+		super(module, parameters);
22 23
 	}
23 24
 	
24 25
 	public void addFile(String filename, String content) {

+ 11
- 6
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java View File

@@ -17,6 +17,8 @@ import org.openzen.zencode.shared.CompileException;
17 17
 import org.openzen.zencode.shared.FileSourceFile;
18 18
 import org.openzen.zencode.shared.LiteralSourceFile;
19 19
 import org.openzen.zencode.shared.SourceFile;
20
+import org.openzen.zenscript.codemodel.FunctionHeader;
21
+import org.openzen.zenscript.codemodel.FunctionParameter;
20 22
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
21 23
 import org.openzen.zenscript.codemodel.Modifiers;
22 24
 import org.openzen.zenscript.codemodel.ModuleSpace;
@@ -36,6 +38,7 @@ import org.openzen.zenscript.codemodel.scope.FileScope;
36 38
 import org.openzen.zenscript.codemodel.scope.GlobalScriptScope;
37 39
 import org.openzen.zenscript.codemodel.type.ISymbol;
38 40
 import org.openzen.zenscript.codemodel.scope.StatementScope;
41
+import org.openzen.zenscript.codemodel.type.BasicTypeID;
39 42
 import org.openzen.zenscript.lexer.ParseException;
40 43
 import org.openzen.zenscript.parser.statements.ParsedStatement;
41 44
 
@@ -49,6 +52,7 @@ public class ParsedFile {
49 52
 			CompilingPackage pkg,
50 53
 			ParsedFile[] files,
51 54
 			ModuleSpace registry,
55
+			FunctionParameter[] parameters,
52 56
 			Consumer<CompileException> exceptionLogger) {
53 57
 		// We are considering all these files to be in the same package, so make
54 58
 		// a single PackageDefinition instance. If these files were in multiple
@@ -88,7 +92,7 @@ public class ParsedFile {
88 92
 		}
89 93
 		
90 94
 		if (failed)
91
-			return new SemanticModule(pkg.module, dependencies, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.registry, expansions, registry.getAnnotations(), registry.getStorageTypes());
95
+			return new SemanticModule(pkg.module, dependencies, parameters, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.registry, expansions, registry.getAnnotations(), registry.getStorageTypes());
92 96
 		
93 97
 		// scripts will store all the script blocks encountered in the files
94 98
 		PrecompilationState precompiler = new PrecompilationState();
@@ -97,16 +101,18 @@ public class ParsedFile {
97 101
 		}
98 102
 		
99 103
 		List<ScriptBlock> scripts = new ArrayList<>();
104
+		FunctionHeader scriptHeader = new FunctionHeader(BasicTypeID.VOID, parameters);
100 105
 		for (ParsedFile file : files) {
101 106
 			// compileCode will convert the parsed statements and expressions
102 107
 			// into semantic code. This semantic code can then be compiled
103 108
 			// to various targets.
104
-			file.compileCode(moduleContext, precompiler, rootPackage, pkg, expansions, scripts, globals, exceptionLogger);
109
+			file.compileCode(moduleContext, precompiler, rootPackage, pkg, expansions, scripts, globals, scriptHeader, exceptionLogger);
105 110
 		}
106 111
 		
107 112
 		return new SemanticModule(
108 113
 				pkg.module,
109 114
 				dependencies,
115
+				parameters,
110 116
 				SemanticModule.State.ASSEMBLED,
111 117
 				rootPackage,
112 118
 				pkg.getPackage(),
@@ -187,7 +193,6 @@ public class ParsedFile {
187 193
 					result.statements.add(ParsedStatement.parse(tokens, annotations));
188 194
 				} else {
189 195
 					result.definitions.add(definition);
190
-					definition.getCompiled().setTag(SourceFile.class, tokens.getFile());
191 196
 				}
192 197
 			}
193 198
 		}
@@ -277,6 +282,7 @@ public class ParsedFile {
277 282
 			List<ExpansionDefinition> expansions,
278 283
 			List<ScriptBlock> scripts,
279 284
 			Map<String, ISymbol> globals,
285
+			FunctionHeader scriptHeader,
280 286
 			Consumer<CompileException> exceptionLogger) {
281 287
 		FileResolutionContext context = new FileResolutionContext(moduleContext, rootPackage, modulePackage);
282 288
 		loadImports(context, rootPackage, modulePackage);
@@ -291,14 +297,13 @@ public class ParsedFile {
291 297
 		}
292 298
 		
293 299
 		if (!statements.isEmpty() || postComment != null) {
294
-			StatementScope statementScope = new GlobalScriptScope(scope);
300
+			StatementScope statementScope = new GlobalScriptScope(scope, scriptHeader);
295 301
 			List<Statement> statements = new ArrayList<>();
296 302
 			for (ParsedStatement statement : this.statements) {
297 303
 				statements.add(statement.compile(statementScope));
298 304
 			}
299 305
 			
300
-			ScriptBlock block = new ScriptBlock(modulePackage.module, modulePackage.getPackage(), statements);
301
-			block.setTag(SourceFile.class, file);
306
+			ScriptBlock block = new ScriptBlock(file, modulePackage.module, modulePackage.getPackage(), scriptHeader, statements);
302 307
 			block.setTag(WhitespacePostComment.class, postComment);
303 308
 			scripts.add(block);
304 309
 		}

+ 5
- 3
Parser/src/main/java/org/openzen/zenscript/parser/ZippedPackage.java View File

@@ -17,6 +17,7 @@ import java.util.zip.ZipEntry;
17 17
 import java.util.zip.ZipInputStream;
18 18
 import org.openzen.zencode.shared.LiteralSourceFile;
19 19
 import org.openzen.zencode.shared.SourceFile;
20
+import org.openzen.zenscript.codemodel.FunctionParameter;
20 21
 import org.openzen.zenscript.codemodel.Module;
21 22
 import org.openzen.zenscript.codemodel.ModuleSpace;
22 23
 import org.openzen.zenscript.codemodel.SemanticModule;
@@ -56,11 +57,11 @@ public class ZippedPackage {
56 57
 		}
57 58
 	}
58 59
 	
59
-	public SemanticModule loadModule(ModuleSpace space, String name, BracketExpressionParser bracketParser, SemanticModule[] dependencies) throws ParseException {
60
-		return loadModule(space, name, bracketParser, dependencies, new ZSPackage(space.rootPackage, name));
60
+	public SemanticModule loadModule(ModuleSpace space, String name, BracketExpressionParser bracketParser, SemanticModule[] dependencies, FunctionParameter[] scriptParameters) throws ParseException {
61
+		return loadModule(space, name, bracketParser, dependencies, scriptParameters, new ZSPackage(space.rootPackage, name));
61 62
 	}
62 63
 	
63
-	public SemanticModule loadModule(ModuleSpace space, String name, BracketExpressionParser bracketParser, SemanticModule[] dependencies, ZSPackage pkg) throws ParseException {
64
+	public SemanticModule loadModule(ModuleSpace space, String name, BracketExpressionParser bracketParser, SemanticModule[] dependencies, FunctionParameter[] scriptParameters, ZSPackage pkg) throws ParseException {
64 65
 		List<SourceFile> sourceFiles = files.get(name);
65 66
 		if (sourceFiles == null)
66 67
 			return null; // no such module
@@ -76,6 +77,7 @@ public class ZippedPackage {
76 77
 				scriptPackage,
77 78
 				files,
78 79
 				space,
80
+				scriptParameters,
79 81
 				ex -> ex.printStackTrace());
80 82
 		return scripts.normalize();
81 83
 	}

+ 3
- 0
ScriptingExample/scripts/scriptparameters.zs View File

@@ -0,0 +1,3 @@
1
+println("Arguments:");
2
+for i, arg in args
3
+	println("- " + i + ": " + arg);

+ 11
- 2
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java View File

@@ -2,6 +2,9 @@ package org.openzen.zenscript.scriptingexample;
2 2
 
3 3
 import java.io.File;
4 4
 import java.io.IOException;
5
+import java.util.Collections;
6
+import java.util.HashMap;
7
+import java.util.Map;
5 8
 import java.util.Optional;
6 9
 import org.openzen.zencode.java.JavaNativeModule;
7 10
 import org.openzen.zencode.java.ScriptingEngine;
@@ -9,7 +12,9 @@ import org.openzen.zencode.shared.CodePosition;
9 12
 import org.openzen.zencode.shared.CompileException;
10 13
 import org.openzen.zencode.shared.FileSourceFile;
11 14
 import org.openzen.zencode.shared.SourceFile;
15
+import org.openzen.zenscript.codemodel.FunctionParameter;
12 16
 import org.openzen.zenscript.codemodel.SemanticModule;
17
+import org.openzen.zenscript.codemodel.type.StringTypeID;
13 18
 import org.openzen.zenscript.lexer.ParseException;
14 19
 import org.openzen.zenscript.lexer.ZSToken;
15 20
 import org.openzen.zenscript.lexer.ZSTokenParser;
@@ -34,12 +39,16 @@ public class Main {
34 39
 		for (int i = 0; i < inputFiles.length; i++)
35 40
 			sourceFiles[i] = new FileSourceFile(inputFiles[i].getName(), inputFiles[i]);
36 41
 		
37
-		SemanticModule scripts = scriptingEngine.createScriptedModule("script", sourceFiles, new TestBracketParser());
42
+		FunctionParameter parameter = new FunctionParameter(scriptingEngine.registry.getArray(StringTypeID.AUTO, 1).stored(), "args");
43
+		SemanticModule scripts = scriptingEngine.createScriptedModule("script", sourceFiles, new TestBracketParser(), new FunctionParameter[] { parameter });
38 44
 		if (!scripts.isValid())
39 45
 			return;
40 46
 		
41 47
 		scriptingEngine.registerCompiled(scripts);
42
-		scriptingEngine.run();
48
+		
49
+		Map<FunctionParameter, Object> scriptArgs = new HashMap<>();
50
+		scriptArgs.put(parameter, new String[] { "hello", "world", "example" });
51
+		scriptingEngine.run(scriptArgs);
43 52
 	}
44 53
 	
45 54
 	private static class TestBracketParser implements BracketExpressionParser {

+ 1
- 1
Shared/src/main/java/org/openzen/zencode/shared/SourceFile.java View File

@@ -3,7 +3,7 @@ package org.openzen.zencode.shared;
3 3
 import java.io.IOException;
4 4
 import java.io.Reader;
5 5
 
6
-public interface SourceFile extends Tag {
6
+public interface SourceFile {
7 7
     String getFilename();
8 8
     
9 9
     Reader open() throws IOException;

+ 1
- 0
Validator/src/main/java/org/openzen/zenscript/validator/Validator.java View File

@@ -48,6 +48,7 @@ public class Validator {
48 48
 		return new SemanticModule(
49 49
 				module.module,
50 50
 				module.dependencies,
51
+				module.parameters,
51 52
 				state,
52 53
 				module.rootPackage,
53 54
 				module.modulePackage,

Loading…
Cancel
Save