Pārlūkot izejas kodu

Finished LambdaClosure class

Stan Hebben 6 gadus atpakaļ
vecāks
revīzija
c0cbbda75f

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedClosureExpression.java Parādīt failu

@@ -24,4 +24,9 @@ public class CapturedClosureExpression extends CapturedExpression {
24 24
 	public <T> T accept(ExpressionVisitor<T> visitor) {
25 25
 		return visitor.visitCapturedClosure(this);
26 26
 	}
27
+
28
+	@Override
29
+	public <T> T accept(CapturedExpressionVisitor<T> visitor) {
30
+		return visitor.visitRecaptured(this);
31
+	}
27 32
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedDirectExpression.java Parādīt failu

@@ -23,4 +23,9 @@ public class CapturedDirectExpression extends CapturedExpression {
23 23
 	public <T> T accept(ExpressionVisitor<T> visitor) {
24 24
 		return visitor.visitCapturedDirect(this);
25 25
 	}
26
+
27
+	@Override
28
+	public <T> T accept(CapturedExpressionVisitor<T> visitor) {
29
+		return visitor.visitCapturedDirect(this);
30
+	}
26 31
 }

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpression.java Parādīt failu

@@ -27,4 +27,6 @@ public abstract class CapturedExpression extends Expression {
27 27
 		closure.add(result);
28 28
 		return result;
29 29
 	}
30
+	
31
+	public abstract <T> T accept(CapturedExpressionVisitor<T> visitor);
30 32
 }

+ 22
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedExpressionVisitor.java Parādīt failu

@@ -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.expression;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface CapturedExpressionVisitor<T> {
13
+	T visitCapturedThis(CapturedThisExpression expression);
14
+	
15
+	T visitCapturedParameter(CapturedParameterExpression expression);
16
+	
17
+	T visitCapturedLocal(CapturedLocalVariableExpression expression);
18
+	
19
+	T visitCapturedDirect(CapturedDirectExpression expression);
20
+	
21
+	T visitRecaptured(CapturedClosureExpression expression);
22
+}

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedLocalVariableExpression.java Parādīt failu

@@ -25,4 +25,9 @@ public class CapturedLocalVariableExpression extends CapturedExpression {
25 25
 	public <T> T accept(ExpressionVisitor<T> visitor) {
26 26
 		return visitor.visitCapturedLocalVariable(this);
27 27
 	}
28
+
29
+	@Override
30
+	public <T> T accept(CapturedExpressionVisitor<T> visitor) {
31
+		return visitor.visitCapturedLocal(this);
32
+	}
28 33
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedParameterExpression.java Parādīt failu

@@ -25,4 +25,9 @@ public class CapturedParameterExpression extends CapturedExpression {
25 25
 	public <T> T accept(ExpressionVisitor<T> visitor) {
26 26
 		return visitor.visitCapturedParameter(this);
27 27
 	}
28
+
29
+	@Override
30
+	public <T> T accept(CapturedExpressionVisitor<T> visitor) {
31
+		return visitor.visitCapturedParameter(this);
32
+	}
28 33
 }

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CapturedThisExpression.java Parādīt failu

@@ -21,4 +21,9 @@ public class CapturedThisExpression extends CapturedExpression {
21 21
 	public <T> T accept(ExpressionVisitor<T> visitor) {
22 22
 		return visitor.visitCapturedThis(this);
23 23
 	}
24
+
25
+	@Override
26
+	public <T> T accept(CapturedExpressionVisitor<T> visitor) {
27
+		return visitor.visitCapturedThis(this);
28
+	}
24 29
 }

+ 6
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/LambdaClosure.java Parādīt failu

@@ -5,12 +5,17 @@
5 5
  */
6 6
 package org.openzen.zenscript.codemodel.expression;
7 7
 
8
+import java.util.ArrayList;
9
+import java.util.List;
10
+
8 11
 /**
9 12
  *
10 13
  * @author Hoofdgebruiker
11 14
  */
12 15
 public class LambdaClosure {
16
+	public final List<CapturedExpression> captures = new ArrayList<>();
17
+	
13 18
 	public void add(CapturedExpression capture) {
14
-		
19
+		captures.add(capture);
15 20
 	}
16 21
 }

Notiek ielāde…
Atcelt
Saglabāt