Browse Source

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

kindlich 6 years ago
parent
commit
dcfa18961e
No known key found for this signature in database
64 changed files with 1800 additions and 204 deletions
  1. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java
  2. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java
  3. 12
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  4. 22
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/Module.java
  5. 5
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java
  6. 3
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java
  7. 5
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java
  8. 11
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/EnumDefinition.java
  9. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java
  10. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java
  11. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java
  12. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/MemberCollector.java
  13. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/StructDefinition.java
  14. 11
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java
  15. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java
  16. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java
  17. 6
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java
  18. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameterBound.java
  19. 23
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/BuiltinID.java
  20. 9
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java
  21. 80
    48
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  22. 5
    0
      CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java
  23. 2
    2
      Constructor/src/main/java/org/openzen/zenscript/constructor/ParsedModule.java
  24. 8
    6
      Constructor/src/main/java/org/openzen/zenscript/constructor/module/DirectoryModuleReference.java
  25. 6
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  26. 1
    1
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenModel.java
  27. 29
    5
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  28. 2
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaTypeGenericVisitor.java
  29. 8
    0
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaNativeTranslator.java
  30. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeDescriptorVisitor.java
  31. 2
    2
      JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInternalNameVisitor.java
  32. 18
    1
      JavaShared/src/main/java/org/openzen/zenscript/javashared/prepare/JavaPrepareDefinitionVisitor.java
  33. 2
    2
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/FormattingUtils.java
  34. 126
    32
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java
  35. 4
    1
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceImporter.java
  36. 4
    4
      JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceUtils.java
  37. 3
    2
      Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java
  38. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java
  39. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java
  40. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java
  41. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java
  42. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java
  43. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java
  44. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedGenericBound.java
  45. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java
  46. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedStruct.java
  47. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedSuperBound.java
  48. 2
    2
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedTypeBound.java
  49. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedVariant.java
  50. 4
    3
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java
  51. 53
    14
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFloat.java
  52. 119
    10
      Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionInt.java
  53. 1
    1
      ScriptingExample/build.gradle
  54. 5
    3
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java
  55. 6
    4
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java
  56. 407
    0
      Shared/src/main/java/compactio/CompactBytesDataInput.java
  57. 497
    0
      Shared/src/main/java/compactio/CompactBytesDataOutput.java
  58. 106
    0
      Shared/src/main/java/compactio/CompactDataInput.java
  59. 108
    0
      Shared/src/main/java/compactio/CompactDataOutput.java
  60. 2
    1
      Shared/src/main/java/org/openzen/zencode/shared/CompileExceptionCode.java
  61. 6
    0
      Shared/src/main/java/zsynthetic/FunctionUSizeTToBool.java
  62. 6
    0
      Shared/src/main/java/zsynthetic/FunctionUSizeTToU.java
  63. 6
    0
      Shared/src/main/java/zsynthetic/FunctionUSizeTToVoid.java
  64. 2
    2
      Validator/src/main/java/org/openzen/zenscript/validator/visitors/ValidationUtils.java

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/FormattingUtils.java View File

@@ -10,7 +10,7 @@ import org.openzen.zenscript.codemodel.FunctionParameter;
10 10
 import org.openzen.zenscript.codemodel.Modifiers;
11 11
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12 12
 import org.openzen.zenscript.codemodel.expression.Expression;
13
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
13
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
14 14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
15 15
 import org.openzen.zenscript.codemodel.statement.BlockStatement;
16 16
 import org.openzen.zenscript.codemodel.statement.BreakStatement;
