Browse Source

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

kindlich 4 years ago
parent
commit
85386a9112
No known key found for this signature in database

+ 41
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/FunctionHeader.java View File

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel;
7 7
 
8
-import java.util.Arrays;
9
-import java.util.Map;
8
+import java.util.*;
9
+
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12 12
 import org.openzen.zenscript.codemodel.expression.Expression;
@@ -532,4 +532,43 @@ public class FunctionHeader {
532 532
 	public boolean accepts(int arguments) {
533 533
 		return arguments >= this.minParameters && arguments <= this.maxParameters;
534 534
 	}
535
+    
536
+    @Override
537
+    public boolean equals(Object o) {
538
+        if(this == o)
539
+            return true;
540
+        if(o == null || getClass() != o.getClass())
541
+            return false;
542
+        
543
+        FunctionHeader that = (FunctionHeader) o;
544
+        
545
+        if(minParameters != that.minParameters)
546
+            return false;
547
+        if(maxParameters != that.maxParameters)
548
+            return false;
549
+        if(hasUnknowns != that.hasUnknowns)
550
+            return false;
551
+        if(!Arrays.equals(typeParameters, that.typeParameters))
552
+            return false;
553
+        if(!returnType.equals(that.returnType))
554
+            return false;
555
+        if(!Arrays.equals(parameters, that.parameters))
556
+            return false;
557
+        if(!Objects.equals(thrownType, that.thrownType))
558
+            return false;
559
+        return Objects.equals(storage, that.storage);
560
+    }
561
+    
562
+    @Override
563
+    public int hashCode() {
564
+        int result = Arrays.hashCode(typeParameters);
565
+        result = 31 * result + returnType.hashCode();
566
+        result = 31 * result + Arrays.hashCode(parameters);
567
+        result = 31 * result + (thrownType != null ? thrownType.hashCode() : 0);
568
+        result = 31 * result + (storage != null ? storage.hashCode() : 0);
569
+        result = 31 * result + minParameters;
570
+        result = 31 * result + maxParameters;
571
+        result = 31 * result + (hasUnknowns ? 1 : 0);
572
+        return result;
573
+    }
535 574
 }

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

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.generic;
7 7
 
8
-import java.util.ArrayList;
9
-import java.util.List;
8
+import java.util.*;
9
+
10 10
 import org.openzen.zencode.shared.CodePosition;
11 11
 import org.openzen.zencode.shared.Taggable;
12 12
 import org.openzen.zenscript.codemodel.type.TypeID;
@@ -60,8 +60,32 @@ public class TypeParameter extends Taggable {
60 60
 		}
61 61
 		return result.toString();
62 62
 	}
63
-	
64
-	@Override
63
+    
64
+    @Override
65
+    public boolean equals(Object o) {
66
+        if(this == o)
67
+            return true;
68
+        if(o == null || getClass() != o.getClass())
69
+            return false;
70
+        
71
+        TypeParameter that = (TypeParameter) o;
72
+        
73
+        if(!name.equals(that.name))
74
+            return false;
75
+        if(!Objects.equals(storage, that.storage))
76
+            return false;
77
+        return bounds.equals(that.bounds);
78
+    }
79
+    
80
+    @Override
81
+    public int hashCode() {
82
+        int result = name.hashCode();
83
+        result = 31 * result + (storage != null ? storage.hashCode() : 0);
84
+        result = 31 * result + bounds.hashCode();
85
+        return result;
86
+    }
87
+    
88
+    @Override
65 89
 	public String toString() {
66 90
 		return name + "@" + position.toShortString();
67 91
 	}

+ 29
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ref/FunctionalMemberRef.java View File

@@ -26,6 +26,8 @@ import org.openzen.zenscript.codemodel.type.StoredType;
26 26
 import org.openzen.zenscript.codemodel.type.TypeID;
27 27
 import org.openzen.zenscript.codemodel.type.member.BuiltinID;
28 28
 
29
+import java.util.*;
30
+
29 31
 /**
30 32
  *
31 33
  * @author Hoofdgebruiker
@@ -150,4 +152,31 @@ public class FunctionalMemberRef implements DefinitionMemberRef {
150 152
 	public Expression callStatic(CodePosition position, TypeID target, FunctionHeader instancedHeader, CallArguments arguments, TypeScope scope) {
151 153
 		return new CallStaticExpression(position, target, this, instancedHeader, arguments);
152 154
 	}
155
+    
156
+    @Override
157
+    public boolean equals(Object o) {
158
+        if(this == o)
159
+            return true;
160
+        if(o == null || getClass() != o.getClass())
161
+            return false;
162
+        
163
+        FunctionalMemberRef that = (FunctionalMemberRef) o;
164
+        
165
+        if(!target.equals(that.target))
166
+            return false;
167
+        if(!header.equals(that.header))
168
+            return false;
169
+        if(!type.equals(that.type))
170
+            return false;
171
+        return Objects.equals(mapper, that.mapper);
172
+    }
173
+    
174
+    @Override
175
+    public int hashCode() {
176
+        int result = target.hashCode();
177
+        result = 31 * result + header.hashCode();
178
+        result = 31 * result + type.hashCode();
179
+        result = 31 * result + (mapper != null ? mapper.hashCode() : 0);
180
+        return result;
181
+    }
153 182
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/GenericTypeID.java View File

@@ -116,7 +116,7 @@ public class GenericTypeID implements TypeID {
116 116
 			return false;
117 117
 		}
118 118
 		final GenericTypeID other = (GenericTypeID) obj;
119
-		return this.parameter == other.parameter;
119
+		return this.parameter.equals(other.parameter);
120 120
 	}
121 121
 	
122 122
 	@Override

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/OptionalTypeID.java View File

@@ -124,4 +124,9 @@ public class OptionalTypeID implements TypeID {
124 124
 	public String toString(StorageTag storage) {
125 125
 		return baseType.toString(storage) + '?';
126 126
 	}
127
+    
128
+    @Override
129
+    public boolean isGeneric() {
130
+        return baseType.isGeneric();
131
+    }
127 132
 }

Loading…
Cancel
Save