Quellcode durchsuchen

Fixed duplicate NOT operator on bool.

Stan Hebben vor 6 Jahren
Ursprung
Commit
3c3040a8d9

+ 0
- 91
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/builtin/StringConcatMember.java Datei anzeigen

@@ -1,91 +0,0 @@
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.member.builtin;
7
-
8
-import java.util.Map;
9
-import org.openzen.zenscript.codemodel.CompareType;
10
-import org.openzen.zenscript.codemodel.FunctionHeader;
11
-import org.openzen.zenscript.codemodel.OperatorType;
12
-import org.openzen.zenscript.codemodel.expression.CallArguments;
13
-import org.openzen.zenscript.codemodel.expression.Expression;
14
-import org.openzen.zenscript.codemodel.expression.StringConcatExpression;
15
-import org.openzen.zenscript.codemodel.generic.TypeParameter;
16
-import org.openzen.zenscript.codemodel.member.ICallableMember;
17
-import org.openzen.zenscript.codemodel.member.IDefinitionMember;
18
-import org.openzen.zenscript.codemodel.member.MemberVisitor;
19
-import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
20
-import org.openzen.zenscript.codemodel.type.ITypeID;
21
-import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
22
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
23
-import org.openzen.zenscript.shared.CodePosition;
24
-import org.openzen.zenscript.shared.Taggable;
25
-
26
-/**
27
- *
28
- * @author Hoofdgebruiker
29
- */
30
-public class StringConcatMember extends Taggable implements ICallableMember {
31
-	private final FunctionHeader header;
32
-	
33
-	public StringConcatMember(FunctionHeader header) {
34
-		this.header = header;
35
-	}
36
-	
37
-	@Override
38
-	public boolean isStatic() {
39
-		return false;
40
-	}
41
-
42
-	@Override
43
-	public FunctionHeader getHeader() {
44
-		return header;
45
-	}
46
-
47
-	@Override
48
-	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments) {
49
-		return new StringConcatExpression(position, target, arguments.arguments[0]);
50
-	}
51
-
52
-	@Override
53
-	public Expression callWithComparator(CodePosition position, CompareType operator, Expression target, FunctionHeader instancedHeader, CallArguments arguments) {
54
-		throw new UnsupportedOperationException("Not comparable");
55
-	}
56
-
57
-	@Override
58
-	public Expression callStatic(CodePosition position, FunctionHeader instancedHeader, CallArguments arguments) {
59
-		throw new UnsupportedOperationException("Not static");
60
-	}
61
-
62
-	@Override
63
-	public Expression callStaticWithComparator(CodePosition position, CompareType operator, FunctionHeader instancedHeader, CallArguments arguments) {
64
-		throw new UnsupportedOperationException("Not comparable");
65
-	}
66
-
67
-	@Override
68
-	public CodePosition getPosition() {
69
-		return CodePosition.BUILTIN;
70
-	}
71
-
72
-	@Override
73
-	public String describe() {
74
-		return "concat string";
75
-	}
76
-
77
-	@Override
78
-	public void registerTo(TypeMembers type, TypeMemberPriority priority) {
79
-		type.addOperator(OperatorType.CAT, this, priority);
80
-	}
81
-
82
-	@Override
83
-	public IDefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
84
-		return this; // only used for basic types
85
-	}
86
-
87
-	@Override
88
-	public <T> T accept(MemberVisitor<T> visitor) {
89
-		throw new UnsupportedOperationException("Not a compilable member");
90
-	}
91
-}

+ 6
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java Datei anzeigen

@@ -38,7 +38,6 @@ import org.openzen.zenscript.codemodel.member.builtin.ArrayIteratorValues;
38 38
 import org.openzen.zenscript.codemodel.member.builtin.ComparatorMember;
39 39
 import org.openzen.zenscript.codemodel.member.builtin.ConstantGetterMember;
40 40
 import org.openzen.zenscript.codemodel.member.builtin.RangeIterator;
41
-import org.openzen.zenscript.codemodel.member.builtin.StringConcatMember;
42 41
 import org.openzen.zenscript.codemodel.member.builtin.SubstringMember;
43 42
 import org.openzen.zenscript.codemodel.type.ArrayTypeID;
44 43
 import org.openzen.zenscript.codemodel.type.AssocTypeID;
@@ -82,6 +81,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
82 81
 				break;
83 82
 			case BYTE:
84 83
 				visitByte();
84
+				break;
85 85
 			case INT:
86 86
 				visitInt();
87 87
 				break;
@@ -271,7 +271,6 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
271 271
 	
272 272
 	private void visitBool() {
273 273
 		members.addOperator(BuiltinTypeMembers.BOOL_NOT);
274
-		members.addOperator(new OperatorMember(BUILTIN, 0, OperatorType.NOT, new FunctionHeader(BOOL)), TypeMemberPriority.SPECIFIED);
275 274
 	}
276 275
 	
277 276
 	private void visitByte() {
@@ -416,8 +415,10 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
416 415
 		members.addOperator(OperatorType.INDEXGET, new SubstringMember(substringHeader), TypeMemberPriority.SPECIFIED);
417 416
 		
418 417
 		members.addConstructor(new ConstructorMember(BUILTIN, 0, new FunctionHeader(VOID, new FunctionParameter(cache.getRegistry().getArray(CHAR, 1), "characters"))), TypeMemberPriority.SPECIFIED);
418
+		
419
+		members.addOperator(STRING_ADD_STRING);
419 420
 
420
-		registerStringConcat(NULL);
421
+		/*registerStringConcat(NULL);
421 422
 		registerStringConcat(BOOL);
422 423
 		registerStringConcat(SBYTE);
423 424
 		registerStringConcat(BYTE);
@@ -430,12 +431,11 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
430 431
 		registerStringConcat(FLOAT);
431 432
 		registerStringConcat(DOUBLE);
432 433
 		registerStringConcat(CHAR);
433
-		registerStringConcat(STRING);
434
+		registerStringConcat(STRING);*/
434 435
 	}
435 436
 
436 437
 	private void registerStringConcat(ITypeID withType) {
437
-		FunctionHeader header = new FunctionHeader(STRING, new FunctionParameter(withType));
438
-		members.addOperator(OperatorType.CAT, new StringConcatMember(header), TypeMemberPriority.SPECIFIED);
438
+		members.addOperator(STRING_ADD_STRING);
439 439
 	}
440 440
 
441 441
 	private void registerUnaryOperations() {

+ 2
- 0
ScriptingExample/scripts/statements.zs Datei anzeigen

@@ -0,0 +1,2 @@
1
+while true
2
+	println("Hello!");

Laden…
Abbrechen
Speichern