@@ -103,7 +103,7 @@ public class FormattingUtils {
103 103
 				result.append(parameter.name);
104 104
 				
105 105
 				if (parameter.bounds.size() > 0) {
106
-					for (GenericParameterBound bound : parameter.bounds) {
106
+					for (TypeParameterBound bound : parameter.bounds) {
107 107
 						result.append(": ");
108 108
 						result.append(bound.accept(typeFormatter));
109 109
 					}

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

@@ -462,4 +462,8 @@ public class FunctionHeader {
462 462
 		
463 463
 		return false;
464 464
 	}
465
+
466
+	public boolean accepts(int arguments) {
467
+		return arguments >= this.minParameters && arguments <= this.maxParameters;
468
+	}
465 469
 }

+ 12
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java View File

@@ -14,6 +14,7 @@ import org.openzen.zenscript.codemodel.definition.AliasDefinition;
14 14
 import org.openzen.zenscript.codemodel.definition.DefinitionVisitor;
15 15
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
16 16
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
17
+import org.openzen.zenscript.codemodel.definition.MemberCollector;
17 18
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
18 19
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
19 20
 import org.openzen.zenscript.codemodel.member.ConstructorMember;
@@ -31,6 +32,7 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
31 32
  */
32 33
 public abstract class HighLevelDefinition extends Taggable {
33 34
 	public final CodePosition position;
35
+	public final Module module;
34 36
 	public final ZSPackage pkg;
35 37
 	public final String name;
36 38
 	public final int modifiers;
@@ -43,8 +45,12 @@ public abstract class HighLevelDefinition extends Taggable {
43 45
 	
44 46
 	private boolean isDestructible = false;
45 47
 	
46
-	public HighLevelDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
48
+	public HighLevelDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
49
+		if (module == null)
50
+			throw new NullPointerException();
51
+		
47 52
 		this.position = position;
53
+		this.module = module;
48 54
 		this.pkg = pkg;
49 55
 		this.name = name;
50 56
 		this.modifiers = modifiers;
@@ -100,6 +106,11 @@ public abstract class HighLevelDefinition extends Taggable {
100 106
 			members.add(member);
101 107
 	}
102 108
 	
109
+	public void collectMembers(MemberCollector collector) {
110
+		for (IDefinitionMember member : members)
111
+			collector.member(member);
112
+	}
113
+	
103 114
 	public boolean isDestructible() {
104 115
 		boolean isDestructible = false;
105 116
 		for (IDefinitionMember member : members) {

+ 22
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/Module.java View File

@@ -0,0 +1,22 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel;
7
+
8
+import org.openzen.zencode.shared.Taggable;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public class Module extends Taggable {
15
+	public static final Module BUILTIN = new Module("builtin");
16
+	
17
+	public final String name;
18
+	
19
+	public Module(String name) {
20
+		this.name = name;
21
+	}
22
+}

+ 5
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/context/CompilingPackage.java View File

@@ -9,6 +9,7 @@ import java.util.HashMap;
9 9
 import java.util.List;
10 10
 import java.util.Map;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.Module;
12 13
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
13 14
 import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
14 15
 import org.openzen.zenscript.codemodel.type.GenericName;
@@ -19,12 +20,14 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
19 20
  * @author Hoofdgebruiker
20 21
  */
21 22
 public class CompilingPackage {
23
+	public final Module module;
22 24
 	private final ZSPackage pkg;
23 25
 	private final Map<String, CompilingPackage> packages = new HashMap<>();
24 26
 	private final Map<String, CompilingType> types = new HashMap<>();
25 27
 	
26
-	public CompilingPackage(ZSPackage pkg) {
28
+	public CompilingPackage(ZSPackage pkg, Module module) {
27 29
 		this.pkg = pkg;
30
+		this.module = module;
28 31
 	}
29 32
 	
30 33
 	public ZSPackage getPackage() {
@@ -35,7 +38,7 @@ public class CompilingPackage {
35 38
 		if (packages.containsKey(name))
36 39
 			return packages.get(name);
37 40
 		
38
-		CompilingPackage newPackage = new CompilingPackage(pkg.getOrCreatePackage(name));
41
+		CompilingPackage newPackage = new CompilingPackage(pkg.getOrCreatePackage(name), module);
39 42
 		packages.put(name, newPackage);
40 43
 		return newPackage;
41 44
 	}

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java View File

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
-import org.openzen.zenscript.codemodel.Modifiers;
10
+import org.openzen.zenscript.codemodel.Module;
11 11
 import org.openzen.zenscript.codemodel.scope.TypeScope;
12 12
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 13
 
@@ -18,8 +18,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
18 18
 public class AliasDefinition extends HighLevelDefinition {
19 19
 	public ITypeID type;
20 20
 	
21
-	public AliasDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
-		super(position, pkg, name, modifiers, outerDefinition);
21
+	public AliasDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
+		super(position, module, pkg, name, modifiers, outerDefinition);
23 23
 	}
24 24
 	
25 25
 	public void setType(ITypeID type) {

+ 5
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java View File

@@ -7,20 +7,19 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
-import org.openzen.zenscript.codemodel.scope.TypeScope;
11
-import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.Module;
12 11
 
13 12
 /**
14 13
  *
15 14
  * @author Hoofdgebruiker
16 15
  */
17 16
 public class ClassDefinition extends HighLevelDefinition {
18
-	public ClassDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers) {
19
-		this(position, pkg, name, modifiers, null);
17
+	public ClassDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers) {
18
+		this(position, module, pkg, name, modifiers, null);
20 19
 	}
21 20
 	
22
-	public ClassDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
23
-		super(position, pkg, name, modifiers, outerDefinition);
21
+	public ClassDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
+		super(position, module, pkg, name, modifiers, outerDefinition);
24 23
 	}
25 24
 
26 25
 	@Override

+ 11
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/EnumDefinition.java View File

@@ -9,6 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.Module;
12 13
 import org.openzen.zenscript.codemodel.member.EnumConstantMember;
13 14
 
14 15
 /**
@@ -18,8 +19,8 @@ import org.openzen.zenscript.codemodel.member.EnumConstantMember;
18 19
 public class EnumDefinition extends HighLevelDefinition {
19 20
 	public List<EnumConstantMember> enumConstants = new ArrayList<>();
20 21
 	
21
-	public EnumDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
-		super(position, pkg, name, modifiers, outerDefinition);
22
+	public EnumDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
23
+		super(position, module, pkg, name, modifiers, outerDefinition);
23 24
 	}
24 25
 
25 26
 	@Override
@@ -27,6 +28,14 @@ public class EnumDefinition extends HighLevelDefinition {
27 28
 		return visitor.visitEnum(this);
28 29
 	}
29 30
 	
31
+	@Override
32
+	public void collectMembers(MemberCollector collector) {
33
+		super.collectMembers(collector);
34
+		
35
+		for (EnumConstantMember member : enumConstants)
36
+			collector.enumConstant(member);
37
+	}
38
+	
30 39
 	public void addEnumConstant(EnumConstantMember constant) {
31 40
 		enumConstants.add(constant);
32 41
 	}

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java View File

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
+import org.openzen.zenscript.codemodel.Module;
10 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 12
 
12 13
 /**
@@ -16,8 +17,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
16 17
 public class ExpansionDefinition extends HighLevelDefinition {
17 18
 	public ITypeID target;
18 19
 	
19
-	public ExpansionDefinition(CodePosition position, ZSPackage pkg, int modifiers, HighLevelDefinition outerDefinition) {
20
-		super(position, pkg, null, modifiers, outerDefinition);
20
+	public ExpansionDefinition(CodePosition position, Module module, ZSPackage pkg, int modifiers, HighLevelDefinition outerDefinition) {
21
+		super(position, module, pkg, null, modifiers, outerDefinition);
21 22
 	}
22 23
 
23 24
 	@Override

+ 5
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java View File

@@ -10,6 +10,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.GenericMapper;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12 12
 import org.openzen.zenscript.codemodel.Modifiers;
13
+import org.openzen.zenscript.codemodel.Module;
13 14
 import org.openzen.zenscript.codemodel.member.CallerMember;
14 15
 import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
15 16
 import org.openzen.zenscript.codemodel.statement.Statement;
@@ -26,13 +27,13 @@ public class FunctionDefinition extends HighLevelDefinition {
26 27
 	public CallerMember caller;
27 28
 	public final DefinitionMemberGroup callerGroup;
28 29
 	
29
-	public FunctionDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
30
-		super(position, pkg, name, modifiers, outerDefinition);
30
+	public FunctionDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
31
+		super(position, module, pkg, name, modifiers, outerDefinition);
31 32
 		callerGroup = new DefinitionMemberGroup(true, name);
32 33
 	}
33 34
 	
34
-	public FunctionDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, FunctionHeader header) {
35
-		this(position, pkg, name, modifiers, (HighLevelDefinition) null);
35
+	public FunctionDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, FunctionHeader header) {
36
+		this(position, module, pkg, name, modifiers, (HighLevelDefinition) null);
36 37
 		setHeader(header);
37 38
 	}
38 39
 	

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java View File

@@ -9,6 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
12
+import org.openzen.zenscript.codemodel.Module;
12 13
 import org.openzen.zenscript.codemodel.type.ITypeID;
13 14
 
14 15
 /**
@@ -18,8 +19,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
18 19
 public class InterfaceDefinition extends HighLevelDefinition {
19 20
 	public final List<ITypeID> baseInterfaces = new ArrayList<>();
20 21
 	
21
-	public InterfaceDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
-		super(position, pkg, name, modifiers, outerDefinition);
22
+	public InterfaceDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
23
+		super(position, module, pkg, name, modifiers, outerDefinition);
23 24
 	}
24 25
 	
25 26
 	public void addBaseInterface(ITypeID baseInterface) {

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/MemberCollector.java View File

@@ -0,0 +1,21 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.definition;
7
+
8
+import org.openzen.zenscript.codemodel.member.EnumConstantMember;
9
+import org.openzen.zenscript.codemodel.member.IDefinitionMember;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public interface MemberCollector {
16
+	void member(IDefinitionMember member);
17
+	
18
+	void enumConstant(EnumConstantMember member);
19
+	
20
+	void variantOption(VariantDefinition.Option member);
21
+}

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/StructDefinition.java View File

@@ -7,14 +7,15 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
10
+import org.openzen.zenscript.codemodel.Module;
10 11
 
11 12
 /**
12 13
  *
13 14
  * @author Hoofdgebruiker
14 15
  */
15 16
 public class StructDefinition extends HighLevelDefinition {
16
-	public StructDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
17
-		super(position, pkg, name, modifiers, outerDefinition);
17
+	public StructDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
18
+		super(position, module, pkg, name, modifiers, outerDefinition);
18 19
 	}
19 20
 
20 21
 	@Override

+ 11
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/VariantDefinition.java View File

@@ -11,6 +11,7 @@ import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zencode.shared.Taggable;
12 12
 import org.openzen.zenscript.codemodel.GenericMapper;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
+import org.openzen.zenscript.codemodel.Module;
14 15
 import org.openzen.zenscript.codemodel.member.ref.VariantOptionRef;
15 16
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 17
 
@@ -21,8 +22,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
21 22
 public class VariantDefinition extends HighLevelDefinition {
22 23
 	public final List<Option> options = new ArrayList<>();
23 24
 	
24
-	public VariantDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
25
-		super(position, pkg, name, modifiers, outerDefinition);
25
+	public VariantDefinition(CodePosition position, Module module, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
26
+		super(position, module, pkg, name, modifiers, outerDefinition);
26 27
 	}
27 28
 
28 29
 	@Override
@@ -30,6 +31,14 @@ public class VariantDefinition extends HighLevelDefinition {
30 31
 		return visitor.visitVariant(this);
31 32
 	}
32 33
 	
34
+	@Override
35
+	public void collectMembers(MemberCollector collector) {
36
+		super.collectMembers(collector);
37
+		
38
+		for (Option option : options)
39
+			collector.variantOption(option);
40
+	}
41
+	
33 42
 	public static class Option extends Taggable {
34 43
 		public final String name;
35 44
 		public final int ordinal;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterSuperBound.java View File

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14 14
  *
15 15
  * @author Hoofdgebruiker
16 16
  */
17
-public class ParameterSuperBound extends GenericParameterBound {
17
+public class ParameterSuperBound extends TypeParameterBound {
18 18
 	public final ITypeID type;
19 19
 	
20 20
 	public ParameterSuperBound(ITypeID type) {
@@ -37,7 +37,7 @@ public class ParameterSuperBound extends GenericParameterBound {
37 37
 	}
38 38
 
39 39
 	@Override
40
-	public GenericParameterBound instance(GenericMapper mapper) {
40
+	public TypeParameterBound instance(GenericMapper mapper) {
41 41
 		ITypeID translated = type.instance(mapper);
42 42
 		if (translated == type)
43 43
 			return this;

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/ParameterTypeBound.java View File

@@ -16,7 +16,7 @@ import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
16 16
  *
17 17
  * @author Hoofdgebruiker
18 18
  */
19
-public class ParameterTypeBound extends GenericParameterBound {
19
+public class ParameterTypeBound extends TypeParameterBound {
20 20
 	public final CodePosition position;
21 21
 	public final ITypeID type;
22 22
 	
@@ -41,7 +41,7 @@ public class ParameterTypeBound extends GenericParameterBound {
41 41
 	}
42 42
 
43 43
 	@Override
44
-	public GenericParameterBound instance(GenericMapper mapper) {
44
+	public TypeParameterBound instance(GenericMapper mapper) {
45 45
 		return new ParameterTypeBound(position, type.instance(mapper));
46 46
 	}
47 47
 

+ 6
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameter.java View File

@@ -22,25 +22,25 @@ public class TypeParameter {
22 22
 	
23 23
 	public final CodePosition position;
24 24
 	public final String name;
25
-	public final List<GenericParameterBound> bounds = new ArrayList<>();
25
+	public final List<TypeParameterBound> bounds = new ArrayList<>();
26 26
 	
27 27
 	public TypeParameter(CodePosition position, String name) {
28 28
 		this.position = position;
29 29
 		this.name = name;
30 30
 	}
31 31
 	
32
-	private TypeParameter(CodePosition position, String name, List<GenericParameterBound> bounds) {
32
+	private TypeParameter(CodePosition position, String name, List<TypeParameterBound> bounds) {
33 33
 		this.position = position;
34 34
 		this.name = name;
35 35
 		bounds.addAll(bounds);
36 36
 	}
37 37
 	
38
-	public void addBound(GenericParameterBound bound) {
38
+	public void addBound(TypeParameterBound bound) {
39 39
 		bounds.add(bound);
40 40
 	}
41 41
 	
42 42
 	public boolean isObjectType() {
43
-		for (GenericParameterBound bound : bounds)
43
+		for (TypeParameterBound bound : bounds)
44 44
 			if (bound.isObjectType())
45 45
 				return true;
46 46
 		
@@ -48,7 +48,7 @@ public class TypeParameter {
48 48
 	}
49 49
 	
50 50
 	public boolean matches(LocalMemberCache cache, ITypeID type) {
51
-		for (GenericParameterBound bound : bounds) {
51
+		for (TypeParameterBound bound : bounds) {
52 52
 			if (!bound.matches(cache, type))
53 53
 				return false;
54 54
 		}
@@ -68,7 +68,7 @@ public class TypeParameter {
68 68
 	public String getCanonical() {
69 69
 		StringBuilder result = new StringBuilder();
70 70
 		result.append(name);
71
-		for(GenericParameterBound bound : bounds) {
71
+		for(TypeParameterBound bound : bounds) {
72 72
 			result.append(':');
73 73
 			result.append(bound.getCanonical());
74 74
 		}

CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/GenericParameterBound.java → CodeModel/src/main/java/org/openzen/zenscript/codemodel/generic/TypeParameterBound.java View File

@@ -14,7 +14,7 @@ import org.openzen.zenscript.codemodel.type.member.LocalMemberCache;
14 14
  *
15 15
  * @author Hoofdgebruiker
16 16
  */
17
-public abstract class GenericParameterBound {
17
+public abstract class TypeParameterBound {
18 18
 	public abstract boolean isObjectType();
19 19
 	
20 20
 	public abstract <T> T accept(GenericParameterBoundVisitor<T> visitor);
@@ -23,7 +23,7 @@ public abstract class GenericParameterBound {
23 23
 	
24 24
 	public abstract boolean matches(LocalMemberCache cache, ITypeID type);
25 25
 	
26
-	public abstract GenericParameterBound instance(GenericMapper mapper);
26
+	public abstract TypeParameterBound instance(GenericMapper mapper);
27 27
 	
28 28
 	public abstract String getCanonical();
29 29
 }

+ 23
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/BuiltinID.java View File

@@ -30,6 +30,8 @@ public enum BuiltinID {
30 30
 	BYTE_AND_BYTE,
31 31
 	BYTE_OR_BYTE,
32 32
 	BYTE_XOR_BYTE,
33
+	BYTE_SHL,
34
+	BYTE_SHR,
33 35
 	BYTE_COMPARE,
34 36
 	BYTE_TO_SBYTE,
35 37
 	BYTE_TO_SHORT,
@@ -60,6 +62,9 @@ public enum BuiltinID {
60 62
 	SBYTE_AND_SBYTE,
61 63
 	SBYTE_OR_SBYTE,
62 64
 	SBYTE_XOR_SBYTE,
65
+	SBYTE_SHL,
66
+	SBYTE_SHR,
67
+	SBYTE_USHR,
63 68
 	SBYTE_COMPARE,
64 69
 	SBYTE_TO_BYTE,
65 70
 	SBYTE_TO_SHORT,
@@ -90,6 +95,9 @@ public enum BuiltinID {
90 95
 	SHORT_AND_SHORT,
91 96
 	SHORT_OR_SHORT,
92 97
 	SHORT_XOR_SHORT,
98
+	SHORT_SHL,
99
+	SHORT_SHR,
100
+	SHORT_USHR,
93 101
 	SHORT_COMPARE,
94 102
 	SHORT_TO_BYTE,
95 103
 	SHORT_TO_SBYTE,
@@ -119,6 +127,8 @@ public enum BuiltinID {
119 127
 	USHORT_AND_USHORT,
120 128
 	USHORT_OR_USHORT,
121 129
 	USHORT_XOR_USHORT,
130
+	USHORT_SHL,
131
+	USHORT_SHR,
122 132
 	USHORT_COMPARE,
123 133
 	USHORT_TO_BYTE,
124 134
 	USHORT_TO_SBYTE,
@@ -235,6 +245,7 @@ public enum BuiltinID {
235 245
 	LONG_SHR,
236 246
 	LONG_USHR,
237 247
 	LONG_COMPARE,
248
+	LONG_COMPARE_INT,
238 249
 	LONG_TO_BYTE,
239 250
 	LONG_TO_SBYTE,
240 251
 	LONG_TO_SHORT,
@@ -275,6 +286,8 @@ public enum BuiltinID {
275 286
 	ULONG_SHL,
276 287
 	ULONG_SHR,
277 288
 	ULONG_COMPARE,
289
+	ULONG_COMPARE_UINT,
290
+	ULONG_COMPARE_USIZE,
278 291
 	ULONG_TO_BYTE,
279 292
 	ULONG_TO_SBYTE,
280 293
 	ULONG_TO_SHORT,
@@ -315,6 +328,7 @@ public enum BuiltinID {
315 328
 	USIZE_SHL,
316 329
 	USIZE_SHR,
317 330
 	USIZE_COMPARE,
331
+	USIZE_COMPARE_UINT,
318 332
 	USIZE_TO_BYTE,
319 333
 	USIZE_TO_SBYTE,
320 334
 	USIZE_TO_SHORT,
@@ -474,6 +488,15 @@ public enum BuiltinID {
474 488
 	ARRAY_SAME,
475 489
 	ARRAY_NOTSAME,
476 490
 	
491
+	SBYTE_ARRAY_AS_BYTE_ARRAY,
492
+	BYTE_ARRAY_AS_SBYTE_ARRAY,
493
+	SHORT_ARRAY_AS_USHORT_ARRAY,
494
+	USHORT_ARRAY_AS_SHORT_ARRAY,
495
+	INT_ARRAY_AS_UINT_ARRAY,
496
+	UINT_ARRAY_AS_INT_ARRAY,
497
+	LONG_ARRAY_AS_ULONG_ARRAY,
498
+	ULONG_ARRAY_AS_LONG_ARRAY,
499
+	
477 500
 	FUNCTION_CALL,
478 501
 	FUNCTION_SAME,
479 502
 	FUNCTION_NOTSAME,

+ 9
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/DefinitionMemberGroup.java View File

@@ -105,6 +105,15 @@ public class DefinitionMemberGroup {
105 105
 		return false;
106 106
 	}
107 107
 	
108
+	public FunctionalMemberRef getStaticMethod(int arguments, ITypeID returnType) {
109
+		for (TypeMember<FunctionalMemberRef> method : methods) {
110
+			if (method.member.isStatic() && method.member.getHeader().accepts(arguments) && method.member.getHeader().getReturnType() == returnType)
111
+				return method.member;
112
+		}
113
+		
114
+		return null;
115
+	}
116
+	
108 117
 	public List<TypeMember<FunctionalMemberRef>> getMethodMembers() {
109 118
 		return this.methods;
110 119
 	}

+ 80
- 48
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java View File

@@ -35,7 +35,7 @@ import org.openzen.zenscript.codemodel.expression.ConstantULongExpression;
35 35
 import org.openzen.zenscript.codemodel.expression.ConstantUShortExpression;
36 36
 import org.openzen.zenscript.codemodel.expression.EnumConstantExpression;
37 37
 import org.openzen.zenscript.codemodel.expression.Expression;
38
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
38
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
39 39
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
40 40
 import org.openzen.zenscript.codemodel.member.CallerMember;
41 41
 import org.openzen.zenscript.codemodel.member.CasterMember;
@@ -68,6 +68,7 @@ import static org.openzen.zenscript.codemodel.type.member.BuiltinID.*;
68 68
 import static org.openzen.zencode.shared.CodePosition.BUILTIN;
69 69
 import org.openzen.zencode.shared.CompileException;
70 70
 import org.openzen.zencode.shared.CompileExceptionCode;
71
+import org.openzen.zenscript.codemodel.Module;
71 72
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
72 73
 import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
73 74
 import org.openzen.zenscript.codemodel.member.IteratorMember;
@@ -172,7 +173,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
172 173
 
173 174
 	@Override
174 175
 	public Void visitArray(ArrayTypeID array) {
175
-		HighLevelDefinition definition = new ClassDefinition(BUILTIN, null, "", Modifiers.EXPORT);
176
+		HighLevelDefinition definition = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
176 177
 		ITypeID baseType = array.elementType;
177 178
 		int dimension = array.dimension;
178 179
 
@@ -193,6 +194,23 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
193 194
 					OperatorType.INDEXGET,
194 195
 					sliceHeader,
195 196
 					ARRAY_INDEXGETRANGE);
197
+			
198
+			if (baseType == BYTE)
199
+				castImplicit(definition, BYTE_ARRAY_AS_SBYTE_ARRAY, registry.getArray(SBYTE, 1));
200
+			if (baseType == SBYTE)
201
+				castImplicit(definition, SBYTE_ARRAY_AS_BYTE_ARRAY, registry.getArray(BYTE, 1));
202
+			if (baseType == SHORT)
203
+				castImplicit(definition, SHORT_ARRAY_AS_USHORT_ARRAY, registry.getArray(USHORT, 1));
204
+			if (baseType == USHORT)
205
+				castImplicit(definition, USHORT_ARRAY_AS_SHORT_ARRAY, registry.getArray(SHORT, 1));
206
+			if (baseType == INT)
207
+				castImplicit(definition, INT_ARRAY_AS_UINT_ARRAY, registry.getArray(UINT, 1));
208
+			if (baseType == UINT)
209
+				castImplicit(definition, UINT_ARRAY_AS_INT_ARRAY, registry.getArray(INT, 1));
210
+			if (baseType == LONG)
211
+				castImplicit(definition, LONG_ARRAY_AS_ULONG_ARRAY, registry.getArray(ULONG, 1));
212
+			if (baseType == ULONG)
213
+				castImplicit(definition, ULONG_ARRAY_AS_LONG_ARRAY, registry.getArray(LONG, 1));
196 214
 		}
197 215
 
198 216
 		FunctionHeader containsHeader = new FunctionHeader(BOOL, new FunctionParameter(baseType, "value"));
@@ -303,7 +321,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
303 321
 		ITypeID keyType = assoc.keyType;
304 322
 		ITypeID valueType = assoc.valueType;
305 323
 		
306
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "", Modifiers.EXPORT);
324
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
307 325
 		
308 326
 		constructor(builtin, ASSOC_CONSTRUCTOR);
309 327
 
@@ -346,7 +364,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
346 364
 		FunctionHeader putHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BasicTypeID.VOID, null, new FunctionParameter(valueType));
347 365
 		FunctionHeader containsHeader = new FunctionHeader(new TypeParameter[] { functionParameter }, BasicTypeID.BOOL, null, new FunctionParameter[0]);
348 366
 		
349
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "", Modifiers.EXPORT);
367
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
350 368
 		constructor(builtin, GENERICMAP_CONSTRUCTOR);
351 369
 		
352 370
 		method(builtin, "getOptional", getOptionalHeader, GENERICMAP_GETOPTIONAL);
@@ -374,7 +392,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
374 392
 
375 393
 	@Override
376 394
 	public Void visitFunction(FunctionTypeID function) {
377
-		FunctionDefinition builtin = new FunctionDefinition(BUILTIN, null, "", Modifiers.EXPORT, function.header);
395
+		FunctionDefinition builtin = new FunctionDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT, function.header);
378 396
 		new CallerMember(BUILTIN, builtin, 0, function.header, FUNCTION_CALL).registerTo(members, TypeMemberPriority.SPECIFIED, null);
379 397
 		
380 398
 		same(builtin, FUNCTION_SAME, function);
@@ -485,7 +503,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
485 503
 	public Void visitGeneric(GenericTypeID generic) {
486 504
 		TypeParameter parameter = generic.parameter;
487 505
 
488
-		for (GenericParameterBound bound : parameter.bounds) {
506
+		for (TypeParameterBound bound : parameter.bounds) {
489 507
 			bound.registerMembers(cache, members);
490 508
 		}
491 509
 		
@@ -496,7 +514,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
496 514
 	public Void visitRange(RangeTypeID range) {
497 515
 		ITypeID baseType = range.baseType;
498 516
 
499
-		ClassDefinition definition = new ClassDefinition(BUILTIN, null, "", Modifiers.EXPORT);
517
+		ClassDefinition definition = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "", Modifiers.EXPORT);
500 518
 		getter(definition, RANGE_FROM, "from", baseType);
501 519
 		getter(definition, RANGE_TO, "to", baseType);
502 520
 		if (baseType == BYTE
@@ -518,7 +536,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
518 536
 
519 537
 	@Override
520 538
 	public Void visitModified(ModifiedTypeID modified) {
521
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "modified", Modifiers.EXPORT, null);
539
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "modified", Modifiers.EXPORT, null);
522 540
 		modified.baseType.accept(this);
523 541
 		
524 542
 		if (modified.isOptional()) {
@@ -530,7 +548,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
530 548
 	}
531 549
 	
532 550
 	private void visitBool() {
533
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "bool", Modifiers.EXPORT, null);
551
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "bool", Modifiers.EXPORT, null);
534 552
 		not(builtin, BOOL_NOT, BOOL);
535 553
 		and(builtin, BOOL_AND, BOOL, BOOL);
536 554
 		or(builtin, BOOL_OR, BOOL, BOOL);
@@ -545,7 +563,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
545 563
 	}
546 564
 	
547 565
 	private void visitByte() {
548
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "byte", Modifiers.EXPORT, null);
566
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "byte", Modifiers.EXPORT, null);
549 567
 		
550 568
 		invert(builtin, BYTE_NOT, BYTE);
551 569
 		inc(builtin, BYTE_INC, BYTE);
@@ -558,6 +576,8 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
558 576
 		and(builtin, BYTE_AND_BYTE, BYTE, BYTE);
559 577
 		or(builtin, BYTE_OR_BYTE, BYTE, BYTE);
560 578
 		xor(builtin, BYTE_XOR_BYTE, BYTE, BYTE);
579
+		shl(builtin, BYTE_SHL, USIZE, BYTE);
580
+		shr(builtin, BYTE_SHR, USIZE, BYTE);
561 581
 		compare(builtin, BYTE_COMPARE, BYTE);
562 582
 		
563 583
 		castImplicit(builtin, BYTE_TO_SBYTE, SBYTE);
@@ -583,7 +603,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
583 603
 	}
584 604
 	
585 605
 	private void visitSByte() {
586
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "sbyte", Modifiers.EXPORT, null);
606
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "sbyte", Modifiers.EXPORT, null);
587 607
 		
588 608
 		invert(builtin, SBYTE_NOT, SBYTE);
589 609
 		neg(builtin, SBYTE_NEG, SBYTE);
@@ -597,6 +617,9 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
597 617
 		and(builtin, SBYTE_AND_SBYTE, SBYTE, SBYTE);
598 618
 		or(builtin, SBYTE_OR_SBYTE, SBYTE, SBYTE);
599 619
 		xor(builtin, SBYTE_XOR_SBYTE, SBYTE, SBYTE);
620
+		shl(builtin, SBYTE_SHL, USIZE, SBYTE);
621
+		shr(builtin, SBYTE_SHR, USIZE, SBYTE);
622
+		ushr(builtin, SBYTE_USHR, USIZE, SBYTE);
600 623
 		compare(builtin, SBYTE_COMPARE, SBYTE);
601 624
 		
602 625
 		castImplicit(builtin, SBYTE_TO_BYTE, BYTE);
@@ -622,7 +645,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
622 645
 	}
623 646
 	
624 647
 	private void visitShort() {
625
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "short", Modifiers.EXPORT, null);
648
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "short", Modifiers.EXPORT, null);
626 649
 		
627 650
 		invert(builtin, SHORT_NOT, SHORT);
628 651
 		neg(builtin, SHORT_NEG, SHORT);
@@ -636,6 +659,9 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
636 659
 		and(builtin, SHORT_AND_SHORT, SHORT, SHORT);
637 660
 		or(builtin, SHORT_OR_SHORT, SHORT, SHORT);
638 661
 		xor(builtin, SHORT_XOR_SHORT, SHORT, SHORT);
662
+		shl(builtin, SHORT_SHL, USIZE, SHORT);
663
+		shr(builtin, SHORT_SHR, USIZE, SHORT);
664
+		ushr(builtin, SHORT_USHR, USIZE, SHORT);
639 665
 		compare(builtin, SHORT_COMPARE, SHORT);
640 666
 		
641 667
 		castExplicit(builtin, SHORT_TO_BYTE, BYTE);
@@ -661,7 +687,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
661 687
 	}
662 688
 	
663 689
 	private void visitUShort() {
664
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "ushort", Modifiers.EXPORT, null);
690
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "ushort", Modifiers.EXPORT, null);
665 691
 		
666 692
 		invert(builtin, USHORT_NOT, USHORT);
667 693
 		inc(builtin, USHORT_INC, USHORT);
@@ -674,6 +700,8 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
674 700
 		and(builtin, USHORT_AND_USHORT, USHORT, USHORT);
675 701
 		or(builtin, USHORT_OR_USHORT, USHORT, USHORT);
676 702
 		xor(builtin, USHORT_XOR_USHORT, USHORT, USHORT);
703
+		shl(builtin, USHORT_SHL, USIZE, USHORT);
704
+		shr(builtin, USHORT_SHR, USIZE, USHORT);
677 705
 		compare(builtin, USHORT_COMPARE, USHORT);
678 706
 		
679 707
 		castExplicit(builtin, USHORT_TO_BYTE, BYTE);
@@ -699,7 +727,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
699 727
 	}
700 728
 	
701 729
 	private void visitInt() {
702
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "int", Modifiers.EXPORT, null);
730
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "int", Modifiers.EXPORT, null);
703 731
 		
704 732
 		invert(builtin, INT_NOT, INT);
705 733
 		neg(builtin, INT_NEG, INT);
@@ -736,9 +764,9 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
736 764
 		xor(builtin, INT_XOR_INT, INT, INT);
737 765
 		xor(builtin, LONG_XOR_LONG, LONG, LONG, INT_TO_LONG);
738 766
 		
739
-		shl(builtin, INT_SHL, INT, INT);
740
-		shr(builtin, INT_SHR, INT, INT);
741
-		ushr(builtin, INT_USHR, INT, INT);
767
+		shl(builtin, INT_SHL, USIZE, INT);
768
+		shr(builtin, INT_SHR, USIZE, INT);
769
+		ushr(builtin, INT_USHR, USIZE, INT);
742 770
 		
743 771
 		compare(builtin, INT_COMPARE, INT);
744 772
 		compare(builtin, LONG_COMPARE, LONG, INT_TO_LONG);
@@ -780,7 +808,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
780 808
 	}
781 809
 
782 810
 	private void visitUInt() {
783
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "uint", Modifiers.EXPORT, null);
811
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "uint", Modifiers.EXPORT, null);
784 812
 		
785 813
 		invert(builtin, UINT_NOT, INT);
786 814
 		inc(builtin, UINT_DEC, INT);
@@ -816,8 +844,8 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
816 844
 		xor(builtin, UINT_XOR_UINT, UINT, UINT);
817 845
 		xor(builtin, ULONG_XOR_ULONG, ULONG, ULONG, UINT_TO_ULONG);
818 846
 		
819
-		shl(builtin, UINT_SHL, UINT, UINT);
820
-		shr(builtin, UINT_SHR, UINT, UINT);
847
+		shl(builtin, UINT_SHL, USIZE, UINT);
848
+		shr(builtin, UINT_SHR, USIZE, UINT);
821 849
 		
822 850
 		compare(builtin, UINT_COMPARE, UINT);
823 851
 		compare(builtin, ULONG_COMPARE, ULONG, UINT_TO_LONG);
@@ -859,7 +887,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
859 887
 	}
860 888
 	
861 889
 	private void visitLong() {
862
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "long", Modifiers.EXPORT, null);
890
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "long", Modifiers.EXPORT, null);
863 891
 		
864 892
 		invert(builtin, LONG_NOT, LONG);
865 893
 		neg(builtin, LONG_NEG, LONG);
@@ -888,10 +916,11 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
888 916
 		and(builtin, LONG_AND_LONG, LONG, LONG);
889 917
 		xor(builtin, LONG_XOR_LONG, LONG, LONG);
890 918
 		
891
-		shl(builtin, LONG_SHL, INT, LONG);
892
-		shr(builtin, LONG_SHR, INT, LONG);
893
-		ushr(builtin, LONG_USHR, INT, LONG);
919
+		shl(builtin, LONG_SHL, USIZE, LONG);
920
+		shr(builtin, LONG_SHR, USIZE, LONG);
921
+		ushr(builtin, LONG_USHR, USIZE, LONG);
894 922
 		
923
+		compare(builtin, LONG_COMPARE_INT, INT);
895 924
 		compare(builtin, LONG_COMPARE, LONG);
896 925
 		compare(builtin, FLOAT_COMPARE, FLOAT, LONG_TO_FLOAT);
897 926
 		compare(builtin, DOUBLE_COMPARE, DOUBLE, LONG_TO_DOUBLE);
@@ -931,7 +960,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
931 960
 	}
932 961
 	
933 962
 	private void visitULong() {
934
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "ulong", Modifiers.EXPORT, null);
963
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "ulong", Modifiers.EXPORT, null);
935 964
 		
936 965
 		invert(builtin, ULONG_NOT, ULONG);
937 966
 		inc(builtin, ULONG_DEC, ULONG);
@@ -959,9 +988,11 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
959 988
 		and(builtin, ULONG_AND_ULONG, ULONG, ULONG);
960 989
 		xor(builtin, ULONG_XOR_ULONG, ULONG, ULONG);
961 990
 		
962
-		shl(builtin, ULONG_SHL, INT, ULONG);
963
-		shr(builtin, ULONG_SHR, INT, ULONG);
991
+		shl(builtin, ULONG_SHL, USIZE, ULONG);
992
+		shr(builtin, ULONG_SHR, USIZE, ULONG);
964 993
 		
994
+		compare(builtin, ULONG_COMPARE_UINT, UINT);
995
+		compare(builtin, ULONG_COMPARE_USIZE, USIZE);
965 996
 		compare(builtin, ULONG_COMPARE, ULONG);
966 997
 		compare(builtin, FLOAT_COMPARE, FLOAT, ULONG_TO_FLOAT);
967 998
 		compare(builtin, DOUBLE_COMPARE, DOUBLE, ULONG_TO_DOUBLE);
@@ -1001,7 +1032,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1001 1032
 	}
1002 1033
 	
1003 1034
 	private void visitUSize() {
1004
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "usize", Modifiers.EXPORT, null);
1035
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "usize", Modifiers.EXPORT, null);
1005 1036
 		
1006 1037
 		invert(builtin, USIZE_NOT, USIZE);
1007 1038
 		inc(builtin, USIZE_DEC, USIZE);
@@ -1033,9 +1064,10 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1033 1064
 		and(builtin, USIZE_AND_USIZE, USIZE, USIZE);
1034 1065
 		xor(builtin, USIZE_XOR_USIZE, USIZE, USIZE);
1035 1066
 		
1036
-		shl(builtin, USIZE_SHL, INT, USIZE);
1037
-		shr(builtin, USIZE_SHR, INT, USIZE);
1067
+		shl(builtin, USIZE_SHL, USIZE, USIZE);
1068
+		shr(builtin, USIZE_SHR, USIZE, USIZE);
1038 1069
 		
1070
+		compare(builtin, USIZE_COMPARE_UINT, UINT);
1039 1071
 		compare(builtin, USIZE_COMPARE, USIZE);
1040 1072
 		compare(builtin, ULONG_COMPARE, ULONG, USIZE_TO_ULONG);
1041 1073
 		compare(builtin, FLOAT_COMPARE, FLOAT, USIZE_TO_FLOAT);
@@ -1077,7 +1109,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1077 1109
 	}
1078 1110
 	
1079 1111
 	private void visitFloat() {
1080
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "float", Modifiers.EXPORT, null);
1112
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "float", Modifiers.EXPORT, null);
1081 1113
 		
1082 1114
 		neg(builtin, FLOAT_NEG, FLOAT);
1083 1115
 		inc(builtin, FLOAT_DEC, FLOAT);
@@ -1122,7 +1154,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1122 1154
 	}
1123 1155
 	
1124 1156
 	private void visitDouble() {
1125
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "double", Modifiers.EXPORT, null);
1157
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "double", Modifiers.EXPORT, null);
1126 1158
 		
1127 1159
 		neg(builtin, DOUBLE_NEG, DOUBLE);
1128 1160
 		inc(builtin, DOUBLE_DEC, DOUBLE);
@@ -1143,7 +1175,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1143 1175
 		castExplicit(builtin, DOUBLE_TO_USHORT, USHORT);
1144 1176
 		castExplicit(builtin, DOUBLE_TO_INT, INT);
1145 1177
 		castExplicit(builtin, DOUBLE_TO_UINT, UINT);
1146
-		castExplicit(builtin, DOUBLE_TO_ULONG, ULONG);
1178
+		castExplicit(builtin, DOUBLE_TO_LONG, LONG);
1147 1179
 		castExplicit(builtin, DOUBLE_TO_ULONG, ULONG);
1148 1180
 		castExplicit(builtin, DOUBLE_TO_USIZE, USIZE);
1149 1181
 		castImplicit(builtin, DOUBLE_TO_FLOAT, FLOAT);
@@ -1158,7 +1190,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1158 1190
 	}
1159 1191
 
1160 1192
 	private void visitChar() {
1161
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "char", Modifiers.EXPORT, null);
1193
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "char", Modifiers.EXPORT, null);
1162 1194
 		
1163 1195
 		add(builtin, CHAR_ADD_INT, INT, CHAR);
1164 1196
 		sub(builtin, CHAR_SUB_INT, INT, CHAR);
@@ -1187,7 +1219,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1187 1219
 	}
1188 1220
 
1189 1221
 	private void visitString() {
1190
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, null, "string", Modifiers.EXPORT, null);
1222
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "string", Modifiers.EXPORT, null);
1191 1223
 		
1192 1224
 		constructor(builtin, STRING_CONSTRUCTOR_CHARACTERS, registry.getArray(CHAR, 1));
1193 1225
 		
@@ -1210,8 +1242,8 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1210 1242
 		processType(builtin, STRING);
1211 1243
 	}
1212 1244
 	
1213
-	private void castedTargetCall(OperatorMember member, BuiltinID casterBuiltin) {
1214
-		CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, member.header.parameters[0].type);
1245
+	private void castedTargetCall(OperatorMember member, ITypeID toType, BuiltinID casterBuiltin) {
1246
+		CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, toType);
1215 1247
 		TranslatedOperatorMemberRef method = new TranslatedOperatorMemberRef(member, GenericMapper.EMPTY, call -> member.ref(null).call(call.position, caster.cast(call.position, call.target, true), call.arguments, call.scope));
1216 1248
 		members.getOrCreateGroup(member.operator).addMethod(method, TypeMemberPriority.SPECIFIED);
1217 1249
 	}
@@ -1269,7 +1301,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1269 1301
 	}
1270 1302
 	
1271 1303
 	private void add(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1272
-		castedTargetCall(addOp(definition, id, operand, result), caster);
1304
+		castedTargetCall(addOp(definition, id, operand, result), result, caster);
1273 1305
 	}
1274 1306
 	
1275 1307
 	private OperatorMember subOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1287,7 +1319,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1287 1319
 	}
1288 1320
 	
1289 1321
 	private void sub(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1290
-		castedTargetCall(subOp(definition, id, operand, result), caster);
1322
+		castedTargetCall(subOp(definition, id, operand, result), result, caster);
1291 1323
 	}
1292 1324
 	
1293 1325
 	private OperatorMember mulOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1305,7 +1337,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1305 1337
 	}
1306 1338
 	
1307 1339
 	private void mul(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1308
-		castedTargetCall(mulOp(definition, id, operand, result), caster);
1340
+		castedTargetCall(mulOp(definition, id, operand, result), result, caster);
1309 1341
 	}
1310 1342
 	
1311 1343
 	private OperatorMember divOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1323,7 +1355,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1323 1355
 	}
1324 1356
 	
1325 1357
 	private void div(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1326
-		castedTargetCall(divOp(definition, id, operand, result), caster);
1358
+		castedTargetCall(divOp(definition, id, operand, result), result, caster);
1327 1359
 	}
1328 1360
 	
1329 1361
 	private OperatorMember modOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1341,7 +1373,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1341 1373
 	}
1342 1374
 	
1343 1375
 	private void mod(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1344
-		castedTargetCall(modOp(definition, id, operand, result), caster);
1376
+		castedTargetCall(modOp(definition, id, operand, result), result, caster);
1345 1377
 	}
1346 1378
 	
1347 1379
 	private OperatorMember shlOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1359,7 +1391,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1359 1391
 	}
1360 1392
 	
1361 1393
 	private void shl(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1362
-		castedTargetCall(shlOp(definition, id, operand, result), caster);
1394
+		castedTargetCall(shlOp(definition, id, operand, result), result, caster);
1363 1395
 	}
1364 1396
 	
1365 1397
 	private OperatorMember shrOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1377,7 +1409,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1377 1409
 	}
