[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/lava/gzz potion/Call.java potion/CommandCal...
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] gzz/lava/gzz potion/Call.java potion/CommandCal... |
Date: |
Wed, 01 Jan 2003 17:46:51 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Benja Fallenstein <address@hidden> 03/01/01 17:46:50
Modified files:
lava/gzz/potion: Call.java CommandCall.java Expression.java
FunctionCall.java Type.java
lava/gzz/potion/potions: Types.java
Added files:
lava/gzz/client: PotionFallbackBinder.java
Log message:
work towards potion-based bindings
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/client/PotionFallbackBinder.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/Call.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/CommandCall.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/Expression.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/FunctionCall.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/Type.java.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/potion/potions/Types.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gzz/lava/gzz/potion/Call.java
diff -u gzz/lava/gzz/potion/Call.java:1.4 gzz/lava/gzz/potion/Call.java:1.5
--- gzz/lava/gzz/potion/Call.java:1.4 Mon Dec 2 20:01:58 2002
+++ gzz/lava/gzz/potion/Call.java Wed Jan 1 17:46:50 2003
@@ -37,9 +37,59 @@
public String getString(Map context) {
return head.getString(params, context);
}
+
public void render(Map context, HChain into) {
head.render(params, context, into);
}
+
+ public boolean isComplete() {
+ for(int i=0; i<params.length; i++) {
+ if(params[i] == null) return false;
+ if(!params[i].isComplete()) return false;
+ }
+
+ return true;
+ }
+
+ public Type getNextParam() {
+ for(int i=0; i<params.length; i++) {
+ if(params[i] == null) return head.getParams()[i];
+ if(params[i] instanceof Call) {
+ Type t = ((Call)params[i]).getNextParam();
+ if(t != null) return t;
+ }
+ }
+ return null;
+ }
+
+ public Call setNextParam(FunctionExpression expr) {
+ FunctionExpression[] n = new FunctionExpression[params.length];
+ int i=0;
+ while(i<params.length) {
+ if(params[i] == null) {
+ n[i] = expr;
+ break;
+ }
+ if(params[i] instanceof FunctionCall) {
+ FunctionCall fc = (FunctionCall)params[i];
+ if(!fc.isComplete()) {
+ n[i] = (FunctionCall)fc.setNextParam(expr);
+ break;
+ }
+ }
+ n[i] = params[i];
+ }
+
+ if(i >= params.length)
+ throw new IllegalStateException("Call is already complete");
+
+ for(i++; i<params.length; i++)
+ n[i] = params[i];
+
+ return newCall(params);
+ }
+
+ abstract protected Call newCall(FunctionExpression[] params);
protected List[] evaluateParams(Map context) {
List[] result = new List[params.length];
Index: gzz/lava/gzz/potion/CommandCall.java
diff -u gzz/lava/gzz/potion/CommandCall.java:1.2
gzz/lava/gzz/potion/CommandCall.java:1.3
--- gzz/lava/gzz/potion/CommandCall.java:1.2 Mon Dec 2 20:01:58 2002
+++ gzz/lava/gzz/potion/CommandCall.java Wed Jan 1 17:46:50 2003
@@ -14,4 +14,8 @@
public void execute(Map context) {
command.execute(evaluateParams(context), context);
}
+
+ protected Call newCall(FunctionExpression[] params) {
+ return new CommandCall(command, params);
+ }
}
Index: gzz/lava/gzz/potion/Expression.java
diff -u gzz/lava/gzz/potion/Expression.java:1.3
gzz/lava/gzz/potion/Expression.java:1.4
--- gzz/lava/gzz/potion/Expression.java:1.3 Mon Dec 2 20:33:19 2002
+++ gzz/lava/gzz/potion/Expression.java Wed Jan 1 17:46:50 2003
@@ -1,7 +1,7 @@
/*
Expression.java
*
- * Copyright (c) 2002, Benja Fallenstein and others
+ * Copyright (c) 2002, Benja Fallenstein
*
* You may use and distribute under the terms of either the GNU Lesser
* General Public License, either version 2 of the license or,
@@ -28,4 +28,10 @@
String getString(Map context);
void render(Map context, HChain into);
+
+ /** Whether this expression is ready to be
+ * evaluated/executed. If there are 'blanks,'
+ * it's not ready yet.
+ */
+ boolean isComplete();
}
Index: gzz/lava/gzz/potion/FunctionCall.java
diff -u gzz/lava/gzz/potion/FunctionCall.java:1.3
gzz/lava/gzz/potion/FunctionCall.java:1.4
--- gzz/lava/gzz/potion/FunctionCall.java:1.3 Mon Dec 2 20:33:19 2002
+++ gzz/lava/gzz/potion/FunctionCall.java Wed Jan 1 17:46:50 2003
@@ -35,4 +35,8 @@
public List evaluate(Map context) {
return function.evaluate(evaluateParams(context), context);
}
+
+ public Call newCall(FunctionExpression[] params) {
+ return new FunctionCall(function, params);
+ }
}
Index: gzz/lava/gzz/potion/Type.java
diff -u gzz/lava/gzz/potion/Type.java:1.3 gzz/lava/gzz/potion/Type.java:1.4
--- gzz/lava/gzz/potion/Type.java:1.3 Mon Dec 2 20:01:58 2002
+++ gzz/lava/gzz/potion/Type.java Wed Jan 1 17:46:50 2003
@@ -25,10 +25,10 @@
import java.util.*;
import gzz.vob.linebreaking.HChain;
-public interface Type{
+public interface Type {
- Object readCell(Cell c, Map context);
- Object readDir(int win, int axis, int dir, Map context);
+ FunctionExpression readCell(Cell c, Map context);
+ FunctionExpression readDir(int win, int axis, int dir, Map context);
String getQuestionString();
void renderQuestion(HChain into);
}
Index: gzz/lava/gzz/potion/potions/Types.java
diff -u gzz/lava/gzz/potion/potions/Types.java:1.2
gzz/lava/gzz/potion/potions/Types.java:1.3
--- gzz/lava/gzz/potion/potions/Types.java:1.2 Mon Dec 2 20:33:19 2002
+++ gzz/lava/gzz/potion/potions/Types.java Wed Jan 1 17:46:50 2003
@@ -44,10 +44,10 @@
public void renderQuestion(HChain into) {
throw new UnsupportedOperationException();
}
- public Object readCell(Cell c, Map context) {
+ public FunctionExpression readCell(Cell c, Map context) {
return null;
}
- public Object readDir(int win, int axis, int dir, Map context) {
+ public FunctionExpression readDir(int win, int axis, int dir, Map
context) {
return null;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gzz-commits] gzz/lava/gzz potion/Call.java potion/CommandCal...,
Benja Fallenstein <=