This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: define-namespace in compiled files


Chris Dean wrote:
I'm unable to use define-namespace from a compiled file. However, when
running interactively it works fine.

The attached patch should fix the problem.


However, this causes the Long:new to be looked up at run time.
We really want it to be looked up at compile time.  I'll take
a look at what's involved in that.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

Index: Interpreter.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/expr/Interpreter.java,v
retrieving revision 1.44
diff -u -r1.44 Interpreter.java
--- Interpreter.java	29 Mar 2003 18:54:22 -0000	1.44
+++ Interpreter.java	30 Apr 2003 06:07:58 -0000
@@ -456,7 +456,7 @@
 
   /** Used when defining a namespace alias (prefix), in the XML sense.
    * Define in a namespace prefix NS is equivalent to defining a constant
-   * named NAMESPACE_PREFIX+"NS" whose value is teh namespace URI. */
+   * named NAMESPACE_PREFIX+"NS" whose value is the namespace URI. */
   public static final String NAMESPACE_PREFIX = "$Namespace$";
 
   public static final int VALUE_NAMESPACE = 1<<0;
@@ -618,6 +618,21 @@
       {
 	if (uri != null && uri.startsWith("class:"))
 	  return ClassMethods.apply(uri.substring(6), name);
+      }
+    int colon = name.indexOf(':');
+    Environment env = sym.getEnvironment();
+    if (colon > 1 & env != null)
+      {
+	String prefix = (NAMESPACE_PREFIX+name.substring(0, colon)).intern();
+	Object uri_val = env.get(prefix, null);
+	if (uri_val != null)
+	  {
+	    if (! (uri_val instanceof Environment))
+	      uri_val = uri_val.toString();
+	    sym = Symbol.make(uri_val, name.substring(colon+1));
+	    return function ? getSymbolProcedure(sym)
+	      : getSymbolValue(sym);
+	  }
       }
     throw new UnboundSymbol(name);
   }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]