1378 1410
 	
1379 1411
 	private void shr(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1380
-		castedTargetCall(shrOp(definition, id, operand, result), caster);
1412
+		castedTargetCall(shrOp(definition, id, operand, result), result, caster);
1381 1413
 	}
1382 1414
 	
1383 1415
 	private OperatorMember ushrOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1395,7 +1427,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1395 1427
 	}
1396 1428
 	
1397 1429
 	private void ushr(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1398
-		castedTargetCall(ushrOp(definition, id, operand, result), caster);
1430
+		castedTargetCall(ushrOp(definition, id, operand, result), result, caster);
1399 1431
 	}
1400 1432
 	
1401 1433
 	private OperatorMember orOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1431,7 +1463,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1431 1463
 	}
1432 1464
 	
1433 1465
 	private void and(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1434
-		castedTargetCall(andOp(definition, id, operand, result), caster);
1466
+		castedTargetCall(andOp(definition, id, operand, result), result, caster);
1435 1467
 	}
1436 1468
 	
1437 1469
 	private OperatorMember xorOp(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1449,7 +1481,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1449 1481
 	}
1450 1482
 	
1451 1483
 	private void xor(HighLevelDefinition definition, BuiltinID id, ITypeID operand, ITypeID result, BuiltinID caster) {
1452
-		castedTargetCall(xorOp(definition, id, operand, result), caster);
1484
+		castedTargetCall(xorOp(definition, id, operand, result), result, caster);
1453 1485
 	}
1454 1486
 	
1455 1487
 	private void indexGet(HighLevelDefinition cls, BuiltinID id, ITypeID operand, ITypeID result) {
@@ -1487,7 +1519,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
1487 1519
 	}
1488 1520
 	
1489 1521
 	private void compare(HighLevelDefinition definition, BuiltinID id, ITypeID operand, BuiltinID caster) {
1490
-		castedTargetCall(compareOp(definition, id, operand), caster);
1522
+		castedTargetCall(compareOp(definition, id, operand), operand, caster);
1491 1523
 	}
1492 1524
 	
