Nice/src/bossa/syntax dispatch.java.bootstrap,1.55,1.56 Module.java,1.26,1.27

Daniel Bonniot <[email protected]> Sat, 18 Jun 2005 13:26:57 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/bossa/syntax
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24032/src/bossa/syntax

Modified Files:
	dispatch.java.bootstrap Module.java 
Log Message:
Implemented static import.


Index: dispatch.java.bootstrap
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/dispatch.java.bootstrap,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** dispatch.java.bootstrap	11 Mar 2005 17:35:52 -0000	1.55
--- dispatch.java.bootstrap	18 Jun 2005 13:26:55 -0000	1.56
***************
*** 52,54 ****
--- 52,56 ----
  
    public static void _printStackTraceWithSourceInfo(Throwable t) {}
+ 
+   public static java.util.List findJavaMethods(gnu.bytecode.ClassType c, String s) { return null; }
  }

Index: Module.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Module.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Module.java	11 Mar 2005 17:35:52 -0000	1.26
--- Module.java	18 Jun 2005 13:26:55 -0000	1.27
***************
*** 36,38 ****
--- 36,72 ----
  
    public boolean compiled() { return pkg.interfaceFile(); }
+ 
+   public void addStaticImport(LocatedString value)
+   {
+     String fullName = value.toString();
+ 
+     int lastDot = fullName.lastIndexOf('.');
+     if (lastDot == -1)
+       bossa.util.User.error(value, "Missing field or method name");
+ 
+     String methodName = fullName.substring(lastDot+1);
+     fullName = fullName.substring(0, lastDot);
+ 
+     mlsub.typing.TypeConstructor tc =
+       Node.getGlobalTypeScope().globalLookup(fullName, value.location());
+ 
+     if(tc == null)
+       bossa.util.User.error(value, "Unknown class: " + fullName);
+ 
+     gnu.bytecode.Type type = nice.tools.code.Types.javaType(tc);
+     if (! (type instanceof gnu.bytecode.ClassType))
+       bossa.util.User.error(value, fullName + " is not a class");
+ 
+     java.util.List symbols = dispatch.findJavaMethods
+       ((gnu.bytecode.ClassType) type, methodName);
+ 
+     if (symbols.size() == 0)
+       bossa.util.User.error(value, methodName + " is not a static field or method of class " + fullName);
+ 
+     for (java.util.Iterator i = symbols.iterator(); i.hasNext();)
+       {
+         /*Var*/Symbol s = (/*Var*/Symbol) i.next();
+         scope.addSymbol(s);
+       }
+   }
  }



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click