/[fenfire]/fenfire/org/fenfire/functional/Functional.java
ViewVC logotype

Diff of /fenfire/org/fenfire/functional/Functional.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by tjl, Wed Sep 10 13:51:31 2003 UTC revision 1.3 by tjl, Mon Oct 6 06:26:13 2003 UTC
# Line 11  import java.lang.reflect.*; Line 11  import java.lang.reflect.*;
11   * transparent run-time data-sensitive caching and super-lazy caching.   * transparent run-time data-sensitive caching and super-lazy caching.
12   */   */
13  public abstract class Functional {  public abstract class Functional {
14        public static boolean dbg = false;
15        private void p(String s) { System.out.println(s); }
16    
17      /** Hints about a Function class.      /** Hints about a Function class.
18       * Hints tell the Functional API about a Function: is it slow to evaluate,       * Hints tell the Functional API about a Function: is it slow to evaluate,
# Line 120  CONSTRUCTORS: for(int i=0; i<constructor Line 122  CONSTRUCTORS: for(int i=0; i<constructor
122                  // If it's a node, allow functions and nodefunctions.                  // If it's a node, allow functions and nodefunctions.
123                  if(FunctionInstance.class.isAssignableFrom(givenParamType)) {                  if(FunctionInstance.class.isAssignableFrom(givenParamType)) {
124                      if(ptypes[j].isAssignableFrom(Function.class) ||                      if(ptypes[j].isAssignableFrom(Function.class) ||
125                         ptypes[j].isAssignableFrom(NodeFunction.class))                         ptypes[j].isAssignableFrom(NodeFunction.class)) {
126                            if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
127                          continue PARAMETERS;                          continue PARAMETERS;
128                        }
129                  }                  }
130    
131                  if(! ptypes[j].isAssignableFrom(givenParamType))                  // Allow float parameter for double and integer.
132                    if(ptypes[j].isAssignableFrom(java.lang.Float.TYPE)) {
133                        if (parameters[j] instanceof java.lang.Double) {
134                            parameters[j] = new java.lang.Float(((java.lang.Double)parameters[j]).floatValue());
135                            if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
136                            continue PARAMETERS;
137                        } else if (parameters[j] instanceof java.lang.Integer) {
138                            parameters[j] = new java.lang.Float(((java.lang.Integer)parameters[j]).floatValue());
139                            if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
140                            continue PARAMETERS;
141                        }
142                    }
143    
144                    // Allow double parameter for float.
145                    if(ptypes[j].isAssignableFrom(java.lang.Double.TYPE)) {
146                        if (parameters[j] instanceof java.lang.Float) {
147                            parameters[j] = new java.lang.Double(((java.lang.Float)parameters[j]).doubleValue());
148                            if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
149                            continue PARAMETERS;
150                        }
151                    }
152    
153                    if(! ptypes[j].isAssignableFrom(givenParamType)) {
154                        if (dbg) p("DISMATCH: "+givenParamType+", "+ptypes[j]);
155                      continue CONSTRUCTORS;                      continue CONSTRUCTORS;
156                    }
157                    if (dbg) p("MATCH: "+givenParamType+", "+ptypes[j]);
158              }              }
159              return constructors[i];              return constructors[i];
160          }          }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26