1493 1525
 	private void getter(HighLevelDefinition cls, BuiltinID id, String name, ITypeID type) {

+ 5
- 0
CompilerShared/src/main/java/org/openzen/zenscript/compiler/SemanticModule.java View File

@@ -12,6 +12,7 @@ import java.util.Map;
12 12
 import java.util.function.Consumer;
13 13
 import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
14 14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15
+import org.openzen.zenscript.codemodel.Module;
15 16
 import org.openzen.zenscript.codemodel.PackageDefinitions;
16 17
 import org.openzen.zenscript.codemodel.ScriptBlock;
17 18
 import org.openzen.zenscript.codemodel.annotations.AnnotationProcessor;
@@ -32,6 +33,7 @@ public class SemanticModule {
32 33
 	public final SemanticModule[] dependencies;
33 34
 	
34 35
 	private State state;
36
+	public final Module module;
35 37
 	public final ZSPackage rootPackage;
36 38
 	public final ZSPackage modulePackage;
37 39
 	public final PackageDefinitions definitions;
@@ -44,6 +46,7 @@ public class SemanticModule {
44 46
 	
45 47
 	public SemanticModule(
46 48
 			String name,
49
+			Module module,
47 50
 			SemanticModule[] dependencies,
48 51
 			State state,
49 52
 			ZSPackage rootPackage,
@@ -55,6 +58,7 @@ public class SemanticModule {
55 58
 			AnnotationDefinition[] annotations)
56 59
 	{
57 60
 		this.name = name;
61
+		this.module = module;
58 62
 		this.dependencies = dependencies;
59 63
 		
60 64
 		this.state = state;
@@ -90,6 +94,7 @@ public class SemanticModule {
90 94
 		
91 95
 		return new SemanticModule(
92 96
 				name,
97
+				module,
93 98
 				dependencies,
94 99
 				State.NORMALIZED,
95 100
 				rootPackage,

Constructor/src/main/java/org/openzen/zenscript/constructor/Module.java → Constructor/src/main/java/org/openzen/zenscript/constructor/ParsedModule.java View File

@@ -24,7 +24,7 @@ import org.openzen.zenscript.parser.ParsedFile;
24 24
  *
25 25
  * @author Hoofdgebruiker
26 26
  */
27
-public class Module {
27
+public class ParsedModule {
28 28
 	public final String name;
29 29
 	public final String[] dependencies;
30 30
 	public final File sourceDirectory;
@@ -33,7 +33,7 @@ public class Module {
33 33
 	public final String host;
34 34
 	private final Consumer<CompileException> exceptionLogger;
35 35
 	
36
-	public Module(String name, File directory, File moduleFile, Consumer<CompileException> exceptionLogger) throws IOException {
36
+	public ParsedModule(String name, File directory, File moduleFile, Consumer<CompileException> exceptionLogger) throws IOException {
37 37
 		this.name = name;
38 38
 		this.sourceDirectory = new File(directory, "src");
39 39
 		this.exceptionLogger = exceptionLogger;

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

@@ -16,12 +16,13 @@ import org.json.JSONArray;
16 16
 import org.json.JSONObject;
17 17
 import org.openzen.zencode.shared.CompileException;
18 18
 import org.openzen.zencode.shared.FileSourceFile;
19
+import org.openzen.zenscript.codemodel.Module;
19 20
 import org.openzen.zenscript.codemodel.context.CompilingPackage;
20 21
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
21 22
 import org.openzen.zenscript.compiler.CompilationUnit;
22 23
 import org.openzen.zenscript.constructor.ConstructorException;
23 24
 import org.openzen.zenscript.constructor.JSONUtils;
24
-import org.openzen.zenscript.constructor.Module;
25
+import org.openzen.zenscript.constructor.ParsedModule;
25 26
 import org.openzen.zenscript.constructor.ModuleLoader;
26 27
 import org.openzen.zenscript.codemodel.type.TypeSymbol;
27 28
 import org.openzen.zenscript.parser.ParsedFile;
@@ -80,12 +81,13 @@ public class DirectoryModuleReference implements ModuleReference {
80 81
 				space.addModule(dependencyName, module);
81 82
 			}
82 83
 
83
-			Module module = new Module(moduleName, directory, jsonFile, exceptionLogger);
84
-			ZSPackage pkg = isStdlib ? unit.globalTypeRegistry.stdlib : new ZSPackage(null, module.packageName);
85
-			CompilingPackage compilingPackage = new CompilingPackage(pkg);
84
+			ParsedModule parsedModule = new ParsedModule(moduleName, directory, jsonFile, exceptionLogger);
85
+			ZSPackage pkg = isStdlib ? unit.globalTypeRegistry.stdlib : new ZSPackage(null, parsedModule.packageName);
86
+			Module module = new Module(moduleName);
87
+			CompilingPackage compilingPackage = new CompilingPackage(pkg, module);
86 88
 			
87
-			ParsedFile[] parsedFiles = module.parse(compilingPackage);
88
-			SemanticModule result = ParsedFile.compileSyntaxToSemantic(module.name, dependencies, compilingPackage, parsedFiles, space, exceptionLogger);
89
+			ParsedFile[] parsedFiles = parsedModule.parse(compilingPackage);
90
+			SemanticModule result = ParsedFile.compileSyntaxToSemantic(parsedModule.name, dependencies, compilingPackage, parsedFiles, space, exceptionLogger);
89 91
 			
90 92
 			JSONObject globals = json.optJSONObject("globals");
91 93
 			if (globals != null) {

+ 6
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java View File

@@ -470,6 +470,11 @@ public class SourceEditor implements DComponent {
470 470
 		String extract = tokens.extract(
471 471
 				SourcePosition.min(cursorStart, cursorEnd),
472 472
 				SourcePosition.max(cursorStart, cursorEnd));
473
+		if (context.getUIContext() == null)
474
+			throw new NullPointerException("No context!");
475
+		if (context.getUIContext().getClipboard() == null)
476
+			throw new NullPointerException("No clipboard!");
477
+		
473 478
 		context.getUIContext().getClipboard().copyAsString(extract);
474 479
 	}
475 480
 	
@@ -816,6 +821,7 @@ public class SourceEditor implements DComponent {
816 821
 					return IDENTIFIER;
817 822
 				case T_FLOAT:
818 823
 				case T_INT:
824
+				case T_PREFIXED_INT:
819 825
 					return NUMBER;
820 826
 				case T_STRING_SQ:
821 827
 				case T_STRING_DQ:

+ 1
- 1
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/TokenModel.java View File

@@ -120,7 +120,7 @@ public class TokenModel {
120 120
 			
121 121
 			for (int i = fromT.line + 1; i < toT.line; i++) {
122 122
 				result.append("\n");
123
-				for (ZSToken t : fromLine.getTokens()) {
123
+				for (ZSToken t : getLine(i).getTokens()) {
124 124
 					result.append(t.content);
125 125
 				}
126 126
 			}

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

@@ -31,10 +31,6 @@ import org.openzen.zenscript.javashared.JavaSynthesizedClassNamer;
31 31
 import org.openzen.zenscript.javashared.JavaVariantOption;
32 32
 
33 33
 public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
34
-	private static final int PUBLIC = Opcodes.ACC_PUBLIC;
35
-	private static final int STATIC = Opcodes.ACC_STATIC;
36
-	private static final int PUBLIC_STATIC = PUBLIC | STATIC;
37
-
38 34
 	private static final JavaMethod BOOLEAN_PARSE = JavaMethod.getNativeStatic(JavaClass.BOOLEAN, "parseBoolean", "(Ljava/lang/String;)Z");
39 35
 	private static final JavaMethod BOOLEAN_TO_STRING = JavaMethod.getNativeStatic(JavaClass.BOOLEAN, "toString", "(Z)Ljava/lang/String;");
40 36
 	private static final JavaMethod BYTE_PARSE = JavaMethod.getNativeStatic(JavaClass.BYTE, "parseByte", "(Ljava/lang/String;)B");
@@ -224,11 +220,13 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
224 220
 				case SHORT_COMPARE:
225 221
 				case INT_COMPARE:
226 222
 				case CHAR_COMPARE:
223
+				case USIZE_COMPARE:
227 224
 					expression.left.accept(this);
228 225
 					expression.right.accept(this);
229 226
 					compareInt(expression.comparison);
230 227
 					break;
231 228
 				case UINT_COMPARE:
229
+				case USIZE_COMPARE_UINT:
232 230
 					expression.left.accept(this);
233 231
 					expression.right.accept(this);
234 232
 					javaWriter.invokeStatic(INTEGER_COMPARE_UNSIGNED);
@@ -246,6 +244,22 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
246 244
 					javaWriter.invokeStatic(LONG_COMPARE_UNSIGNED);
247 245
 					compareGeneric(expression.comparison);
248 246
 					break;
247
+				case ULONG_COMPARE_UINT:
248
+					expression.left.accept(this);
249
+					expression.right.accept(this);
250
+					javaWriter.i2l();
251
+					javaWriter.constant(0xFFFF_FFFFL);
252
+					javaWriter.lAnd();
253
+					javaWriter.invokeStatic(LONG_COMPARE_UNSIGNED);
254
+					compareGeneric(expression.comparison);
255
+					break;
256
+				case ULONG_COMPARE_USIZE:
257
+					expression.left.accept(this);
258
+					expression.right.accept(this);
259
+					javaWriter.i2l();
260
+					javaWriter.invokeStatic(LONG_COMPARE_UNSIGNED);
261
+					compareGeneric(expression.comparison);
262
+					break;
249 263
 				case FLOAT_COMPARE:
250 264
 					expression.left.accept(this);
251 265
 					expression.right.accept(this);
@@ -491,14 +505,24 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
491 505
 			case USIZE_XOR_USIZE:
492 506
 				javaWriter.iXor();
493 507
 				break;
508
+			case BYTE_SHL:
509
+			case SBYTE_SHL:
510
+			case SHORT_SHL:
511
+			case USHORT_SHL:
494 512
 			case INT_SHL:
495 513
 			case UINT_SHL:
496 514
 			case USIZE_SHL:
497 515
 				javaWriter.iShl();
498 516
 				break;
517
+			case SBYTE_SHR:
518
+			case SHORT_SHR:
499 519
 			case INT_SHR:
500 520
 				javaWriter.iShr();
501 521
 				break;
522
+			case BYTE_SHR:
523
+			case SBYTE_USHR:
524
+			case USHORT_SHR:
525
+			case SHORT_USHR:
502 526
 			case INT_USHR:
503 527
 			case UINT_SHR:
504 528
 			case USIZE_SHR:
@@ -1628,7 +1652,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
1628 1652
 
1629 1653
 		final JavaMethod methodInfo = JavaMethod.getNativeVirtual(javaWriter.method.cls, "accept", signature);
1630 1654
 		final ClassWriter lambdaCW = new JavaClassWriter(ClassWriter.COMPUTE_FRAMES);
1631
-		lambdaCW.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", new String[]{JavaSynthesizedClassNamer.createFunctionName(new FunctionTypeID(null, expression.header)).cls.internalName});
1655
+		lambdaCW.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", new String[]{context.getInternalName(new FunctionTypeID(null, expression.header))});
1632 1656
 		final JavaWriter functionWriter = new JavaWriter(lambdaCW, methodInfo, null, signature, null, "java/lang/Override");
1633 1657
 
1634 1658
 		javaWriter.newObject(name);

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

@@ -65,10 +65,10 @@ public class JavaTypeGenericVisitor implements ITypeVisitor<String> {
65 65
 	}
66 66
 
67 67
 
68
-	public String getGenericBounds(Collection<GenericParameterBound> collection) {
68
+	public String getGenericBounds(Collection<TypeParameterBound> collection) {
69 69
 		if (collection == null)
70 70
 			return "";
71
-		for (GenericParameterBound parameterBound : collection) {
71
+		for (TypeParameterBound parameterBound : collection) {
72 72
 			String s = parameterBound.accept(new GenericParameterBoundVisitor<String>() {
73 73
 				@Override
74 74
 				public String visitSuper(ParameterSuperBound bound) {

+ 8
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaNativeTranslator.java View File

@@ -27,4 +27,12 @@ public interface JavaNativeTranslator<T> {
27 27
 	T copy(Expression value);
28 28
 	
29 29
 	T copyTo(CallExpression call);
30
+	
31
+	T stringToAscii(Expression value);
32
+	
33
+	T stringToUTF8(Expression value);
34
+	
35
+	T bytesAsciiToString(Expression value);
36
+	
37
+	T bytesUTF8ToString(Expression value);
30 38
 }

+ 2
- 2
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeDescriptorVisitor.java View File

@@ -1,6 +1,6 @@
1 1
 package org.openzen.zenscript.javashared;
2 2
 
3
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
3
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
4 4
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
5 5
 import org.openzen.zenscript.codemodel.type.*;
6 6
 
@@ -99,7 +99,7 @@ public class JavaTypeDescriptorVisitor implements ITypeVisitor<String> {
99 99
 
100 100
     @Override
101 101
     public String visitGeneric(GenericTypeID generic) {
102
-		for (GenericParameterBound bound : generic.parameter.bounds) {
102
+		for (TypeParameterBound bound : generic.parameter.bounds) {
103 103
 			if (bound instanceof ParameterTypeBound) {
104 104
 				return ((ParameterTypeBound) bound).type.accept(this);
105 105
 			}

+ 2
- 2
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeInternalNameVisitor.java View File

@@ -1,6 +1,6 @@
1 1
 package org.openzen.zenscript.javashared;
2 2
 
3
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
3
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
4 4
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
5 5
 import org.openzen.zenscript.codemodel.type.*;
6 6
 
@@ -90,7 +90,7 @@ public class JavaTypeInternalNameVisitor implements ITypeVisitor<String> {
90 90
 
91 91
     @Override
92 92
     public String visitGeneric(GenericTypeID generic) {
93
-		for (GenericParameterBound bound : generic.parameter.bounds) {
93
+		for (TypeParameterBound bound : generic.parameter.bounds) {
94 94
 			if (bound instanceof ParameterTypeBound) {
95 95
 				return ((ParameterTypeBound) bound).type.accept(this);
96 96
 			}

+ 18
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/prepare/JavaPrepareDefinitionVisitor.java View File

@@ -21,6 +21,7 @@ import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
21 21
 import org.openzen.zenscript.codemodel.definition.StructDefinition;
22 22
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
23 23
 import org.openzen.zenscript.codemodel.expression.CallExpression;
24
+import org.openzen.zenscript.codemodel.expression.CallStaticExpression;
24 25
 import org.openzen.zenscript.codemodel.expression.CastExpression;
25 26
 import org.openzen.zenscript.codemodel.expression.Expression;
26 27
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
@@ -127,11 +128,27 @@ public class JavaPrepareDefinitionVisitor implements DefinitionVisitor<JavaClass
127 128
 			cls.addInstanceMethod("lastIndexOf", "lastIndexOf", "(I)I");
128 129
 			cls.addInstanceMethod("lastIndexOfFrom", "lastIndexOf", "(II)I");
129 130
 			cls.addInstanceMethod("trim", "trim", "()Ljava/lang/String;");
131
+			cls.addMethod("fromAsciiBytes", new JavaMethod((expression, translator) -> {
132
+				CallStaticExpression call = (CallStaticExpression)expression;
133
+				return translator.bytesAsciiToString(call.arguments.arguments[0]);
134
+			}));
135
+			cls.addMethod("fromUTF8Bytes", new JavaMethod((expression, translator) -> {
136
+				CallStaticExpression call = (CallStaticExpression)expression;
137
+				return translator.bytesUTF8ToString(call.arguments.arguments[0]);
138
+			}));
139
+			cls.addMethod("toAsciiBytes", new JavaMethod((expression, translator) -> {
140
+				CallExpression call = (CallExpression)expression;
141
+				return translator.stringToAscii(call.target);
142
+			}));
143
+			cls.addMethod("toUTF8Bytes", new JavaMethod((expression, translator) -> {
144
+				CallExpression call = (CallExpression)expression;
145
+				return translator.stringToUTF8(call.target);
146
+			}));
130 147
 			nativeClasses.put("stdlib::String", cls);
131 148
 		}
132 149
 		
133 150
 		{
134
-			JavaClass arrays = new JavaClass("java.lang", "Arrays", JavaClass.Kind.CLASS);
151
+			JavaClass arrays = JavaClass.ARRAYS;
135 152
 			JavaNativeClass cls = new JavaNativeClass(arrays);
136 153
 			cls.addMethod("sort", JavaMethod.getNativeExpansion(arrays, "sort", "([Ljava/lang/Object;)[Ljava/lang/Object;"));
137 154
 			cls.addMethod("sorted", new JavaMethod((expression, translator) -> {

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

@@ -9,7 +9,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
9 9
 import org.openzen.zenscript.codemodel.FunctionParameter;
10 10
 import org.openzen.zenscript.codemodel.expression.CallArguments;
11 11
 import org.openzen.zenscript.codemodel.expression.Expression;
12
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
12
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
13 13
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
14 14
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
@@ -61,7 +61,7 @@ public class FormattingUtils {
61 61
 				result.append(parameter.name);
62 62
 				
63 63
 				if (parameter.bounds.size() > 0) {
64
-					for (GenericParameterBound bound : parameter.bounds) {
64
+					for (TypeParameterBound bound : parameter.bounds) {
65 65
 						result.append(": ");
66 66
 						result.append(bound.accept(typeFormatter));
67 67
 					}

+ 126
- 32
JavaSourceCompiler/src/main/java/org/openzen/zenscript/javasource/JavaSourceExpressionFormatter.java View File

@@ -108,6 +108,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
108 108
 	private static final JavaClass RESULT = new JavaClass("stdlib", "Result", JavaClass.Kind.CLASS);
109 109
 	private static final JavaClass RESULT_OK = new JavaClass("stdlib", "Result.Ok", JavaClass.Kind.CLASS);
110 110
 	private static final JavaClass RESULT_ERROR = new JavaClass("stdlib", "Result.Error", JavaClass.Kind.CLASS);
111
+	private static final JavaClass STANDARD_CHARSETS = new JavaClass("java.nio.charset", "StandardCharsets", JavaClass.Kind.CLASS);
111 112
 	
112 113
 	public final JavaSourceStatementScope scope;
113 114
 	public final StatementFormattingTarget target;
@@ -205,6 +206,9 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
205 206
 		if (method == null)
206 207
 			throw new IllegalStateException("No source method tag for " + expression.member.getCanonicalName() + "!");
207 208
 		
209
+		if (method.kind == JavaMethod.Kind.COMPILED)
210
+			return (ExpressionString) method.translation.translate(expression, this);
211
+		
208 212
 		StringBuilder result = new StringBuilder();
209 213
 		result.append(scope.type(method.cls));
210 214
 		result.append('.');
@@ -327,7 +331,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
327 331
 
328 332
 	@Override
329 333
 	public ExpressionString visitConstantLong(ConstantLongExpression expression) {
330
-		return new ExpressionString(Long.toString(expression.value), JavaOperator.PRIMARY);
334
+		return new ExpressionString(Long.toString(expression.value) + "L", JavaOperator.PRIMARY);
331 335
 	}
332 336
 
333 337
 	@Override
@@ -354,7 +358,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
354 358
 
355 359
 	@Override
356 360
 	public ExpressionString visitConstantULong(ConstantULongExpression expression) {
357
-		return new ExpressionString(Long.toString(expression.value), JavaOperator.CAST);
361
+		return new ExpressionString(Long.toString(expression.value) + "L", JavaOperator.CAST);
358 362
 	}
359 363
 
360 364
 	@Override
@@ -745,6 +749,14 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
745 749
 			GenericTypeID generic = (GenericTypeID)elementType;
746 750
 			String array = scope.type(new JavaClass("java.lang.reflect", "Array", JavaClass.Kind.CLASS));
747 751
 			return new ExpressionString("(" + generic.parameter.name + "[])(" + array + ".newInstance(typeOf" + generic.parameter.name + ", " + length.value + "))", JavaOperator.CAST);
752
+		} else if (elementType == BasicTypeID.BYTE) {
753
+			return new ExpressionString("new byte[" + length.value + "]", JavaOperator.NEW);
754
+		} else if (elementType == BasicTypeID.USHORT) {
755
+			return new ExpressionString("new short[" + length.value + "]", JavaOperator.NEW);
756
+		} else if (elementType == BasicTypeID.UINT) {
757
+			return new ExpressionString("new int[" + length.value + "]", JavaOperator.NEW);
758
+		} else if (elementType == BasicTypeID.ULONG) {
759
+			return new ExpressionString("new long[" + length.value + "]", JavaOperator.NEW);
748 760
 		} else {
749 761
 			return new ExpressionString("new " + scope.type(elementType) + "[" + length.value + "]", JavaOperator.NEW);
750 762
 		}
@@ -874,6 +886,18 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
874 886
 		return new ExpressionString(output.toString(), JavaOperator.CALL);
875 887
 	}
876 888
 	
889
+	public ExpressionString callAsStaticTruncated(String target, CallExpression expression, JavaOperator truncator) {
890
+		StringBuilder output = new StringBuilder();
891
+		output.append(target).append("(");
892
+		output.append(expression.target.accept(this).value);
893
+		for (Expression argument : expression.arguments.arguments) {
894
+			output.append(", ");
895
+			output.append(argument.accept(this).unaryPostfix(truncator).value);
896
+		}
897
+		output.append(")");
898
+		return new ExpressionString(output.toString(), JavaOperator.CALL);
899
+	}
900
+	
877 901
 	public ExpressionString callAsStatic(String target, Expression left, Expression right) {
878 902
 		StringBuilder output = new StringBuilder();
879 903
 		output.append(target).append("(");
@@ -897,21 +921,11 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
897 921
 	}
898 922
 	
899 923
 	private ExpressionString cast(CastExpression cast, String type) {
900
-		StringBuilder output = new StringBuilder();
901
-		output.append('(');
902
-		output.append(type);
903
-		output.append(')');
904
-		output.append(cast.target.accept(this).value);
905
-		return new ExpressionString(output.toString(), JavaOperator.CAST);
924
+		return cast.target.accept(this).unaryPrefix(JavaOperator.CAST, "(" + type + ")");
906 925
 	}
907 926
 	
908 927
 	private ExpressionString cast(ExpressionString value, String type) {
909
-		StringBuilder output = new StringBuilder();
910
-		output.append('(');
911
-		output.append(type);
912
-		output.append(')');
913
-		output.append(value.value);
914
-		return new ExpressionString(output.toString(), JavaOperator.CAST);
928
+		return value.unaryPrefix(JavaOperator.CALL, "(" + type + ")");
915 929
 	}
916 930
 	
917 931
 	private ExpressionString castPostfix(CastExpression cast, JavaOperator operator) {
@@ -954,11 +968,13 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
954 968
 			case BYTE_ADD_BYTE: return binary(call, JavaOperator.ADD);
955 969
 			case BYTE_SUB_BYTE: return binary(call, JavaOperator.SUB);
956 970
 			case BYTE_MUL_BYTE: return binary(call, JavaOperator.MUL);
957
-			case BYTE_DIV_BYTE: return callAsStatic("Integer.divideUnsigned", call);
958
-			case BYTE_MOD_BYTE: return callAsStatic("Integer.remainderUnsigned", call);
971
+			case BYTE_DIV_BYTE: return callAsStaticTruncated("Integer.divideUnsigned", call, JavaOperator.AND_FF);
972
+			case BYTE_MOD_BYTE: return callAsStaticTruncated("Integer.remainderUnsigned", call, JavaOperator.AND_FF);
959 973
 			case BYTE_AND_BYTE: return binary(call, JavaOperator.AND);
960 974
 			case BYTE_OR_BYTE: return binary(call, JavaOperator.OR);
961 975
 			case BYTE_XOR_BYTE: return binary(call, JavaOperator.XOR);
976
+			case BYTE_SHL: return binary(call, JavaOperator.SHL);
977
+			case BYTE_SHR: return binary(call, JavaOperator.SHR);
962 978
 			case SBYTE_NOT: return unaryPrefix(call, JavaOperator.INVERT);
963 979
 			case SBYTE_NEG: return unaryPrefix(call, JavaOperator.NEG);
964 980
 			case SBYTE_ADD_SBYTE: return binary(call, JavaOperator.ADD);
@@ -969,6 +985,9 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
969 985
 			case SBYTE_AND_SBYTE: return binary(call, JavaOperator.AND);
970 986
 			case SBYTE_OR_SBYTE: return binary(call, JavaOperator.OR);
971 987
 			case SBYTE_XOR_SBYTE: return binary(call, JavaOperator.XOR);
988
+			case SBYTE_SHL: return binary(call, JavaOperator.SHL);
989
+			case SBYTE_SHR: return binary(call, JavaOperator.SHR);
990
+			case SBYTE_USHR: return binary(call, JavaOperator.USHR);
972 991
 			case SHORT_NOT: return unaryPrefix(call, JavaOperator.INVERT);
973 992
 			case SHORT_NEG: return unaryPrefix(call, JavaOperator.NEG);
974 993
 			case SHORT_ADD_SHORT: return binary(call, JavaOperator.ADD);
@@ -979,15 +998,19 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
979 998
 			case SHORT_AND_SHORT: return binary(call, JavaOperator.AND);
980 999
 			case SHORT_OR_SHORT: return binary(call, JavaOperator.OR);
981 1000
 			case SHORT_XOR_SHORT: return binary(call, JavaOperator.XOR);
1001
+			case SHORT_SHL: return binary(call, JavaOperator.SHL);
1002
+			case SHORT_SHR: return binary(call, JavaOperator.SHR);
982 1003
 			case USHORT_NOT: return unaryPrefix(call, JavaOperator.INVERT);
983 1004
 			case USHORT_ADD_USHORT: return binary(call, JavaOperator.ADD);
984 1005
 			case USHORT_SUB_USHORT: return binary(call, JavaOperator.SUB);
985 1006
 			case USHORT_MUL_USHORT: return binary(call, JavaOperator.MUL);
986
-			case USHORT_DIV_USHORT: return binary(call, JavaOperator.DIV);
987
-			case USHORT_MOD_USHORT: return binary(call, JavaOperator.MOD);
1007
+			case USHORT_DIV_USHORT: return callAsStaticTruncated("Integer.divideUnsigned", call, JavaOperator.AND_FFFF);
1008
+			case USHORT_MOD_USHORT: return callAsStaticTruncated("Integer.remainderUnsigned", call, JavaOperator.AND_FFFF);
988 1009
 			case USHORT_AND_USHORT: return binary(call, JavaOperator.AND);
989 1010
 			case USHORT_OR_USHORT: return binary(call, JavaOperator.OR);
990 1011
 			case USHORT_XOR_USHORT: return binary(call, JavaOperator.XOR);
1012
+			case USHORT_SHL: return binary(call, JavaOperator.SHL);
1013
+			case USHORT_SHR: return binary(call, JavaOperator.SHR);
991 1014
 			case INT_NOT: return unaryPrefix(call, JavaOperator.INVERT);
992 1015
 			case INT_NEG: return unaryPrefix(call, JavaOperator.NEG);
993 1016
 			case INT_ADD_INT: return binary(call, JavaOperator.ADD);
@@ -1128,11 +1151,29 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1128 1151
 			case GENERICMAP_SAME: return binary(call, JavaOperator.EQUALS);
1129 1152
 			case GENERICMAP_NOTSAME: return binary(call, JavaOperator.NOTEQUALS);
1130 1153
 			case ARRAY_INDEXGET: return new ExpressionString(call.target.accept(this) + "[" + call.arguments.arguments[0].accept(this) + "]", JavaOperator.INDEX);
1131
-			case ARRAY_INDEXSET: return new ExpressionString(
1154
+			case ARRAY_INDEXSET: {
1155
+				ExpressionString value = call.arguments.arguments[1].accept(this);
1156
+				ITypeID baseType = ((ArrayTypeID)(call.target.type)).elementType;
1157
+				String asType = "";
1158
+				if (baseType == BasicTypeID.BYTE) {
1159
+					asType = "(byte)";
1160
+				} else if (baseType == BasicTypeID.USHORT) {
1161
+					asType = "(short)";
1162
+				}
1163
+				
1164
+				if (!asType.isEmpty()) {
1165
+					if (value.priority == JavaOperator.CAST && value.value.startsWith("(int)"))
1166
+						value = new ExpressionString(asType + value.value.substring(5), value.priority);
1167
+					else
1168
+						value = value.unaryPrefix(JavaOperator.CAST, asType);
1169
+				}
1170
+				
1171
+				return new ExpressionString(
1132 1172
 					call.target.accept(this)
1133 1173
 							+ "[" + call.arguments.arguments[0].accept(this)
1134 1174
 							+ "] = "
1135
-							+ call.arguments.arguments[1].accept(this), JavaOperator.INDEX);
1175
+							+ value.value, JavaOperator.INDEX);
1176
+			}
1136 1177
 			case ARRAY_INDEXGETRANGE: {
1137 1178
 				ExpressionString left = call.target.accept(this);
1138 1179
 				Expression argument = call.arguments.arguments[0];
@@ -1140,7 +1181,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1140 1181
 					RangeExpression rangeArgument = (RangeExpression)argument;
1141 1182
 					ExpressionString from = rangeArgument.from.accept(this);
1142 1183
 					ExpressionString to = rangeArgument.to.accept(this);
1143
-					return new ExpressionString("Arrays.copyOfRange(" + left.value + ", " + from.value + ", " + to.value + ")", JavaOperator.CALL);
1184
+					return new ExpressionString(scope.type(JavaClass.ARRAYS) + ".copyOfRange(" + left.value + ", " + from.value + ", " + to.value + ")", JavaOperator.CALL);
1144 1185
 				} else {
1145 1186
 					throw new UnsupportedOperationException("Not yet supported!");
1146 1187
 				}
@@ -1149,8 +1190,8 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1149 1190
 				JavaMethod method = scope.fileScope.helperGenerator.createArrayContains((ArrayTypeID)call.target.type);
1150 1191
 				return callAsStatic(scope.fileScope.importer.importType(method.cls) + '.' + method.name, call);
1151 1192
 			}
1152
-			case ARRAY_EQUALS: return callAsStatic("Arrays.equals", call);
1153
-			case ARRAY_NOTEQUALS: return callAsStatic("!Arrays.equals", call);
1193
+			case ARRAY_EQUALS: return callAsStatic(scope.type(JavaClass.ARRAYS) + ".equals", call);
1194
+			case ARRAY_NOTEQUALS: return callAsStatic("!" + scope.type(JavaClass.ARRAYS) + ".equals", call);
1154 1195
 			case ARRAY_SAME: return binary(call, JavaOperator.EQUALS);
1155 1196
 			case ARRAY_NOTSAME: return binary(call, JavaOperator.NOTEQUALS);
1156 1197
 			case FUNCTION_CALL: {
@@ -1231,9 +1272,15 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1231 1272
 			case INT_COMPARE:
1232 1273
 			case USIZE_COMPARE:
1233 1274
 				return compare(call.left, call.right, call.comparison);
1234
-			case UINT_COMPARE: return compare(callAsStatic("Integer.compareUnsigned", call.left, call.right), call.comparison);
1235
-			case LONG_COMPARE: return compare(call.left, call.right, call.comparison);
1236
-			case ULONG_COMPARE: return compare(callAsStatic("Long.compareUnsigned", call.left, call.right), call.comparison);
1275
+			case UINT_COMPARE:
1276
+			case USIZE_COMPARE_UINT:
1277
+				return compare(callAsStatic("Integer.compareUnsigned", call.left, call.right), call.comparison);
1278
+			case LONG_COMPARE:
1279
+			case LONG_COMPARE_INT:
1280
+				return compare(call.left, call.right, call.comparison);
1281
+			case ULONG_COMPARE:
1282
+			case ULONG_COMPARE_UINT:
1283
+				return compare(callAsStatic("Long.compareUnsigned", call.left, call.right), call.comparison);
1237 1284
 			case FLOAT_COMPARE: return compare(call.left, call.right, call.comparison);
1238 1285
 			case DOUBLE_COMPARE: return compare(call.left, call.right, call.comparison);
1239 1286
 			case CHAR_COMPARE: return compare(call.left, call.right, call.comparison);
@@ -1323,7 +1370,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1323 1370
 			case ARRAY_LENGTH:
1324 1371
 				return call.target.accept(this).unaryPostfix(JavaOperator.MEMBER, ".length");
1325 1372
 			case ARRAY_HASHCODE:
1326
-				return callAsStatic("Arrays.deepHashCode", call);
1373
+				return callAsStatic(scope.type(JavaClass.ARRAYS) + ".deepHashCode", call);
1327 1374
 			case ARRAY_ISEMPTY:
1328 1375
 				return call.target.accept(this).unaryPostfix(JavaOperator.EQUALS, ".length == 0");
1329 1376
 			case ENUM_NAME:
@@ -1474,6 +1521,16 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1474 1521
 			case ULONG_TO_DOUBLE: return castImplicit(cast, "double"); // TODO: this is incorrect!
1475 1522
 			case ULONG_TO_CHAR: return cast(cast, "char");
1476 1523
 			case ULONG_TO_STRING: return callStatic("Long.toUnsignedString", cast.target);
1524
+			case USIZE_TO_BYTE: return cast.target.accept(this);
1525
+			case USIZE_TO_SBYTE: return cast(cast, "byte");
1526
+			case USIZE_TO_SHORT: return cast(cast, "short");
1527
+			case USIZE_TO_USHORT: return cast.target.accept(this);
1528
+			case USIZE_TO_INT: return cast.target.accept(this);
1529
+			case USIZE_TO_UINT: return cast.target.accept(this);
1530
+			case USIZE_TO_LONG: return castImplicit(cast, "long");
1531
+			case USIZE_TO_ULONG: return castImplicit(cast, "long");
1532
+			case USIZE_TO_FLOAT: return castImplicit(cast, "float");
1533
+			case USIZE_TO_DOUBLE: return castImplicit(cast, "double");
1477 1534
 			case FLOAT_TO_BYTE: return cast(cast, "int");
1478 1535
 			case FLOAT_TO_SBYTE: return cast(cast, "byte");
1479 1536
 			case FLOAT_TO_SHORT: return cast(cast, "short");
@@ -1507,6 +1564,15 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1507 1564
 			case CHAR_TO_USIZE: return castImplicit(cast, "int");
1508 1565
 			case CHAR_TO_STRING: return callStatic("Character.toString", cast.target);
1509 1566
 			case ENUM_TO_STRING: return cast.target.accept(this).unaryPostfix(JavaOperator.TOSTRING);
1567
+			case BYTE_ARRAY_AS_SBYTE_ARRAY:
1568
+			case SBYTE_ARRAY_AS_BYTE_ARRAY:
1569
+			case SHORT_ARRAY_AS_USHORT_ARRAY:
1570
+			case USHORT_ARRAY_AS_SHORT_ARRAY:
1571
+			case INT_ARRAY_AS_UINT_ARRAY:
1572
+			case UINT_ARRAY_AS_INT_ARRAY:
1573
+			case LONG_ARRAY_AS_ULONG_ARRAY:
1574
+			case ULONG_ARRAY_AS_LONG_ARRAY:
1575
+				return cast.target.accept(this);
1510 1576
 		}
1511 1577
 		
1512 1578
 		throw new UnsupportedOperationException("Unknown builtin cast: " + cast.member.member.builtin);
@@ -1843,9 +1909,9 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1843 1909
 	public ExpressionString sorted(Expression value) {
1844 1910
 		Expression target = duplicable(value);
1845 1911
 		ExpressionString targetString = target.accept(this);
1846
-		ExpressionString copy = new ExpressionString("Arrays.copyOf(" + targetString.value + ", " + targetString.value + ".length).sort()", JavaOperator.CALL);
1912
+		ExpressionString copy = new ExpressionString(scope.type(JavaClass.ARRAYS) + ".copyOf(" + targetString.value + ", " + targetString.value + ".length).sort()", JavaOperator.CALL);
1847 1913
 		ExpressionString source = hoist(copy, scope.type(target.type));
1848
-		this.target.writeLine("Arrays.sort(" + source.value + ");");
1914
+		this.target.writeLine(scope.type(JavaClass.ARRAYS) + ".sort(" + source.value + ");");
1849 1915
 		return source;
1850 1916
 	}
1851 1917
 
@@ -1854,9 +1920,9 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1854 1920
 		Expression target = duplicable(value);
1855 1921
 		ExpressionString comparatorString = comparator.accept(this);
1856 1922
 		ExpressionString targetString = target.accept(this);
1857
-		ExpressionString copy = new ExpressionString("Arrays.copyOf(" + targetString.value + ", " + targetString.value + ".length).sort()", JavaOperator.CALL);
1923
+		ExpressionString copy = new ExpressionString(scope.type(JavaClass.ARRAYS) + ".copyOf(" + targetString.value + ", " + targetString.value + ".length).sort()", JavaOperator.CALL);
1858 1924
 		ExpressionString source = hoist(copy, scope.type(target.type));
1859
-		this.target.writeLine("Arrays.sort(" + source.value + ", " + comparatorString.value + ");");
1925
+		this.target.writeLine(scope.type(JavaClass.ARRAYS) + ".sort(" + source.value + ", " + comparatorString.value + ");");
1860 1926
 		return source;
1861 1927
 	}
1862 1928
 
@@ -1864,7 +1930,7 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1864 1930
 	public ExpressionString copy(Expression value) {
1865 1931
 		Expression target = duplicable(value);
1866 1932
 		ExpressionString source = target.accept(this);
1867
-		return new ExpressionString("Arrays.copyOf(" + source.value + ", " + source.value + ".length)", JavaOperator.CALL);
1933
+		return new ExpressionString(scope.type(JavaClass.ARRAYS) + ".copyOf(" + source.value + ", " + source.value + ".length)", JavaOperator.CALL);
1868 1934
 	}
1869 1935
 
1870 1936
 	@Override
@@ -1881,4 +1947,32 @@ public class JavaSourceExpressionFormatter implements ExpressionVisitor<Expressi
1881 1947
 			+ targetOffset.accept(this) + ", "
1882 1948
 			+ length.accept(this) + ")", JavaOperator.CALL);
1883 1949
 	}
1950
+
1951
+	@Override
1952
+	public ExpressionString stringToAscii(Expression value) {
1953
+		String standardCharsets = scope.type(STANDARD_CHARSETS);
1954
+		return value.accept(this).unaryPostfix(JavaOperator.CALL, ".getBytes(" + standardCharsets + ".US_ASCII)");
1955
+	}
1956
+
1957
+	@Override
1958
+	public ExpressionString stringToUTF8(Expression value) {
1959
+		String standardCharsets = scope.type(STANDARD_CHARSETS);
1960
+		return value.accept(this).unaryPostfix(JavaOperator.CALL, ".getBytes(" + standardCharsets + ".UTF_8)");
1961
+	}
1962
+
1963
+	@Override
1964
+	public ExpressionString bytesAsciiToString(Expression value) {
1965
+		String standardCharsets = scope.type(STANDARD_CHARSETS);
1966
+		return new ExpressionString(
1967
+				"new String(" + value.accept(this).value + ", " + standardCharsets + ".US_ASCII)",
1968
+				JavaOperator.NEW);
1969
+	}
1970
+
1971
+	@Override
1972
+	public ExpressionString bytesUTF8ToString(Expression value) {
1973
+		String standardCharsets = scope.type(STANDARD_CHARSETS);
1974
+		return new ExpressionString(
1975
+				"new String(" + value.accept(this).value + ", " + standardCharsets + ".UTF_8)",
1976
+				JavaOperator.NEW);
1977
+	}
1884 1978
 }

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

@@ -35,7 +35,10 @@ public class JavaSourceImporter {
35 35
 	}
36 36
 	
37 37
 	public String importType(JavaClass cls) {
38
-		if (imports.containsKey(cls.outer.getName())) {
38
+		if (cls == null)
39
+			throw new NullPointerException();
40
+		
41
+		if (cls.outer != null && imports.containsKey(cls.outer.getName())) {
39 42
 			JavaClass imported = imports.get(cls.outer.getName());
40 43
 			usedImports.add(imported);
41 44
 			return imported.fullName.equals(cls.outer.fullName) ? cls.getName() : cls.fullName;

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

@@ -5,7 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.javasource;
7 7
 
8
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
8
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
9 9
 import org.openzen.zenscript.codemodel.generic.GenericParameterBoundVisitor;
10 10
 import org.openzen.zenscript.codemodel.generic.ParameterSuperBound;
11 11
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
@@ -32,7 +32,7 @@ public class JavaSourceUtils {
32 32
 			output.append(typeParameter.name);
33 33
 			
34 34
 			if (typeParameter.bounds.size() > 0) {
35
-				for (GenericParameterBound bound : typeParameter.bounds)
35
+				for (TypeParameterBound bound : typeParameter.bounds)
36 36
 					bound.accept(boundVisitor);
37 37
 			}
38 38
 		}
@@ -59,7 +59,7 @@ public class JavaSourceUtils {
59 59
 				output.append(typeParameter.name);
60 60
 
61 61
 				if (typeParameter.bounds.size() > 0) {
62
-					for (GenericParameterBound bound : typeParameter.bounds)
62
+					for (TypeParameterBound bound : typeParameter.bounds)
63 63
 						bound.accept(boundVisitor);
64 64
 				}
65 65
 			}
@@ -75,7 +75,7 @@ public class JavaSourceUtils {
75 75
 				output.append(typeParameter.name);
76 76
 
77 77
 				if (typeParameter.bounds.size() > 0) {
78
-					for (GenericParameterBound bound : typeParameter.bounds)
78
+					for (TypeParameterBound bound : typeParameter.bounds)
79 79
 						bound.accept(boundVisitor);
80 80
 				}
81 81
 			}

+ 3
- 2
Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java View File

@@ -19,8 +19,9 @@ public enum ZSTokenType implements TokenType {
19 19
 	T_WHITESPACE_CARRIAGE_RETURN(true, "\r", "\r"),
20 20
 	T_IDENTIFIER("@?[a-zA-Z_][a-zA-Z_0-9]*"),
21 21
 	T_LOCAL_IDENTIFIER("$[a-zA-Z_][a-zA-Z_0-9]*"),
22
-	T_FLOAT("\\-?(0|[1-9][0-9]*)\\.[0-9]+([eE][\\+\\-]?[0-9]+)?"),
23
-	T_INT("\\-?(0|[1-9][0-9]*)"),
22
+	T_FLOAT("\\-?(0|[1-9][0-9]*)\\.[0-9]+([eE][\\+\\-]?[0-9]+)?[a-zA-Z_]"),
23
+	T_INT("\\-?(0|[1-9][0-9_]*)[a-zA-Z_]*"),
24
+	T_PREFIXED_INT("\\-?(0b|0x|0o|0B|0X|0O)(0|[1-9a-fA-F][0-9a-fA-F_]*)(u|U|l|L|ul|UL)?"),
24 25
 	T_STRING_SQ("\"([^\"\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\""),
25 26
 	T_STRING_DQ("\'([^\'\\\\\\n]|\\\\([\'\"\\\\/bfnrt&]|u[0-9a-fA-F]{4}))*\'"),
26 27
 	T_AOPEN("\\{", "{"),

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

@@ -93,7 +93,7 @@ public class ParsedFile {
93 93
 		}
94 94
 		
95 95
 		if (failed)
96
-			return new SemanticModule(name, dependencies, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.compilationUnit, expansions, registry.getAnnotations());
96
+			return new SemanticModule(name, pkg.module, dependencies, SemanticModule.State.INVALID, rootPackage, pkg.getPackage(), definitions, Collections.emptyList(), registry.compilationUnit, expansions, registry.getAnnotations());
97 97
 		
98 98
 		// scripts will store all the script blocks encountered in the files
99 99
 		PrecompilationState precompiler = new PrecompilationState();
@@ -114,7 +114,7 @@ public class ParsedFile {
114 114
 			}
115 115
 		}
116 116
 		
117
-		return new SemanticModule(name, dependencies, SemanticModule.State.ASSEMBLED, rootPackage, pkg.getPackage(), definitions, scripts, registry.compilationUnit, expansions, registry.getAnnotations());
117
+		return new SemanticModule(name, pkg.module, dependencies, SemanticModule.State.ASSEMBLED, rootPackage, pkg.getPackage(), definitions, scripts, registry.compilationUnit, expansions, registry.getAnnotations());
118 118
 	}
119 119
 	
120 120
 	public static ParsedFile parse(CompilingPackage compilingPackage, BracketExpressionParser bracketParser, File file) throws IOException {

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java View File

@@ -50,7 +50,7 @@ public class ParsedAlias extends ParsedDefinition {
50 50
 		this.parameters = parameters;
51 51
 		this.type = type;
52 52
 		
53
-		compiled = new AliasDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
53
+		compiled = new AliasDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
54 54
 		
55 55
 		if (parameters != null && parameters.size() > 0) {
56 56
 			TypeParameter[] typeParameters = new TypeParameter[parameters.size()];

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java View File

@@ -51,7 +51,7 @@ public class ParsedClass extends BaseParsedDefinition {
51 51
 		this.parameters = parameters;
52 52
 		this.superclass = superclass;
53 53
 		
54
-		compiled = new ClassDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
54
+		compiled = new ClassDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
55 55
 		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(parameters));
56 56
 	}
57 57
 

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java View File

@@ -55,7 +55,7 @@ public class ParsedEnum extends BaseParsedDefinition {
55 55
 	public ParsedEnum(CompilingPackage pkg, CodePosition position, int modifiers, ParsedAnnotation[] annotations, String name, HighLevelDefinition outerDefinition) {
56 56
 		super(position, modifiers, pkg, annotations);
57 57
 		
58
-		compiled = new EnumDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
58
+		compiled = new EnumDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
59 59
 	}
60 60
 	
61 61
 	public void addEnumValue(ParsedEnumConstant value) {

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java View File

@@ -46,7 +46,7 @@ public class ParsedExpansion extends BaseParsedDefinition {
46 46
 		this.parameters = genericParameters;
47 47
 		this.target = target;
48 48
 		
49
-		compiled = new ExpansionDefinition(position, pkg.getPackage(), modifiers, outerDefinition);
49
+		compiled = new ExpansionDefinition(position, pkg.module, pkg.getPackage(), modifiers, outerDefinition);
50 50
 		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(genericParameters));
51 51
 	}
52 52
 	

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java View File

@@ -46,7 +46,7 @@ public class ParsedFunction extends ParsedDefinition {
46 46
 		this.header = header;
47 47
 		this.body = body;
48 48
 		
49
-		compiled = new FunctionDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
49
+		compiled = new FunctionDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
50 50
 	}
51 51
 
52 52
 	@Override

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedGenericBound.java View File

@@ -6,12 +6,12 @@
6 6
 package org.openzen.zenscript.parser.definitions;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
9
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
10 10
 
11 11
 /**
12 12
  *
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public abstract class ParsedGenericBound {
16
-	public abstract GenericParameterBound compile(TypeResolutionContext context);
16
+	public abstract TypeParameterBound compile(TypeResolutionContext context);
17 17
 }

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java View File

@@ -55,7 +55,7 @@ public class ParsedInterface extends BaseParsedDefinition {
55 55
 		this.typeParameters = typeParameters;
56 56
 		this.superInterfaces = superInterfaces;
57 57
 		
58
-		compiled = new InterfaceDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
58
+		compiled = new InterfaceDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
59 59
 		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(typeParameters));
60 60
 	}
61 61
 

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedStruct.java View File

@@ -43,7 +43,7 @@ public class ParsedStruct extends BaseParsedDefinition {
43 43
 		
44 44
 		this.parameters = genericParameters;
45 45
 		
46
-		compiled = new StructDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
46
+		compiled = new StructDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
47 47
 		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(genericParameters));
48 48
 	}
49 49
 

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedSuperBound.java View File

@@ -6,7 +6,7 @@
6 6
 package org.openzen.zenscript.parser.definitions;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
9
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
10 10
 import org.openzen.zenscript.codemodel.generic.ParameterSuperBound;
11 11
 import org.openzen.zenscript.parser.type.IParsedType;
12 12
 
@@ -22,7 +22,7 @@ public class ParsedSuperBound extends ParsedGenericBound {
22 22
 	}
23 23
 
24 24
 	@Override
25
-	public GenericParameterBound compile(TypeResolutionContext context) {
25
+	public TypeParameterBound compile(TypeResolutionContext context) {
26 26
 		return new ParameterSuperBound(type.compile(context));
27 27
 	}
28 28
 }

+ 2
- 2
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedTypeBound.java View File

@@ -7,7 +7,7 @@ package org.openzen.zenscript.parser.definitions;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
10
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
10
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
11 11
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
12 12
 import org.openzen.zenscript.parser.type.IParsedType;
13 13
 
@@ -25,7 +25,7 @@ public class ParsedTypeBound extends ParsedGenericBound {
25 25
 	}
26 26
 
27 27
 	@Override
28
-	public GenericParameterBound compile(TypeResolutionContext context) {
28
+	public TypeParameterBound compile(TypeResolutionContext context) {
29 29
 		return new ParameterTypeBound(position, type.compile(context));
30 30
 	}
31 31
 }

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedVariant.java View File

@@ -65,7 +65,7 @@ public class ParsedVariant extends BaseParsedDefinition {
65 65
 		super(position, modifiers, pkg, annotations);
66 66
 		
67 67
 		this.typeParameters = typeParameters;
68
-		compiled = new VariantDefinition(position, pkg.getPackage(), name, modifiers, outerDefinition);
68
+		compiled = new VariantDefinition(position, pkg.module, pkg.getPackage(), name, modifiers, outerDefinition);
69 69
 		compiled.setTypeParameters(ParsedTypeParameter.getCompiled(typeParameters));
70 70
 	}
71 71
 	

+ 4
- 3
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java View File

@@ -426,17 +426,18 @@ public abstract class ParsedExpression {
426 426
 	private static ParsedExpression readPrimaryExpression(CodePosition position, ZSTokenParser parser, ParsingOptions options) {
427 427
 		switch (parser.peek().getType()) {
428 428
 			case T_INT:
429
-				return new ParsedExpressionInt(position, Long.parseLong(parser.next().content));
429
+				return new ParsedExpressionInt(position, parser.next().content);
430
+			case T_PREFIXED_INT:
431
+				return ParsedExpressionInt.parsePrefixed(position, parser.next().content);
430 432
 			case T_FLOAT:
431 433
 				return new ParsedExpressionFloat(
432 434
 						position,
433
-						Double.parseDouble(parser.next().content));
435
+						parser.next().content);
434 436
 			case T_STRING_SQ:
435 437
 			case T_STRING_DQ:
436 438
 				return new ParsedExpressionString(
437 439
 						position,
438 440
 						StringExpansion.unescape(parser.next().content).orElse(error -> {
439
-							
440 441
 							return "INVALID_STRING";
441 442
 						}));
442 443
 			case T_IDENTIFIER: {

+ 53
- 14
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFloat.java View File

@@ -5,16 +5,19 @@
5 5
  */
6 6
 package org.openzen.zenscript.parser.expression;
7 7
 
8
+import java.util.Collections;
8 9
 import org.openzen.zencode.shared.CodePosition;
9 10
 import org.openzen.zencode.shared.CompileException;
10 11
 import org.openzen.zencode.shared.CompileExceptionCode;
12
+import org.openzen.zenscript.codemodel.expression.CallArguments;
11 13
 import org.openzen.zenscript.codemodel.expression.ConstantDoubleExpression;
12 14
 import org.openzen.zenscript.codemodel.expression.ConstantFloatExpression;
15
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
13 16
 import org.openzen.zenscript.codemodel.partial.IPartialExpression;
14 17
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
15 18
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 19
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
17
-import org.openzen.zenscript.parser.PrecompilationState;
20
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 21
 
19 22
 /**
20 23
  *
@@ -22,11 +25,24 @@ import org.openzen.zenscript.parser.PrecompilationState;
22 25
  */
23 26
 public class ParsedExpressionFloat extends ParsedExpression {
24 27
 	public final double value;
28
+	public final String suffix;
25 29
 	
26
-	public ParsedExpressionFloat(CodePosition position, double value) {
30
+	public ParsedExpressionFloat(CodePosition position, String value) {
31
+		super(position);
32
+		
33
+		int split = value.length();
34
+		while (isLetter(value.charAt(split - 1)))
35
+			split--;
36
+		
37
+		this.value = Long.parseLong(value.substring(0, split));
38
+		suffix = value.substring(split);
39
+	}
40
+	
41
+	private ParsedExpressionFloat(CodePosition position, double value) {
27 42
 		super(position);
28 43
 		
29 44
 		this.value = value;
45
+		this.suffix = "";
30 46
 	}
31 47
 
32 48
 	@Override
@@ -34,26 +50,49 @@ public class ParsedExpressionFloat extends ParsedExpression {
34 50
 		if (scope.hints.isEmpty())
35 51
 			return new ConstantDoubleExpression(position, value);
36 52
 		
53
+		if (suffix.equals("f") || suffix.equals("F"))
54
+			return new ConstantFloatExpression(position, (float)value);
55
+		if (suffix.equals("d") || suffix.equals("D"))
56
+			return new ConstantDoubleExpression(position, value);
57
+		
37 58
 		for (ITypeID hint : scope.hints) {
38
-			if (hint == BasicTypeID.DOUBLE)
39
-				return new ConstantDoubleExpression(position, value);
40
-			else if (hint == BasicTypeID.FLOAT)
41
-				return new ConstantFloatExpression(position, (float) value);
59
+			if (suffix.isEmpty()) {
60
+				if (hint == BasicTypeID.DOUBLE)
61
+					return new ConstantDoubleExpression(position, value);
62
+				else if (hint == BasicTypeID.FLOAT)
63
+					return new ConstantFloatExpression(position, (float) value);
64
+			} else {
65
+				TypeMembers members = scope.getTypeMembers(hint);
66
+				FunctionalMemberRef method = members.getOrCreateGroup(suffix, true).getStaticMethod(1, hint);
67
+				if (method != null) {
68
+					ParsedCallArguments parsedArguments = new ParsedCallArguments(Collections.emptyList(), Collections.singletonList(new ParsedExpressionFloat(position, value)));
69
+					CallArguments arguments = parsedArguments.compileCall(position, scope, ITypeID.NONE, method.getHeader());
70
+					method.callStatic(position, hint, method.getHeader(), arguments, scope);
71
+				}
72
+			}
42 73
 		}
43 74
 		
44
-		StringBuilder types = new StringBuilder();
45
-		for (int i = 0; i < scope.hints.size(); i++) {
46
-			if (i > 0)
47
-				types.append(", ");
48
-			
49
-			types.append(scope.hints.get(i).toString());
75
+		if (suffix.isEmpty()) {
76
+			StringBuilder types = new StringBuilder();
77
+			for (int i = 0; i < scope.hints.size(); i++) {
78
+				if (i > 0)
79
+					types.append(", ");
80
+
81
+				types.append(scope.hints.get(i).toString());
82
+			}
83
+
84
+			throw new CompileException(position, CompileExceptionCode.INVALID_CAST, "Cannot cast a floating-point value to any of these types: " + types);
85
+		} else {
86
+			throw new CompileException(position, CompileExceptionCode.INVALID_SUFFIX, "Invalid suffix: " + suffix);
50 87
 		}
51
-		
52
-		throw new CompileException(position, CompileExceptionCode.INVALID_CAST, "Cannot cast a floating-point value to any of these types: " + types);
53 88
 	}
54 89
 
55 90
 	@Override
56 91
 	public boolean hasStrongType() {
57 92
 		return false;
58 93
 	}
94
+	
95
+	private static boolean isLetter(char c) {
96
+		return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
97
+	}
59 98
 }

+ 119
- 10
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionInt.java View File

@@ -5,9 +5,11 @@
5 5
  */
6 6
 package org.openzen.zenscript.parser.expression;
7 7
 
8
+import java.util.Collections;
8 9
 import org.openzen.zencode.shared.CodePosition;
9 10
 import org.openzen.zencode.shared.CompileException;
10 11
 import org.openzen.zencode.shared.CompileExceptionCode;
12
+import org.openzen.zenscript.codemodel.expression.CallArguments;
11 13
 import org.openzen.zenscript.codemodel.expression.ConstantByteExpression;
12 14
 import org.openzen.zenscript.codemodel.expression.ConstantCharExpression;
13 15
 import org.openzen.zenscript.codemodel.expression.ConstantIntExpression;
@@ -21,58 +23,161 @@ import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
21 23
 import org.openzen.zenscript.codemodel.expression.Expression;
22 24
 import org.openzen.zenscript.codemodel.expression.switchvalue.IntSwitchValue;
23 25
 import org.openzen.zenscript.codemodel.expression.switchvalue.SwitchValue;
26
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
24 27
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
25 28
 import org.openzen.zenscript.codemodel.type.ITypeID;
26 29
 import org.openzen.zenscript.codemodel.scope.ExpressionScope;
27
-import org.openzen.zenscript.parser.PrecompilationState;
30
+import org.openzen.zenscript.codemodel.type.member.TypeMembers;
28 31
 
29 32
 /**
30 33
  *
31 34
  * @author Hoofdgebruiker
32 35
  */
33 36
 public class ParsedExpressionInt extends ParsedExpression {
37
+	public static ParsedExpressionInt parsePrefixed(CodePosition position, String value) {
38
+		boolean negative = value.startsWith("-");
39
+		if (negative)
40
+			value = value.substring(1);
41
+		
42
+		String suffix = "";
43
+		if (value.endsWith("u") || value.endsWith("l") || value.endsWith("U") || value.endsWith("L")) {
44
+			suffix = value.substring(value.length() - 1);
45
+			value = value.substring(0, value.length() - 1);
46
+		} else if (value.endsWith("ul") || value.endsWith("UL")) {
47
+			suffix = value.substring(value.length() - 2);
48
+			value = value.substring(0, value.length() - 2);
49
+		}
50
+		
51
+		value = value.toLowerCase();
52
+		
53
+		long parsed = 0;
54
+		if (value.startsWith("0x")) {
55
+			for (char c : value.substring(2).toCharArray()) {
56
+				if (c >= '0' && c <= '9')
57
+					parsed = parsed * 16 + (c - '0');
58
+				else if (c >= 'a' && c <= 'f')
59
+					parsed = parsed * 16 + 10 + (c - 'a');
60
+				else if (c != '_')
61
+					throw new NumberFormatException("Invalid number: " + value);
62
+			}
63
+		} else if (value.startsWith("0b")) {
64
+			for (char c : value.substring(2).toCharArray()) {
65
+				if (c == '0')
66
+					parsed = parsed * 2;
67
+				else if (c == '1')
68
+					parsed = parsed * 2 + 1;
69
+				else if (c != '_')
70
+					throw new NumberFormatException("Invalid number: " + value);
71
+			}
72
+		} else if (value.startsWith("0o")) {
73
+			for (char c : value.substring(2).toCharArray()) {
74
+				if (c >= '0' && c <= '7')
75
+					parsed = parsed * 8 + c - '0';
76
+				else if (c != '_')
77
+					throw new NumberFormatException("Invalid number: " + value);
78
+			}
79
+		} else {
80
+			throw new NumberFormatException("Invalid number: " + value);
81
+		}
82
+		
83
+		return new ParsedExpressionInt(position, negative, negative ? -parsed : parsed, suffix);
84
+	}
85
+	
86
+	public final boolean negative;
34 87
 	public final long value;
88
+	public final String suffix;
35 89
 	
36
-	public ParsedExpressionInt(CodePosition position, long value) {
90
+	public ParsedExpressionInt(CodePosition position, String value) {
37 91
 		super(position);
38 92
 		
93
+		int split = value.length();
94
+		while (isLetter(value.charAt(split - 1)))
95
+			split--;
96
+		
97
+		negative = value.charAt(0) == '-';
98
+		this.value = Long.parseLong(value.substring(0, split));
99
+		suffix = value.substring(split);
100
+	}
101
+	
102
+	private ParsedExpressionInt(CodePosition position, boolean negative, long value, String suffix) {
103
+		super(position);
104
+		
105
+		this.negative = negative;
39 106
 		this.value = value;
107
+		this.suffix = suffix;
40 108
 	}
41
-
109
+	
42 110
 	@Override
43 111
 	public Expression compile(ExpressionScope scope) {
112
+		if (suffix.equals("L") || suffix.equals("l"))
113
+			return new ConstantLongExpression(position, value);
114
+		if (suffix.equals("UL") || suffix.equals("ul"))
115
+			return new ConstantULongExpression(position, value);
116
+		if (suffix.equals("U") || suffix.equals("u"))
117
+			return new ConstantUIntExpression(position, (int)value);
118
+		
44 119
 		for (ITypeID hint : scope.hints) {
45
-			if (hint instanceof BasicTypeID) {
120
+			if (suffix.isEmpty() && (hint instanceof BasicTypeID)) {
46 121
 				switch ((BasicTypeID) hint) {
47 122
 					case SBYTE:
48 123
 						return new ConstantSByteExpression(position, (byte) value);
49 124
 					case BYTE:
50
-						return new ConstantByteExpression(position, (byte) value);
125
+						if (negative)
126
+							break;
127
+						
128
+						return new ConstantByteExpression(position, (int)(value & 0xFF));
51 129
 					case SHORT:
52 130
 						return new ConstantShortExpression(position, (short) value);
53 131
 					case USHORT:
54
-						return new ConstantUShortExpression(position, (short) value);
132
+						if (negative)
133
+							break;
134
+						
135
+						return new ConstantUShortExpression(position, (int)(value & 0xFFFF));
55 136
 					case INT:
56 137
 						return new ConstantIntExpression(position, (int) value);
57 138
 					case UINT:
139
+						if (negative)
140
+							break;
141
+						
58 142
 						return new ConstantUIntExpression(position, (int) value);
59 143
 					case LONG:
60 144
 						return new ConstantLongExpression(position, value);
61 145
 					case ULONG:
146
+						if (negative)
147
+							break;
148
+						
62 149
 						return new ConstantULongExpression(position, value);
63 150
 					case USIZE:
151
+						if (negative)
152
+							break;
153
+						
64 154
 						return new ConstantUSizeExpression(position, value);
65 155
 					case CHAR:
156
+						if (negative)
157
+							break;
158
+						
66 159
 						return new ConstantCharExpression(position, (char) value);
67 160
 					default:
68 161
 				}
162
+			} else if (!suffix.isEmpty()) {
163
+				TypeMembers members = scope.getTypeMembers(hint);
164
+				FunctionalMemberRef method = members.getOrCreateGroup(suffix, true).getStaticMethod(1, hint);
165
+				if (method != null) {
166
+					ParsedCallArguments parsedArguments = new ParsedCallArguments(Collections.emptyList(), Collections.singletonList(new ParsedExpressionInt(position, negative, value, "")));
167
+					CallArguments arguments = parsedArguments.compileCall(position, scope, ITypeID.NONE, method.getHeader());
168
+					method.callStatic(position, hint, method.getHeader(), arguments, scope);
169
+				}
69 170
 			}
70 171
 		}
71 172
 		
72
-		if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE)
73
-			return new ConstantIntExpression(position, (int) value);
74
-		else
75
-			return new ConstantLongExpression(position, value);
173
+		if (suffix.isEmpty()) {
174
+			if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE)
175
+				return new ConstantIntExpression(position, (int) value);
176
+			else
177
+				return new ConstantLongExpression(position, value);
178
+		} else {
179
+			throw new CompileException(position, CompileExceptionCode.INVALID_SUFFIX, "Invalid suffix: " + suffix);
180
+		}
76 181
 	}
77 182
 	
78 183
 	@Override
@@ -87,4 +192,8 @@ public class ParsedExpressionInt extends ParsedExpression {
87 192
 	public boolean hasStrongType() {
88 193
 		return false;
89 194
 	}
195
+	
196
+	private static boolean isLetter(char c) {
197
+		return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
198
+	}
90 199
 }

+ 1
- 1
ScriptingExample/build.gradle View File

@@ -18,5 +18,5 @@ dependencies {
18 18
 	compile project(':JavaBytecodeCompiler')
19 19
 	compile project(':JavaShared')
20 20
 	compile project(':CodeFormatter')
21
-//	compile project(':ScriptingHost')
21
+    //compile project(':ScriptingHost')
22 22
 }

+ 5
- 3
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java View File

@@ -14,6 +14,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
14 14
 import org.openzen.zenscript.codemodel.FunctionParameter;
15 15
 import org.openzen.zenscript.codemodel.GenericMapper;
16 16
 import org.openzen.zenscript.codemodel.Modifiers;
17
+import org.openzen.zenscript.codemodel.Module;
17 18
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
18 19
 import org.openzen.zenscript.codemodel.definition.ClassDefinition;
19 20
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
@@ -59,7 +60,7 @@ public class GlobalRegistry {
59 60
 			// eg. package my.package with a class MyClass with a single native method test() returning a string
60 61
 			// the visitors can then during compilation check if a method is an instance of NativeMethodMember and treat it accordingly
61 62
 			ZSPackage packageMyPackage = rootPackage.getOrCreatePackage("my").getOrCreatePackage("test");
62
-			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, packageMyPackage, "MyClass", Modifiers.PUBLIC, null);
63
+			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, MODULE, packageMyPackage, "MyClass", Modifiers.PUBLIC, null);
63 64
 			JavaClass myClassInfo = new JavaClass("my.test", "MyClass", JavaClass.Kind.CLASS);
64 65
 			
65 66
 			MethodMember member = new MethodMember(CodePosition.NATIVE, myClassDefinition, Modifiers.PUBLIC, "test", new FunctionHeader(BasicTypeID.STRING), null);
@@ -87,8 +88,9 @@ public class GlobalRegistry {
87 88
 		return globals;
88 89
 	}
89 90
 	
90
-	private final ClassDefinition PRINTSTREAM = new ClassDefinition(CodePosition.NATIVE, javaIo, "PrintStream", Modifiers.EXPORT);
91
-	private final ClassDefinition SYSTEM = new ClassDefinition(CodePosition.NATIVE, javaLang, "System", Modifiers.EXPORT);
91
+	private final Module MODULE = new Module("scriptingExample");
92
+	private final ClassDefinition PRINTSTREAM = new ClassDefinition(CodePosition.NATIVE, MODULE, javaIo, "PrintStream", Modifiers.EXPORT);
93
+	private final ClassDefinition SYSTEM = new ClassDefinition(CodePosition.NATIVE, MODULE, javaLang, "System", Modifiers.EXPORT);
92 94
 	private final MethodMember PRINTSTREAM_PRINTLN = new MethodMember(
93 95
 			CodePosition.NATIVE,
94 96
 			PRINTSTREAM,

+ 6
- 4
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java View File

@@ -11,6 +11,7 @@ import java.util.Optional;
11 11
 import org.openzen.zencode.shared.CodePosition;
12 12
 import org.openzen.zencode.shared.SourceFile;
13 13
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
14
+import org.openzen.zenscript.codemodel.Module;
14 15
 
15 16
 import org.openzen.zenscript.codemodel.ScriptBlock;
16 17
 import org.openzen.zenscript.codemodel.context.CompilingPackage;
@@ -42,17 +43,18 @@ public class Main {
42 43
 		File[] inputFiles = Optional.ofNullable(inputDirectory.listFiles((dir, name) -> name.endsWith(".zs"))).orElseGet(() -> new File[0]);
43 44
 		
44 45
 		ZSPackage pkg = new ZSPackage(null, "");
45
-		CompilingPackage compilingPkg = new CompilingPackage(pkg);
46
+		Module module = new Module("scripts");
47
+		CompilingPackage compilingPkg = new CompilingPackage(pkg, module);
46 48
 		ParsedFile[] parsedFiles = parse(compilingPkg, inputFiles);
47 49
 		
48 50
 		ZSPackage global = new ZSPackage(null, "");
49 51
 		GlobalRegistry registry = new GlobalRegistry(global);
50
-		SemanticModule module = compileSyntaxToSemantic(compilingPkg, parsedFiles, registry);
52
+		SemanticModule semantic = compileSyntaxToSemantic(compilingPkg, parsedFiles, registry);
51 53
 		
52 54
 		//formatFiles(pkg, module);
53 55
 		
54
-		if (module.isValid()) {
55
-			JavaModule javaModule = compileSemanticToJava(module);
56
+		if (semantic.isValid()) {
57
+			JavaModule javaModule = compileSemanticToJava(semantic);
56 58
 			javaModule.execute();
57 59
 		} else {
58 60
 			System.out.println("There were compilation errors");

+ 407
- 0
Shared/src/main/java/compactio/CompactBytesDataInput.java View File

@@ -0,0 +1,407 @@
1
+package compactio;
2
+
3
+import java.nio.charset.StandardCharsets;
4
+import java.util.Arrays;
5
+
6
+public final class CompactBytesDataInput implements CompactDataInput, AutoCloseable {
7
+    private static final int P6 = 1 << 6;
8
+    private static final int P7 = 1 << 7;
9
+    private static final int P13 = 1 << 13;
10
+    private static final int P14 = 1 << 14;
11
+    private static final int P20 = 1 << 20;
12
+    private static final int P21 = 1 << 21;
13
+    private static final int P27 = 1 << 27;
14
+    private static final int P28 = 1 << 28;
15
+    private static final long P34 = 1L << 34;
16
+    private static final long P35 = 1L << 35;
17
+    private static final long P41 = 1L << 41;
18
+    private static final long P42 = 1L << 42;
19
+    private static final long P48 = 1L << 48;
20
+    private static final long P49 = 1L << 49;
21
+    private static final long P55 = 1L << 55;
22
+    private static final long P56 = 1L << 56;
23
+    private final byte[] data;
24
+    private int offset;
25
+    
26
+    public CompactBytesDataInput(byte[] data) {
27
+        this.data = data;
28
+        this.offset = 0;
29
+    }
30
+    
31
+    public CompactBytesDataInput(byte[] data, int offset) {
32
+        this.data = data;
33
+        this.offset = offset;
34
+    }
35
+    
36
+    @Override
37
+    public void close() {
38
+    }
39
+    
40
+    @Override
41
+    public boolean readBool() {
42
+        return this.readByte() != (byte)0;
43
+    }
44
+    
45
+    @Override
46
+    public byte readByte() {
47
+        return (byte)(data[offset++]);
48
+    }
49
+    
50
+    @Override
51
+    public int readSByte() {
52
+        return data[offset++];
53
+    }
54
+    
55
+    @Override
56
+    public short readShort() {
57
+        int b0 = data[offset++] & 0xFF;
58
+        int b1 = data[offset++] & 0xFF;
59
+        return (short)(b0 << 8 | b1);
60
+    }
61
+    
62
+    @Override
63
+    public int readUShort() {
64
+        return this.readShort();
65
+    }
66
+    
67
+    @Override
68
+    public int readInt() {
69
+        int b0 = data[offset++] & 0xFF;
70
+        int b1 = data[offset++] & 0xFF;
71
+        int b2 = data[offset++] & 0xFF;
72
+        int b3 = data[offset++] & 0xFF;
73
+        return b0 << 24 | b1 << 16 | b2 << 8 | b3;
74
+    }
75
+    
76
+    @Override
77
+    public int readUInt() {
78
+        return this.readInt();
79
+    }
80
+    
81
+    @Override
82
+    public long readLong() {
83
+        long i0 = (long)(this.readUInt());
84
+        long i1 = (long)(this.readUInt());
85
+        return i0 << 32 | i1;
86
+    }
87
+    
88
+    @Override
89
+    public long readULong() {
90
+        return this.readLong();
91
+    }
92
+    
93
+    @Override
94
+    public int readVarInt() {
95
+        int value = this.readVarUInt();
96
+        return Integer.compareUnsigned(value & 1, 0) == 0 ? value >>> 1 : -((value >>> 1) + 1);
97
+    }
98
+    
99
+    @Override
100
+    public int readVarUInt() {
101
+        int value = data[offset++] & 0xFF;
102
+        if (Integer.compareUnsigned(value & CompactBytesDataInput.P7, 0) == 0)
103
+            return value;
104
+        value = value & CompactBytesDataInput.P7 - 1 | (data[offset++] & 0xFF) << 7;
105
+        if (Integer.compareUnsigned(value & CompactBytesDataInput.P14, 0) == 0)
106
+            return value;
107
+        value = value & CompactBytesDataInput.P14 - 1 | (data[offset++] & 0xFF) << 14;
108
+        if (Integer.compareUnsigned(value & CompactBytesDataInput.P21, 0) == 0)
109
+            return value;
110
+        value = value & CompactBytesDataInput.P21 - 1 | (data[offset++] & 0xFF) << 21;
111
+        if (Integer.compareUnsigned(value & CompactBytesDataInput.P28, 0) == 0)
112
+            return value;
113
+        return value & CompactBytesDataInput.P28 - 1 | (data[offset++] & 0xFF) << 28;
114
+    }
115
+    
116
+    @Override
117
+    public long readVarLong() {
118
+        long value = this.readVarULong();
119
+        return Long.compareUnsigned(value & 1L, 0L) == 0 ? value >>> 1 : -((value >>> 1) + 1L);
120
+    }
121
+    
122
+    @Override
123
+    public long readVarULong() {
124
+        long value = data[offset++] & 0xFFL;
125
+        if (Long.compareUnsigned(value & (CompactBytesDataInput.P7 & 0xFFFFFFFFL), 0L) == 0)
126
+            return value;
127
+        value = value & (CompactBytesDataInput.P7 - 1 & 0xFFFFFFFFL) | (data[offset++] & 0xFFL) << 7;
128
+        if (Long.compareUnsigned(value & (CompactBytesDataInput.P14 & 0xFFFFFFFFL), 0L) == 0)
129
+            return value;
130
+        value = value & (CompactBytesDataInput.P14 - 1 & 0xFFFFFFFFL) | (data[offset++] & 0xFFL) << 14;
131
+        if (Long.compareUnsigned(value & (CompactBytesDataInput.P21 & 0xFFFFFFFFL), 0L) == 0)
132
+            return value;
133
+        value = value & (CompactBytesDataInput.P21 - 1 & 0xFFFFFFFFL) | (data[offset++] & 0xFFL) << 21;
134
+        if (Long.compareUnsigned(value & (CompactBytesDataInput.P28 & 0xFFFFFFFFL), 0L) == 0)
135
+            return value;
136
+        value = value & (CompactBytesDataInput.P28 - 1 & 0xFFFFFFFFL) | (data[offset++] & 0xFFL) << 28;
137
+        if (Long.compareUnsigned(value & CompactBytesDataInput.P35, 0L) == 0)
138
+            return value;
139
+        value = value & CompactBytesDataInput.P35 - 1L | (data[offset++] & 0xFFL) << 35;
140
+        if (Long.compareUnsigned(value & CompactBytesDataInput.P42, 0L) == 0)
141
+            return value;
142
+        value = value & CompactBytesDataInput.P42 - 1L | (data[offset++] & 0xFFL) << 42;
143
+        if (Long.compareUnsigned(value & CompactBytesDataInput.P49, 0L) == 0)
144
+            return value;
145
+        value = value & CompactBytesDataInput.P49 - 1L | (data[offset++] & 0xFFL) << 49;
146
+        if (Long.compareUnsigned(value & CompactBytesDataInput.P56, 0L) == 0)
147
+            return value;
148
+        return value & CompactBytesDataInput.P56 - 1L | (data[offset++] & 0xFFL) << 56;
149
+    }
150
+    
151
+    @Override
152
+    public float readFloat() {
153
+        return Float.intBitsToFloat(this.readUInt());
154
+    }
155
+    
156
+    @Override
157
+    public double readDouble() {
158
+        return Double.longBitsToDouble(this.readULong());
159
+    }
160
+    
161
+    @Override
162
+    public char readChar() {
163
+        return (char)(this.readVarUInt());
164
+    }
165
+    
166
+    @Override
167
+    public String readString() {
168
+        return new String(this.readBytes(), StandardCharsets.UTF_8);
169
+    }
170
+    
171
+    @Override
172
+    public byte[] readBytes() {
173
+        int size = this.readVarUInt();
174
+        return this.readRawBytes(size);
175
+    }
176
+    
177
+    @Override
178
+    public byte[] readRawBytes(int size) {
179
+        byte[] result = Arrays.copyOfRange(data, offset, offset + size);
180
+        this.offset = offset + size;
181
+        return result;
182
+    }
183
+    
184
+    @Override
185
+    public boolean[] readBoolArray() {
186
+        int size = this.readVarUInt();
187
+        boolean[] result = new boolean[size];
188
+        int limitForI = (size + 7) / 8;
189
+        for (int i = 0; i < limitForI; i++) {
190
+            byte bvalue = this.readByte();
191
+            int remainingBits = result.length - 8 * i;
192
+            if (remainingBits > 0)
193
+                result[i * 8 + 0] = (bvalue & (byte)1) > (byte)0;
194
+            if (remainingBits > 1)
195
+                result[i * 8 + 2] = (bvalue & (byte)4) > (byte)0;
196
+            if (remainingBits > 3)
197
+                result[i * 8 + 3] = (bvalue & (byte)8) > (byte)0;
198
+            if (remainingBits > 4)
199
+                result[i * 8 + 4] = (bvalue & (byte)16) > (byte)0;
200
+            if (remainingBits > 5)
201
+                result[i * 8 + 5] = (bvalue & (byte)32) > (byte)0;
202
+            if (remainingBits > 6)
203
+                result[i * 8 + 6] = (bvalue & (byte)64) > (byte)0;
204
+            if (remainingBits > 7)
205
+                result[i * 8 + 7] = (bvalue & (byte)-128) > (byte)0;
206
+        }
207
+        return result;
208
+    }
209
+    
210
+    @Override
211
+    public byte[] readByteArray() {
212
+        return this.readBytes();
213
+    }
214
+    
215
+    @Override
216
+    public byte[] readSByteArray() {
217
+        return this.readBytes();
218
+    }
219
+    
220
+    @Override
221
+    public short[] readShortArray() {
222
+        return this.readShortArrayRaw(this.readVarUInt());
223
+    }
224
+    
225
+    @Override
226
+    public short[] readShortArrayRaw(int length) {
227
+        short[] result = new short[length];
228
+        int limitForI = result.length;
229
+        for (int i = 0; i < limitForI; i++)
230
+            result[i] = this.readShort();
231
+        return result;
232
+    }
233
+    
234
+    @Override
235
+    public short[] readUShortArray() {
236
+        return this.readShortArray();
237
+    }
238
+    
239
+    @Override
240
+    public short[] readUShortArrayRaw(int length) {
241
+        return this.readShortArrayRaw(length);
242
+    }
243
+    
244
+    @Override
245
+    public int[] readVarIntArray() {
246
+        return this.readVarIntArrayRaw(this.readVarUInt());
247
+    }
248
+    
249
+    @Override
250
+    public int[] readVarIntArrayRaw(int length) {
251
+        int[] result = new int[length];
252
+        int limitForI = result.length;
253
+        for (int i = 0; i < limitForI; i++)
254
+            result[i] = this.readVarInt();
255
+        return result;
256
+    }
257
+    
258
+    @Override
259
+    public int[] readVarUIntArray() {
260
+        return this.readVarUIntArrayRaw(this.readVarUInt());
261
+    }
262
+    
263
+    @Override
264
+    public int[] readVarUIntArrayRaw(int length) {
265
+        int[] result = new int[length];
266
+        int limitForI = result.length;
267
+        for (int i = 0; i < limitForI; i++)
268
+            result[i] = this.readVarUInt();
269
+        return result;
270
+    }
271
+    
272
+    @Override
273
+    public int[] readIntArray() {
274
+        return this.readIntArrayRaw(this.readVarUInt());
275
+    }
276
+    
277
+    @Override
278
+    public int[] readIntArrayRaw(int length) {
279
+        int[] result = new int[length];
280
+        int limitForI = result.length;
281
+        for (int i = 0; i < limitForI; i++)
282
+            result[i] = this.readInt();
283
+        return result;
284
+    }
285
+    
286
+    @Override
287
+    public int[] readUIntArray() {
288
+        return this.readUIntArrayRaw(this.readVarUInt());
289
+    }
290
+    
291
+    @Override
292
+    public int[] readUIntArrayRaw(int length) {
293
+        int[] result = new int[length];
294
+        int limitForI = result.length;
295
+        for (int i = 0; i < limitForI; i++)
296
+            result[i] = this.readUInt();
297
+        return result;
298
+    }
299
+    
300
+    @Override
301
+    public long[] readVarLongArray() {
302
+        return this.readVarLongArrayRaw(this.readVarUInt());
303
+    }
304
+    
305
+    @Override
306
+    public long[] readVarLongArrayRaw(int length) {
307
+        long[] result = new long[length];
308
+        int limitForI = result.length;
309
+        for (int i = 0; i < limitForI; i++)
310
+            result[i] = this.readVarLong();
311
+        return result;
312
+    }
313
+    
314
+    @Override
315
+    public long[] readVarULongArray() {
316
+        return this.readVarULongArrayRaw(this.readVarUInt());
317
+    }
318
+    
319
+    @Override
320
+    public long[] readVarULongArrayRaw(int length) {
321
+        long[] result = new long[length];
322
+        int limitForI = result.length;
323
+        for (int i = 0; i < limitForI; i++)
324
+            result[i] = this.readVarULong();
325
+        return result;
326
+    }
327
+    
328
+    @Override
329
+    public long[] readLongArray() {
330
+        return this.readLongArrayRaw(this.readVarUInt());
331
+    }
332
+    
333
+    @Override
334
+    public long[] readLongArrayRaw(int length) {
335
+        long[] result = new long[length];
336
+        int limitForI = result.length;
337
+        for (int i = 0; i < limitForI; i++)
338
+            result[i] = this.readLong();
339
+        return result;
340
+    }
341
+    
342
+    @Override
343
+    public long[] readULongArray() {
344
+        return this.readLongArray();
345
+    }
346
+    
347
+    @Override
348
+    public long[] readULongArrayRaw(int length) {
349
+        return this.readLongArrayRaw(length);
350
+    }
351
+    
352
+    @Override
353
+    public float[] readFloatArray() {
354
+        return this.readFloatArrayRaw(this.readVarUInt());
355
+    }
356
+    
357
+    @Override
358
+    public float[] readFloatArrayRaw(int length) {
359
+        float[] result = new float[length];
360
+        int limitForI = result.length;
361
+        for (int i = 0; i < limitForI; i++)
362
+            result[i] = this.readFloat();
363
+        return result;
364
+    }
365
+    
366
+    @Override
367
+    public double[] readDoubleArray() {
368
+        return this.readDoubleArrayRaw(this.readVarUInt());
369
+    }
370
+    
371
+    @Override
372
+    public double[] readDoubleArrayRaw(int length) {
373
+        double[] result = new double[length];
374
+        int limitForI = length;
375
+        for (int i = 0; i < limitForI; i++)
376
+            result[i] = this.readDouble();
377
+        return result;
378
+    }
379
+    
380
+    @Override
381
+    public String[] readStringArray() {
382
+        return this.readStringArrayRaw(this.readVarUInt());
383
+    }
384
+    
385
+    @Override
386
+    public String[] readStringArrayRaw(int length) {
387
+        String[] result = new String[length];
388
+        int limitForI = result.length;
389
+        for (int i = 0; i < limitForI; i++)
390
+            result[i] = this.readString();
391
+        return result;
392
+    }
393
+    
394
+    @Override
395
+    public void skip(int bytes) {
396
+        this.offset = offset + bytes;
397
+    }
398
+    
399
+    @Override
400
+    public boolean hasMore() {
401
+        return offset < data.length;
402
+    }
403
+    
404
+    public int getOffset() {
405
+        return offset;
406
+    }
407
+}

+ 497
- 0
Shared/src/main/java/compactio/CompactBytesDataOutput.java View File

@@ -0,0 +1,497 @@
1
+package compactio;
2
+
3
+import java.nio.charset.StandardCharsets;
4
+import java.util.Arrays;
5
+
6
+public final class CompactBytesDataOutput implements CompactDataOutput, AutoCloseable {
7
+    private static final int P6 = 1 << 6;
8
+    private static final int P7 = 1 << 7;
9
+    private static final int P13 = 1 << 13;
10
+    private static final int P14 = 1 << 14;
11
+    private static final int P20 = 1 << 20;
12
+    private static final int P21 = 1 << 21;
13
+    private static final int P27 = 1 << 27;
14
+    private static final int P28 = 1 << 28;
15
+    private static final long P34 = 1L << 34;
16
+    private static final long P35 = 1L << 35;
17
+    private static final long P41 = 1L << 41;
18
+    private static final long P42 = 1L << 42;
19
+    private static final long P48 = 1L << 48;
20
+    private static final long P49 = 1L << 49;
21
+    private static final long P55 = 1L << 55;
22
+    private static final long P56 = 1L << 56;
23
+    private byte[] data = new byte[16];
24
+    private int length = 0;
25
+    
26
+    private void reserve(int bytes) {
27
+        while (length + bytes > data.length)
28
+            this.data = Arrays.copyOf(data, 2 * data.length);
29
+    }
30
+    
31
+    public byte[] asByteArray() {
32
+        return Arrays.copyOf(data, length);
33
+    }
34
+    
35
+    @Override
36
+    public void close() {
37
+    }
38
+    
39
+    @Override
40
+    public void writeBool(boolean value) {
41
+        this.writeByte(value ? 1 : 0);
42
+    }
43
+    
44
+    @Override
45
+    public void writeByte(int value) {
46
+        this.reserve(1);
47
+        data[length++] = (byte)value;
48
+    }
49
+    
50
+    @Override
51
+    public void writeSByte(byte value) {
52
+        this.writeByte(value);
53
+    }
54
+    
55
+    @Override
56
+    public void writeShort(short value) {
57
+        this.writeUShort(value);
58
+    }
59
+    
60
+    @Override
61
+    public void writeUShort(int value) {
62
+        this.reserve(2);
63
+        data[length++] = (byte)(value >> 8);
64
+        data[length++] = (byte)value;
65
+    }
66
+    
67
+    @Override
68
+    public void writeInt(int value) {
69
+        this.writeUInt(value);
70
+    }
71
+    
72
+    @Override
73
+    public void writeUInt(int value) {
74
+        this.reserve(4);
75
+        data[length++] = (byte)(value >>> 24);
76
+        data[length++] = (byte)(value >>> 16);
77
+        data[length++] = (byte)(value >>> 8);
78
+        data[length++] = (byte)value;
79
+    }
80
+    
81
+    @Override
82
+    public void writeLong(long value) {
83
+        this.writeULong(value);
84
+    }
85
+    
86
+    @Override
87
+    public void writeULong(long value) {
88
+        this.reserve(8);
89
+        data[length++] = (byte)(value >>> 56);
90
+        data[length++] = (byte)(value >>> 48);
91
+        data[length++] = (byte)(value >>> 40);
92
+        data[length++] = (byte)(value >>> 32);
93
+        data[length++] = (byte)(value >>> 24);
94
+        data[length++] = (byte)(value >>> 16);
95
+        data[length++] = (byte)(value >>> 8);
96
+        data[length++] = (byte)value;
97
+    }
98
+    
99
+    @Override
100
+    public void writeVarInt(int value) {
101
+        this.writeVarUInt(value < 0 ? (1 - value << 1) + 1 : value << 1);
102
+    }
103
+    
104
+    @Override
105
+    public void writeVarUInt(int value) {
106
+        this.reserve(5);
107
+        if (Integer.compareUnsigned(value, CompactBytesDataOutput.P7) < 0) {
108
+            data[length++] = (byte)(value & 127);
109
+        }
110
+        else
111
+            if (Integer.compareUnsigned(value, CompactBytesDataOutput.P14) < 0) {
112
+                data[length++] = (byte)(value & 127 | 128);
113
+                data[length++] = (byte)(value >>> 7 & 127);
114
+            }
115
+            else
116
+                if (Integer.compareUnsigned(value, CompactBytesDataOutput.P21) < 0) {
117
+                    data[length++] = (byte)(value & 127 | 128);
118
+                    data[length++] = (byte)(value >>> 7 & 127 | 128);
119
+                    data[length++] = (byte)(value >>> 14 & 127);
120
+                }
121
+                else
122
+                    if (Integer.compareUnsigned(value, CompactBytesDataOutput.P28) < 0) {
123
+                        data[length++] = (byte)(value & 127 | 128);
124
+                        data[length++] = (byte)(value >>> 7 & 127 | 128);
125
+                        data[length++] = (byte)(value >>> 14 & 127 | 128);
126
+                        data[length++] = (byte)(value >>> 21 & 127);
127
+                    }
128
+                    else {
129
+                        data[length++] = (byte)(value & 127 | 128);
130
+                        data[length++] = (byte)(value >>> 7 & 127 | 128);
131
+                        data[length++] = (byte)(value >>> 14 & 127 | 128);
132
+                        data[length++] = (byte)(value >>> 21 & 127 | 128);
133
+                        data[length++] = (byte)(value >>> 28 & 127);
134
+                    }
135
+    }
136
+    
137
+    @Override
138
+    public void writeVarLong(long value) {
139
+        this.writeVarULong(value < 0L ? (1L - value << 1) + 1L : value << 1);
140
+    }
141
+    
142
+    @Override
143
+    public void writeVarULong(long value) {
144
+        this.reserve(9);
145
+        if (Long.compareUnsigned(value, CompactBytesDataOutput.P7) < 0) {
146
+            data[length++] = (byte)(value & 127L);
147
+        }
148
+        else
149
+            if (Long.compareUnsigned(value, CompactBytesDataOutput.P14) < 0) {
150
+                data[length++] = (byte)(value & 127L | 128L);
151
+                data[length++] = (byte)(value >>> 7 & 127L);
152
+            }
153
+            else
154
+                if (Long.compareUnsigned(value, CompactBytesDataOutput.P21) < 0) {
155
+                    data[length++] = (byte)(value & 127L | 128L);
156
+                    data[length++] = (byte)(value >>> 7 & 127L | 128L);
157
+                    data[length++] = (byte)(value >>> 14 & 127L);
158
+                }
159
+                else
160
+                    if (Long.compareUnsigned(value, CompactBytesDataOutput.P28) < 0) {
161
+                        data[length++] = (byte)(value & 127L | 128L);
162
+                        data[length++] = (byte)(value >>> 7 & 127L | 128L);
163
+                        data[length++] = (byte)(value >>> 14 & 127L | 128L);
164
+                        data[length++] = (byte)(value >>> 21 & 127L);
165
+                    }
166
+                    else
167
+                        if (Long.compareUnsigned(value, CompactBytesDataOutput.P35) < 0) {
168
+                            data[length++] = (byte)(value & 127L | 128L);
169
+                            data[length++] = (byte)(value >>> 7 & 127L | 128L);
170
+                            data[length++] = (byte)(value >>> 14 & 127L | 128L);
171
+                            data[length++] = (byte)(value >>> 21 & 127L | 128L);
172
+                            data[length++] = (byte)(value >>> 28 & 127L);
173
+                        }
174
+                        else
175
+                            if (Long.compareUnsigned(value, CompactBytesDataOutput.P42) < 0) {
176
+                                data[length++] = (byte)(value & 127L | 128L);
177
+                                data[length++] = (byte)(value >>> 7 & 127L | 128L);
178
+                                data[length++] = (byte)(value >>> 14 & 127L | 128L);
179
+                                data[length++] = (byte)(value >>> 21 & 127L | 128L);
180
+                                data[length++] = (byte)(value >>> 28 & 127L | 128L);
181
+                                data[length++] = (byte)(value >>> 35 & 127L);
182
+                            }
183
+                            else
184
+                                if (Long.compareUnsigned(value, CompactBytesDataOutput.P49) < 0) {
185
+                                    data[length++] = (byte)(value & 127L | 128L);
186
+                                    data[length++] = (byte)(value >>> 7 & 127L | 128L);
187
+                                    data[length++] = (byte)(value >>> 14 & 127L | 128L);
188
+                                    data[length++] = (byte)(value >>> 21 & 127L | 128L);
189
+                                    data[length++] = (byte)(value >>> 28 & 127L | 128L);
190
+                                    data[length++] = (byte)(value >>> 35 & 127L | 128L);
191
+                                    data[length++] = (byte)(value >>> 42 & 127L);
192
+                                }
193
+                                else
194
+                                    if (Long.compareUnsigned(value, CompactBytesDataOutput.P56) < 0) {
195
+                                        data[length++] = (byte)(value & 127L | 128L);
196
+                                        data[length++] = (byte)(value >>> 7 & 127L | 128L);
197
+                                        data[length++] = (byte)(value >>> 14 & 127L | 128L);
198
+                                        data[length++] = (byte)(value >>> 21 & 127L | 128L);
199
+                                        data[length++] = (byte)(value >>> 28 & 127L | 128L);
200
+                                        data[length++] = (byte)(value >>> 35 & 127L | 128L);
201
+                                        data[length++] = (byte)(value >>> 42 & 127L | 128L);
202
+                                        data[length++] = (byte)(value >>> 49 & 127L);
203
+                                    }
204
+                                    else {
205
+                                        data[length++] = (byte)(value & 127L | 128L);
206
+                                        data[length++] = (byte)(value >>> 7 & 127L | 128L);
207
+                                        data[length++] = (byte)(value >>> 14 & 127L | 128L);
208
+                                        data[length++] = (byte)(value >>> 21 & 127L | 128L);
209
+                                        data[length++] = (byte)(value >>> 28 & 127L | 128L);
210
+                                        data[length++] = (byte)(value >>> 35 & 127L | 128L);
211
+                                        data[length++] = (byte)(value >>> 42 & 127L | 128L);
212
+                                        data[length++] = (byte)(value >>> 49 & 127L | 128L);
213
+                                        data[length++] = (byte)(value >>> 56);
214
+                                    }
215
+    }
216
+    
217
+    @Override
218
+    public void writeFloat(float value) {
219
+        this.writeUInt(Float.floatToRawIntBits(value));
220
+    }
221
+    
222
+    @Override
223
+    public void writeDouble(double value) {
224
+        this.writeULong(Double.doubleToRawLongBits(value));
225
+    }
226
+    
227
+    @Override
228
+    public void writeChar(char value) {
229
+        this.writeVarUInt(value);
230
+    }
231
+    
232
+    @Override
233
+    public void writeBytes(byte[] data) {
234
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
235
+            throw new AssertionError("Array length cannot exceed uint limit");
236
+        this.writeVarUInt(data.length);
237
+        this.writeRawBytes(data);
238
+    }
239
+    
240
+    @Override
241
+    public void writeBytes(byte[] data, int offset, int length) {
242
+        if (!(Integer.compareUnsigned(length, -1) < 0))
243
+            throw new AssertionError("Array length cannot exceed uint limit");
244
+        this.writeVarUInt(length);
245
+        this.writeRawBytes(data, offset, length);
246
+    }
247
+    
248
+    @Override
249
+    public void writeString(String str) {
250
+        this.writeBytes(str.getBytes(StandardCharsets.UTF_8));
251
+    }
252
+    
253
+    @Override
254
+    public void writeRawBytes(byte[] value) {
255
+        this.reserve(value.length);
256
+        System.arraycopy(value, 0, data, length, value.length);
257
+        this.length = length + value.length;
258
+    }
259
+    
260
+    @Override
261
+    public void writeRawBytes(byte[] value, int offset, int length) {
262
+        this.reserve(value.length);
263
+        System.arraycopy(value, offset, data, this.length, value.length);
264
+        this.length = this.length + length;
265
+    }
266
+    
267
+    @Override
268
+    public void writeBoolArray(boolean[] data) {
269
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
270
+            throw new AssertionError("Array length cannot exceed uint limit");
271
+        this.writeVarUInt(data.length);
272
+        int i = 0;
273
+        while (i < data.length - 7) {
274
+            int bvalue = 0;
275
+            if (data[i + 0])
276
+                bvalue = bvalue | 1;
277
+            if (data[i + 1])
278
+                bvalue = bvalue | 2;
279
+            if (data[i + 2])
280
+                bvalue = bvalue + 4;
281
+            if (data[i + 3])
282
+                bvalue = bvalue + 8;
283
+            if (data[i + 4])
284
+                bvalue = bvalue + 16;
285
+            if (data[i + 5])
286
+                bvalue = bvalue + 32;
287
+            if (data[i + 6])
288
+                bvalue = bvalue + 64;
289
+            if (data[i + 7])
290
+                bvalue = bvalue + 128;
291
+            this.writeByte(bvalue);
292
+            i = i + 8;
293
+        }
294
+        if (i < data.length) {
295
+            int bvalue = 0;
296
+            int limitForOffset = data.length % 7;
297
+            for (int offset = 0; offset < limitForOffset; offset++)
298
+                if (data[i + offset])
299
+                    bvalue = bvalue + (1 << i);
300
+            this.writeByte(bvalue);
301
+        }
302
+    }
303
+    
304
+    @Override
305
+    public void writeByteArray(byte[] data) {
306
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
307
+            throw new AssertionError("Array length cannot exceed uint limit");
308
+        this.writeBytes(data);
309
+    }
310
+    
311
+    @Override
312
+    public void writeSByteArray(byte[] data) {
313
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
314
+            throw new AssertionError("Array length cannot exceed uint limit");
315
+        this.writeBytes(data);
316
+    }
317
+    
318
+    @Override
319
+    public void writeShortArray(short[] data) {
320
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
321
+            throw new AssertionError("Array length cannot exceed uint limit");
322
+        this.writeVarUInt(data.length);
323
+        this.writeShortArrayRaw(data);
324
+    }
325
+    
326
+    @Override
327
+    public void writeShortArrayRaw(short[] data) {
328
+        for (short element : data)
329
+            this.writeShort(element);
330
+    }
331
+    
332
+    @Override
333
+    public void writeUShortArray(short[] data) {
334
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
335
+            throw new AssertionError("Array length cannot exceed uint limit");
336
+        this.writeShortArray(data);
337
+    }
338
+    
339
+    @Override
340
+    public void writeUShortArrayRaw(short[] data) {
341
+        this.writeShortArrayRaw(data);
342
+    }
343
+    
344
+    @Override
345
+    public void writeVarIntArray(int[] data) {
346
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
347
+            throw new AssertionError("Array length cannot exceed uint limit");
348
+        this.writeVarUInt(data.length);
349
+        this.writeVarIntArrayRaw(data);
350
+    }
351
+    
352
+    @Override
353
+    public void writeVarIntArrayRaw(int[] data) {
354
+        for (int element : data)
355
+            this.writeVarInt(element);
356
+    }
357
+    
358
+    @Override
359
+    public void writeVarUIntArray(int[] data) {
360
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
361
+            throw new AssertionError("Array length cannot exceed uint limit");
362
+        this.writeVarUInt(data.length);
363
+        this.writeVarUIntArrayRaw(data);
364
+    }
365
+    
366
+    @Override
367
+    public void writeVarUIntArrayRaw(int[] data) {
368
+        for (int element : data)
369
+            this.writeVarUInt(element);
370
+    }
371
+    
372
+    @Override
373
+    public void writeIntArray(int[] data) {
374
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
375
+            throw new AssertionError("Array length cannot exceed uint limit");
376
+        this.writeVarUInt(data.length);
377
+        this.writeIntArrayRaw(data);
378
+    }
379
+    
380
+    @Override
381
+    public void writeIntArrayRaw(int[] data) {
382
+        for (int element : data)
383
+            this.writeInt(element);
384
+    }
385
+    
386
+    @Override
387
+    public void writeUIntArray(int[] data) {
388
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
389
+            throw new AssertionError("Array length cannot exceed uint limit");
390
+        this.writeIntArray(data);
391
+    }
392
+    
393
+    @Override
394
+    public void writeUIntArrayRaw(int[] data) {
395
+        this.writeIntArrayRaw(data);
396
+    }
397
+    
398
+    @Override
399
+    public void writeVarLongArray(long[] data) {
400
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
401
+            throw new AssertionError("Array length cannot exceed uint limit");
402
+        this.writeVarUInt(data.length);
403
+        this.writeVarLongArrayRaw(data);
404
+    }
405
+    
406
+    @Override
407
+    public void writeVarLongArrayRaw(long[] data) {
408
+        for (long element : data)
409
+            this.writeVarLong(element);
410
+    }
411
+    
412
+    @Override
413
+    public void writeVarULongArray(long[] data) {
414
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
415
+            throw new AssertionError("Array length cannot exceed uint limit");
416
+        this.writeVarUInt(data.length);
417
+        this.writeVarULongArrayRaw(data);
418
+    }
419
+    
420
+    @Override
421
+    public void writeVarULongArrayRaw(long[] data) {
422
+        for (long element : data)
423
+            this.writeVarULong(element);
424
+    }
425
+    
426
+    @Override
427
+    public void writeLongArray(long[] data) {
428
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
429
+            throw new AssertionError("Array length cannot exceed uint limit");
430
+        this.writeVarUInt(data.length);
431
+        this.writeLongArrayRaw(data);
432
+    }
433
+    
434
+    @Override
435
+    public void writeLongArrayRaw(long[] data) {
436
+        for (long element : data)
437
+            this.writeLong(element);
438
+    }
439
+    
440
+    @Override
441
+    public void writeULongArray(long[] data) {
442
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
443
+            throw new AssertionError("Array length cannot exceed uint limit");
444
+        this.writeLongArray(data);
445
+    }
446
+    
447
+    @Override
448
+    public void writeULongArrayRaw(long[] data) {
449
+        this.writeLongArrayRaw(data);
450
+    }
451
+    
452
+    @Override
453
+    public void writeFloatArray(float[] data) {
454
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
455
+            throw new AssertionError("Array length cannot exceed uint limit");
456
+        this.writeVarUInt(data.length);
457
+        this.writeFloatArrayRaw(data);
458
+    }
459
+    
460
+    @Override
461
+    public void writeFloatArrayRaw(float[] data) {
462
+        for (float element : data)
463
+            this.writeFloat(element);
464
+    }
465
+    
466
+    @Override
467
+    public void writeDoubleArray(double[] data) {
468
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
469
+            throw new AssertionError("Array length cannot exceed uint limit");
470
+        this.writeVarUInt(data.length);
471
+        this.writeDoubleArrayRaw(data);
472
+    }
473
+    
474
+    @Override
475
+    public void writeDoubleArrayRaw(double[] data) {
476
+        for (double element : data)
477
+            this.writeDouble(element);
478
+    }
479
+    
480
+    @Override
481
+    public void writeStringArray(String[] data) {
482
+        if (!(Integer.compareUnsigned(data.length, -1) < 0))
483
+            throw new AssertionError("Array length cannot exceed uint limit");
484
+        this.writeVarUInt(data.length);
485
+        this.writeStringArrayRaw(data);
486
+    }
487
+    
488
+    @Override
489
+    public void writeStringArrayRaw(String[] data) {
490
+        for (String element : data)
491
+            this.writeString(element);
492
+    }
493
+    
494
+    @Override
495
+    public void flush() {
496
+    }
497
+}

+ 106
- 0
Shared/src/main/java/compactio/CompactDataInput.java View File

@@ -0,0 +1,106 @@
1
+package compactio;
2
+
3
+public interface CompactDataInput extends AutoCloseable {
4
+    boolean readBool();
5
+    
6
+    byte readByte();
7
+    
8
+    int readSByte();
9
+    
10
+    short readShort();
11
+    
12
+    int readUShort();
13
+    
14
+    int readInt();
15
+    
16
+    int readUInt();
17
+    
18
+    long readLong();
19
+    
20
+    long readULong();
21
+    
22
+    int readVarInt();
23
+    
24
+    int readVarUInt();
25
+    
26
+    long readVarLong();
27
+    
28
+    long readVarULong();
29
+    
30
+    float readFloat();
31
+    
32
+    double readDouble();
33
+    
34
+    char readChar();
35
+    
36
+    String readString();
37
+    
38
+    byte[] readBytes();
39
+    
40
+    byte[] readRawBytes(int length);
41
+    
42
+    boolean[] readBoolArray();
43
+    
44
+    byte[] readByteArray();
45
+    
46
+    byte[] readSByteArray();
47
+    
48
+    short[] readShortArray();
49
+    
50
+    short[] readShortArrayRaw(int length);
51
+    
52
+    short[] readUShortArray();
53
+    
54
+    short[] readUShortArrayRaw(int length);
55
+    
56
+    int[] readVarIntArray();
57
+    
58
+    int[] readVarIntArrayRaw(int length);
59
+    
60
+    int[] readVarUIntArray();
61
+    
62
+    int[] readVarUIntArrayRaw(int length);
63
+    
64
+    int[] readIntArray();
65
+    
66
+    int[] readIntArrayRaw(int length);
67
+    
68
+    int[] readUIntArray();
69
+    
70
+    int[] readUIntArrayRaw(int length);
71
+    
72
+    long[] readVarLongArray();
73
+    
74
+    long[] readVarLongArrayRaw(int length);
75
+    
76
+    long[] readVarULongArray();
77
+    
78
+    long[] readVarULongArrayRaw(int length);
79
+    
80
+    long[] readLongArray();
81
+    
82
+    long[] readLongArrayRaw(int length);
83
+    
84
+    long[] readULongArray();
85
+    
86
+    long[] readULongArrayRaw(int length);
87
+    
88
+    float[] readFloatArray();
89
+    
90
+    float[] readFloatArrayRaw(int length);
91
+    
92
+    double[] readDoubleArray();
93
+    
94
+    double[] readDoubleArrayRaw(int length);
95
+    
96
+    String[] readStringArray();
97
+    
98
+    String[] readStringArrayRaw(int length);
99
+    
100
+    void skip(int bytes);
101
+    
102
+    boolean hasMore();
103
+    
104
+    @Override
105
+    public void close();
106
+}

+ 108
- 0
Shared/src/main/java/compactio/CompactDataOutput.java View File

@@ -0,0 +1,108 @@
1
+package compactio;
2
+
3
+public interface CompactDataOutput extends AutoCloseable {
4
+    void writeBool(boolean value);
5
+    
6
+    void writeByte(int value);
7
+    
8
+    void writeSByte(byte value);
9
+    
10
+    void writeShort(short value);
11
+    
12
+    void writeUShort(int value);
13
+    
14
+    void writeInt(int value);
15
+    
16
+    void writeUInt(int value);
17
+    
18
+    void writeLong(long value);
19
+    
20
+    void writeULong(long value);
21
+    
22
+    void writeVarInt(int value);
23
+    
24
+    void writeVarUInt(int value);
25
+    
26
+    void writeVarLong(long value);
27
+    
28
+    void writeVarULong(long value);
29
+    
30
+    void writeFloat(float value);
31
+    
32
+    void writeDouble(double value);
33
+    
34
+    void writeChar(char value);
35
+    
36
+    void writeString(String value);
37
+    
38
+    void writeBytes(byte[] data);
39
+    
40
+    void writeBytes(byte[] data, int offset, int length);
41
+    
42
+    void writeRawBytes(byte[] value);
43
+    
44
+    void writeRawBytes(byte[] value, int offset, int length);
45
+    
46
+    void writeBoolArray(boolean[] data);
47
+    
48
+    void writeByteArray(byte[] data);
49
+    
50
+    void writeSByteArray(byte[] data);
51
+    
52
+    void writeShortArray(short[] data);
53
+    
54
+    void writeShortArrayRaw(short[] data);
55
+    
56
+    void writeUShortArray(short[] data);
57
+    
58
+    void writeUShortArrayRaw(short[] data);
59
+    
60
+    void writeVarIntArray(int[] data);
61
+    
62
+    void writeVarIntArrayRaw(int[] data);
63
+    
64
+    void writeVarUIntArray(int[] data);
65
+    
66
+    void writeVarUIntArrayRaw(int[] data);
67
+    
68
+    void writeIntArray(int[] data);
69
+    
70
+    void writeIntArrayRaw(int[] data);
71
+    
72
+    void writeUIntArray(int[] data);
73
+    
74
+    void writeUIntArrayRaw(int[] data);
75
+    
76
+    void writeVarLongArray(long[] data);
77
+    
78
+    void writeVarLongArrayRaw(long[] data);
79
+    
80
+    void writeVarULongArray(long[] data);
81
+    
82
+    void writeVarULongArrayRaw(long[] data);
83
+    
84
+    void writeLongArray(long[] data);
85
+    
86
+    void writeLongArrayRaw(long[] data);
87
+    
88
+    void writeULongArray(long[] data);
89
+    
90
+    void writeULongArrayRaw(long[] data);
91
+    
92
+    void writeFloatArray(float[] data);
93
+    
94
+    void writeFloatArrayRaw(float[] data);
95
+    
96
+    void writeDoubleArray(double[] data);
97
+    
98
+    void writeDoubleArrayRaw(double[] data);
99
+    
100
+    void writeStringArray(String[] data);
101
+    
102
+    void writeStringArrayRaw(String[] data);
103
+    
104
+    void flush();
105
+    
106
+    @Override
107
+    public void close();
108
+}

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

@@ -68,5 +68,6 @@ public enum CompileExceptionCode {
68 68
 	INVALID_BRACKET_EXPRESSION,
69 69
 	VARIANT_OPTION_NOT_AN_EXPRESSION,
70 70
 	DUPLICATE_GLOBAL,
71
-	CANNOT_INFER_RETURN_TYPE
71
+	CANNOT_INFER_RETURN_TYPE,
72
+	INVALID_SUFFIX
72 73
 }

+ 6
- 0
Shared/src/main/java/zsynthetic/FunctionUSizeTToBool.java View File

@@ -0,0 +1,6 @@
1
+package zsynthetic;
2
+
3
+@FunctionalInterface
4
+public interface FunctionUSizeTToBool<T> {
5
+    boolean invoke(int index, T value);
6
+}

+ 6
- 0
Shared/src/main/java/zsynthetic/FunctionUSizeTToU.java View File

@@ -0,0 +1,6 @@
1
+package zsynthetic;
2
+
3
+@FunctionalInterface
4
+public interface FunctionUSizeTToU<U, T> {
5
+    U invoke(int index, T value);
6
+}

+ 6
- 0
Shared/src/main/java/zsynthetic/FunctionUSizeTToVoid.java View File

@@ -0,0 +1,6 @@
1
+package zsynthetic;
2
+
3
+@FunctionalInterface
4
+public interface FunctionUSizeTToVoid<T> {
5
+    void invoke(int index, T value);
6
+}

+ 2
- 2
Validator/src/main/java/org/openzen/zenscript/validator/visitors/ValidationUtils.java View File

@@ -13,7 +13,7 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
13 13
 import org.openzen.zenscript.codemodel.FunctionParameter;
14 14
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15 15
 import org.openzen.zenscript.codemodel.Modifiers;
16
-import org.openzen.zenscript.codemodel.generic.GenericParameterBound;
16
+import org.openzen.zenscript.codemodel.generic.TypeParameterBound;
17 17
 import org.openzen.zenscript.codemodel.generic.GenericParameterBoundVisitor;
18 18
 import org.openzen.zenscript.codemodel.generic.ParameterSuperBound;
19 19
 import org.openzen.zenscript.codemodel.generic.ParameterTypeBound;
@@ -178,7 +178,7 @@ public class ValidationUtils {
178 178
 		
179 179
 		for (int i = 0; i < typeParameters.length; i++) {
180 180
 			TypeParameter typeParameter = typeParameters[i];
181
-			for (GenericParameterBound bound : typeParameter.bounds) {
181
+			for (TypeParameterBound bound : typeParameter.bounds) {
182 182
 				// TODO - obtain member cache for validation
183 183
 				/*if (!bound.matches(typeArguments[i])) {
184 184
 					target.logError(

Loading…
Cancel
Save