Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Parameters.java

00001 package gov.nasa.arc.ase.jpf.tools;
00002 
00003 //#ifdef BUCHI && BANDERA
00004 import edu.ksu.cis.bandera.specification.predicate.analysis.*;
00005 import edu.ksu.cis.bandera.specification.predicate.node.*;
00006 import gov.nasa.arc.ase.jpf.JPFErrorException;
00007 import java.io.*;
00008 
00009 class Parameters extends DepthFirstAdapter {
00010   private Translation translation;
00011   private StringBuffer sb;
00012 
00013   public Parameters(Translation t) {
00014     translation = t;
00015   }  
00016   public void caseAInstanceParams(AInstanceParams node) {
00017     translation.out.print(", Reference " + classNameOf(translation.thisType.getName()) + "$this");
00018     if(node.getCpl() != null) {
00019       node.getCpl().apply(this);
00020     }
00021   }  
00022   public void caseAParamParamList(AParamParamList node) {
00023     sb = new StringBuffer();
00024     node.getName().apply(this);
00025     String type = sb.toString();
00026 
00027     sb = new StringBuffer();
00028     node.getId().apply(this);
00029     String name = sb.toString();
00030 
00031     translation.out.print(", Reference " + name);
00032 
00033     try {
00034       translation.params.put(name, Class.forName(type));
00035     } catch(ClassNotFoundException e) {
00036       try {
00037     translation.params.put(name, Class.forName("java.lang." + type));
00038       } catch(ClassNotFoundException ee) {
00039     throw new JPFErrorException("class not found: " + type);
00040       }
00041     }
00042   }  
00043   public void caseAParamsParamList(AParamsParamList node) {
00044     sb = new StringBuffer();
00045     node.getName().apply(this);
00046     String type = sb.toString();
00047 
00048     sb = new StringBuffer();
00049     node.getId().apply(this);
00050     String name = sb.toString();
00051 
00052     translation.out.print(", " + type + " " + name);
00053 
00054     try {
00055       translation.params.put(name, Class.forName(type));
00056     } catch(ClassNotFoundException e) {
00057       try {
00058     translation.params.put(name, Class.forName("java.lang." + type));
00059       } catch(ClassNotFoundException ee) {
00060     throw new JPFErrorException("class not found: " + type);
00061       }
00062     }
00063   }  
00064   public void caseAQualifiedName(AQualifiedName node) {
00065     node.getName().apply(this);
00066     sb.append(".");
00067     sb.append(node.getId().getText());
00068   }  
00069   public void caseASimpleName(ASimpleName node) {
00070     sb.append(node.getId().getText());
00071   }  
00072   public void caseTId(TId node) {
00073     sb.append(node.getText());
00074   }  
00075   private static String classNameOf(String name) {
00076     if(name.indexOf('.') == -1) return name;
00077 
00078     return name.substring(name.lastIndexOf('.')+1);
00079   }  
00080 }

Generated at Thu Feb 7 06:51:04 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001