📄 program.java
字号:
String[] bootclasspaths; if(Program.hasValueForOption("-bootclasspath")) bootclasspaths = Program.getValueForOption("-bootclasspath").split(File.pathSeparator); else bootclasspaths = System.getProperty("sun.boot.class.path").split(File.pathSeparator); for(int i = 0; i < bootclasspaths.length; i++) { classPaths.add(bootclasspaths[i]); //System.err.println("Adding classpath " + bootclasspaths[i]); } String[] extdirs; if(Program.hasValueForOption("-extdirs")) extdirs = Program.getValueForOption("-extdirs").split(File.pathSeparator); else extdirs = System.getProperty("java.ext.dirs").split(File.pathSeparator); for(int i = 0; i < extdirs.length; i++) { classPaths.add(extdirs[i]); //System.err.println("Adding classpath " + extdirs[i]); } String[] userClasses = null; if(Program.hasValueForOption("-classpath")) userClasses = Program.getValueForOption("-classpath").split(File.pathSeparator); else { String s = System.getProperty("java.class.path"); if(s != null && s.length() > 0) { s = s + File.pathSeparator + "."; // TODO; This should not be necessary userClasses = s.split(File.pathSeparator); } else userClasses = ".".split(File.pathSeparator); } if(!Program.hasValueForOption("-sourcepath")) { for(int i = 0; i < userClasses.length; i++) { classPaths.add(userClasses[i]); sourcePaths.add(userClasses[i]); //System.err.println("Adding classpath/sourcepath " + userClasses[i]); } } else { for(int i = 0; i < userClasses.length; i++) { classPaths.add(userClasses[i]); //System.err.println("Adding classpath " + userClasses[i]); } userClasses = Program.getValueForOption("-sourcepath").split(File.pathSeparator); for(int i = 0; i < userClasses.length; i++) { sourcePaths.add(userClasses[i]); //System.err.println("Adding sourcepath " + userClasses[i]); } } classPath = new ArrayList(); sourcePath = new ArrayList(); for(Iterator iter = classPaths.iterator(); iter.hasNext(); ) { String s = (String)iter.next(); PathPart part = PathPart.createClassPath(s, this); if(part != null) { classPath.add(part); //System.out.println("Adding classpath " + s); } else if(Program.verbose()) System.out.println("Warning: Could not use " + s + " as class path"); } for(Iterator iter = sourcePaths.iterator(); iter.hasNext(); ) { String s = (String)iter.next(); PathPart part = PathPart.createSourcePath(s, this); if(part != null) { sourcePath.add(part); //System.out.println("Adding sourcepath " + s); } else if(Program.verbose()) System.out.println("Warning: Could not use " + s + " as source path"); } } } // Declared in ClassPath.jrag at line 541 // remove user defined classes from this program but keep library classes public void simpleReset() { lookupType_String_String_values = new HashMap(); hasPackage_String_values = new HashMap(); List list = new List(); for(int i = 0; i < getNumCompilationUnit(); i++) { CompilationUnit unit = getCompilationUnit(i); if(!unit.fromSource()) { list.add(unit); } } setCompilationUnitList(list); } // Declared in ErrorCheck.jrag at line 210 public void errorCheck(Collection collection) { for(Iterator iter = compilationUnitIterator(); iter.hasNext(); ) { CompilationUnit cu = (CompilationUnit)iter.next(); if(cu.fromSource()) { cu.collectErrors(); collection.addAll(cu.errors); } } } // Declared in ErrorCheck.jrag at line 219 public void errorCheck(Collection collection, Collection warn) { for(Iterator iter = compilationUnitIterator(); iter.hasNext(); ) { CompilationUnit cu = (CompilationUnit)iter.next(); if(cu.fromSource()) { cu.collectErrors(); collection.addAll(cu.errors); warn.addAll(cu.warnings); } } } // Declared in ErrorCheck.jrag at line 240 public boolean errorCheck() { Collection collection = new LinkedList(); errorCheck(collection); if(collection.isEmpty()) return false; System.out.println("Errors:"); for(Iterator iter = collection.iterator(); iter.hasNext(); ) { String s = (String)iter.next(); System.out.println(s); } return true; } // Declared in LookupType.jrag at line 103 public int classFileReadTime; // Declared in Options.jadd at line 23 private static Map options = new HashMap(); // Declared in Options.jadd at line 24 private static Map optionDescriptions = new HashMap(); // Declared in Options.jadd at line 26 private HashSet files = new HashSet(); // Declared in Options.jadd at line 27 public Collection files() { return files; } // Declared in Options.jadd at line 31 public static void initOptions() { options = new HashMap(); optionDescriptions = new HashMap(); } // Declared in Options.jadd at line 36 public void addKeyOption(String name) { if(optionDescriptions.containsKey(name)) throw new Error("Command line definition error: option description for " + name + " is multiply declared"); optionDescriptions.put(name, new Option(name, false, false)); } // Declared in Options.jadd at line 42 public void addKeyValueOption(String name) { if(optionDescriptions.containsKey(name)) throw new Error("Command line definition error: option description for " + name + " is multiply declared"); optionDescriptions.put(name, new Option(name, true, false)); } // Declared in Options.jadd at line 48 public void addKeyCollectionOption(String name) { if(optionDescriptions.containsKey(name)) throw new Error("Command line definition error: option description for " + name + " is multiply declared"); optionDescriptions.put(name, new Option(name, true, true)); } // Declared in Options.jadd at line 54 public void addOptionDescription(String name, boolean value) { if(optionDescriptions.containsKey(name)) throw new Error("Command line definition error: option description for " + name + " is multiply declared"); optionDescriptions.put(name, new Option(name, value, false)); } // Declared in Options.jadd at line 59 public void addOptionDescription(String name, boolean value, boolean isCollection) { if(optionDescriptions.containsKey(name)) throw new Error("Command line definition error: option description for " + name + " is multiply declared"); optionDescriptions.put(name, new Option(name, value, isCollection)); } // Declared in Options.jadd at line 65 public void addOptions(String[] args) { for(int i = 0; i < args.length; i++) { String arg = args[i]; if(arg.startsWith("@")) { try { String fileName = arg.substring(1,arg.length()); java.io.StreamTokenizer tokenizer = new java.io.StreamTokenizer(new java.io.FileReader(fileName)); tokenizer.resetSyntax(); tokenizer.whitespaceChars(' ',' '); tokenizer.whitespaceChars('\t','\t'); tokenizer.whitespaceChars('\f','\f'); tokenizer.whitespaceChars('\n','\n'); tokenizer.whitespaceChars('\r','\r'); tokenizer.wordChars(33,255); ArrayList list = new ArrayList(); int next = tokenizer.nextToken(); while(next != java.io.StreamTokenizer.TT_EOF) { if(next == java.io.StreamTokenizer.TT_WORD) { list.add(tokenizer.sval); } next = tokenizer.nextToken(); } String[] newArgs = new String[list.size()]; int index = 0; for(Iterator iter = list.iterator(); iter.hasNext(); index++) { newArgs[index] = (String)iter.next(); } addOptions(newArgs); } catch (java.io.IOException e) { } } else if(arg.startsWith("-")) { if(!optionDescriptions.containsKey(arg)) throw new Error("Command line argument error: option " + arg + " is not defined"); Option o = (Option)optionDescriptions.get(arg); if(!o.isCollection && options.containsKey(arg)) throw new Error("Command line argument error: option " + arg + " is multiply defined"); if(o.hasValue && !o.isCollection) { String value = null; if(i + 1 > args.length - 1) throw new Error("Command line argument error: value missing for key " + arg); value = args[i+1]; if(value.startsWith("-")) throw new Error("Command line argument error: value missing for key " + arg); i++; options.put(arg, value); } else if(o.hasValue && o.isCollection) { String value = null; if(i + 1 > args.length - 1) throw new Error("Command line argument error: value missing for key " + arg); value = args[i+1]; if(value.startsWith("-")) throw new Error("Command line argument error: value missing for key " + arg); i++; Collection c = (Collection)options.get(arg); if(c == null) c = new ArrayList(); c.add(value); options.put(arg, c); } else { options.put(arg, null); } } else { files.add(arg); } } } // Declared in Options.jadd at line 137 public static boolean hasOption(String name) { return options.containsKey(name); } // Declared in Options.jadd at line 140 public static void setOption(String name) { options.put(name, null); } // Declared in Options.jadd at line 143 public static boolean hasValueForOption(String name) { return options.containsKey(name) && options.get(name) != null; } // Declared in Options.jadd at line 146 public static String getValueForOption(String name) { if(!hasValueForOption(name)) throw new Error("Command line argument error: key " + name + " does not have a value"); return (String)options.get(name); } // Declared in Options.jadd at line 151 public static void setValueForOption(String value, String option) { options.put(option, value); } // Declared in Options.jadd at line 154 public static Collection getValueCollectionForOption(String name) { if(!hasValueForOption(name)) throw new Error("Command line argument error: key " + name + " does not have a value"); return (Collection)options.get(name); } // Declared in Options.jadd at line 160 public static boolean verbose() { return hasOption("-verbose"); } // Declared in PrettyPrint.jadd at line 35 public void toString(StringBuffer s) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -