LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Mon Feb 25 03:49:21 CET 2008
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/08/02 25:03:49

    Modified: jop/java/tools/src/joptimizer/config ArchConfig.java
    JopConfig.java
    Added: jop/java/tools/src/joptimizer/config jop-arch.properties
    jvm-arch.properties
    Log:
    loading arch config from property-file

    allow to load configfile from cmdline


    Revision Changes Path
    1.3 jop/java/tools/src/joptimizer/config/ArchConfig.java

    http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/config/ArchConfig.java.diff?r1=1.2&r2=1.3

    (In the diff below, changes in quantity of whitespace are not shown.)

    Index: ArchConfig.java
    ===================================================================
    RCS file: /cvsroot/stefant/jop/java/tools/src/joptimizer/config/ArchConfig.java,v
    retrieving revision 1.2
    retrieving revision 1.3
    diff -u -b -r1.2 -r1.3
    --- ArchConfig.java 24 Feb 2008 20:19:12 -0000 1.2
    +++ ArchConfig.java 25 Feb 2008 02:49:21 -0000 1.3
    @@ -18,7 +18,15 @@
    */
    package joptimizer.config;

    +import java.io.BufferedReader;
    +import java.io.IOException;
    +import java.io.InputStreamReader;
    +import java.io.Reader;
    +import java.net.URL;
    +import java.util.Arrays;
    +import java.util.Collections;
    import java.util.HashSet;
    +import java.util.Properties;
    import java.util.Set;

    /**
    @@ -27,29 +35,31 @@
    public class ArchConfig {

    private ArchTiming timing;
    + private Set systemClasses;
    + private String nativeClass;

    - public ArchConfig(String filename) {
    - timing = new JopTimings(this);
    - }
    + public static final String CONF_SYSTEM_CLASSES = "systemclasses";

    - public ArchTiming getArchTiming() {
    - return timing;
    - }
    + public static final String CONF_NATIVE_CLASS = "nativeclass";

    - public String getNativeClassName() {
    - return "com.jopdesign.sys.Native";
    + public ArchConfig() {
    + systemClasses = Collections.EMPTY_SET;
    + nativeClass = "";
    + timing = new JopTimings(this);
    }

    - public String getStartupClassName() {
    - return "com.jopdesign.sys.Startup";
    + public ArchConfig(URL configfile) throws ConfigurationException {
    + loadConfig(configfile);
    + // TODO get timings from configuration too
    + timing = new JopTimings(this);
    }

    - public String getJvmClassName() {
    - return "com.jopdesign.sys.JVM";
    + public ArchTiming getArchTiming() {
    + return timing;
    }

    - public String getHelpClassName() {
    - return "com.jopdesign.sys.JVMHelp";
    + public String getNativeClassName() {
    + return nativeClass;
    }

    /**
    @@ -59,14 +69,6 @@
    * @return a set of classnames as string.
    */
    public Set getSystemClasses() {
    - Set systemClasses = new HashSet();
    -
    - systemClasses.add(getStartupClassName());
    - systemClasses.add(getJvmClassName());
    - systemClasses.add(getHelpClassName());
    -
    - //systemClasses.add("java.lang.NullPointerException");
    -
    return systemClasses;
    } @@ -89,4 +91,31 @@ public int getRamWriteCycles() { return 2; } + + private void loadConfig(URL config) throws ConfigurationException { + + systemClasses = new HashSet(); + + Properties props = new Properties(); + try { + Reader reader = new BufferedReader(new InputStreamReader(config.openStream())); + props.load(reader); + } catch (IOException e) { + throw new ConfigurationException("Could not read configuration file.", e); + } + + Object sys = props.get(CONF_SYSTEM_CLASSES); + if ( sys != null && !"".equals(sys.toString()) ) { + String[] sysclasses = String.valueOf(sys).split(","); + systemClasses.addAll(Arrays.asList(sysclasses)); + } + + Object nat = props.get(CONF_NATIVE_CLASS); + if ( nat != null ) { + nativeClass = String.valueOf(nat); + } else { + nativeClass = ""; + } + + } } 1.7 jop/java/tools/src/joptimizer/config/JopConfig.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/config/JopConfig.java.diff?r1=1.6&r2=1.7 (In the diff below, changes in quantity of whitespace are not shown.) Index: JopConfig.java =================================================================== RCS file: /cvsroot/stefant/jop/java/tools/src/joptimizer/config/JopConfig.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- JopConfig.java 21 Feb 2008 03:09:50 -0000 1.6 +++ JopConfig.java 25 Feb 2008 02:49:21 -0000 1.7 @@ -20,7 +20,10 @@ import com.jopdesign.libgraph.struct.AppConfig; +import java.net.MalformedURLException; +import java.net.URL; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; @@ -28,7 +31,6 @@ /** * Main configuration container class. - * TODO make 'Architecture'-conf-file option, load sys/default classnames, max-code/stack/locals,.. from prop-file * * @author Stefan Hepp, e0026640@s... * @noinspection InconsistentJavaDoc @@ -39,6 +41,8 @@ private Set rootClasses; private String mainClass; private ArchConfig archConfig; + private String[] libraries; + private String[] ignore; public static final String CONF_OUTPUTPATH = "o"; @@ -50,8 +54,12 @@ public static final String CONF_ALLOW_LOADDEMAND = "allow-loaddemand"; + public static final String CONF_ARCH = "arch"; + public static final String CONF_ARCH_CONFIG = "arch-config"; + public static final String CONF_LIBRARY_PATH = "libraries"; + public static final String CONF_IGNORE_PATH = "skip"; public static final String CONF_IGNORE_ACTION_ERRORS = "ignore-errors"; @@ -59,20 +67,30 @@ public static final String CONF_SKIP_NATIVE_CLASS = "skip-nativeclass"; public JopConfig() { - this.config = new Properties(); - this.rootClasses = new HashSet(); - setArchConfig(null); + initialize(null, null); + } + + public JopConfig(Properties config) throws ConfigurationException { + initialize(config, null); + if ( config != null ) { + setProperties(config); + } } - public JopConfig(Properties config) { - this.config = config == null ? new Properties() : config; - setArchConfig(getArchConfigFileName()); + public JopConfig(Properties config, String mainClass) throws ConfigurationException { + initialize(config, mainClass); + if ( config != null ) { + setProperties(config); + } } - public JopConfig(Properties config, String mainClass) { - this.config = config == null ? new Properties() : config; + private void initialize(Properties config, String mainClass) { + this.config = new Properties(); this.mainClass = mainClass; - setArchConfig(getArchConfigFileName()); + this.rootClasses = new HashSet(); + libraries = new String[0]; + ignore = new String[0]; + archConfig = new ArchConfig(); } /** @@ -81,8 +99,12 @@ * @param optionList a list where options as ArgOption will be added. */ public static void createOptions(List optionList) { + optionList.add(new StringOption(null, CONF_OUTPUTPATH, "Set default output path for all generated files.", "path")); + optionList.add(new StringOption(null, CONF_ARCH, + "Initialize options with default values for an architecture if not set, and load " + + "internal architecture configfile. Currently supported: jop,jvm", "arch")); optionList.add(new StringOption(null, CONF_ARCH_CONFIG, "Load an architecture configuration from a config file.", "file")); optionList.add(new BoolOption(null, CONF_ASSUME_DYNAMIC_LOADING, @@ -93,6 +115,9 @@ "Ignore missing classes. Some features will not work when this option is set.")); optionList.add( new BoolOption(null, CONF_ALLOW_LOADDEMAND, "Allow class loading on demand. Disables automatic transitive hull loading.")); + optionList.add( new StringOption(null, CONF_LIBRARY_PATH, + "Comma-separated list of packages or classes which are part of libraries and should " + + "not be loaded.", "pkg")); optionList.add( new StringOption(null, CONF_IGNORE_PATH, "Comma-separated list of packages or classes which will not be loaded. Ignored if " + CONF_ALLOW_INCOMPLETE_CODE + " is not set.", "pkg")); @@ -102,8 +127,11 @@ "Do not load native system classes.")); } - public void setProperties(Properties config) { - this.config.putAll(config); + public void setProperties(Map config) throws ConfigurationException { + for (Iterator it = config.entrySet().iterator(); it.hasNext();) { + Map.Entry entry = (Map.Entry) it.next(); + setOption(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); + } } public String getMainClassName() { @@ -138,11 +166,33 @@ return getOption(CONF_ARCH_CONFIG); } - public void setArchConfig(String config) { + public void setArchConfig(URL config) throws ConfigurationException { if ( config != null ) { - this.config.put(CONF_ARCH_CONFIG, config); - } this.archConfig = new ArchConfig(config); + this.config.put(CONF_ARCH_CONFIG, config.toString()); + } else { + this.archConfig = new ArchConfig(); + this.config.remove(CONF_ARCH_CONFIG); + } + } + + public void initArchitecture(String arch) throws ConfigurationException { + if ( "jop".equals(arch) ) { + URL config = getClass().getResource("jop-arch.properties"); + setArchConfig(config); + + } else if ( "jvm".equals(arch) ) { + + URL config = getClass().getResource("jvm-arch.properties"); + setArchConfig(config); + + if ( !isSet(CONF_LIBRARY_PATH) ) { + setOption(CONF_LIBRARY_PATH, "java,sun"); + } + + } else { + throw new ConfigurationException("Unknown architecture {"+arch+"}."); + } } public String getMainMethodSignature() { @@ -173,8 +223,40 @@ return isEnabled(getOptionName(name, option)); } - public void setOption(String option, String value) { + public void setOption(String option, String value) throws ConfigurationException { + if ( CONF_ARCH_CONFIG.equals(option) ) { + try { + setArchConfig(new URL(value)); + } catch (MalformedURLException e) { + throw new ConfigurationException("Invalid configuration file url {"+value+"}.", e); + } + } else if ( CONF_ARCH.equals(option) ) { + initArchitecture(value); + } else { + if ( value != null ) { config.setProperty(option, value); + } else { + config.remove(option); + } + } + + if ( CONF_IGNORE_PATH.equals(option) ) { + + if ( value != null && !"".equals(value) ) { + ignore = value.split(","); + } else { + ignore = new String[0]; + } + + } else if ( CONF_LIBRARY_PATH.equals(option) ) { + + if ( value != null && !"".equals(value) ) { + libraries = value.split(","); + } else { + libraries = new String[0]; + } + + } } public String getOption(String option) { @@ -246,14 +328,33 @@ "java.lang.Class".equals(className); } + public boolean isLibraryClassName(String className) { + for (int i = 0; i < libraries.length; i++) { + if ( className.startsWith(libraries[i]) ) { + return true; + } + } + return false; + } + public String doExcludeClassName(String className) { if ( isNativeClassName(className) && isEnabled(CONF_SKIP_NATIVE_CLASS) ) { return "Skipping native class {" + className + "}."; } + if ( isLibraryClassName(className) ) { + return "Skipping library class {" + className + "}"; + } + if ( doAllowIncompleteCode() ) { - // TODO check for jopConfig.ignore_path + + for (int i = 0; i < ignore.length; i++) { + if ( className.startsWith(ignore[i]) ) { + return "Skipping excluded class {"+ className + "}"; + } + } + } return null; 1.1 jop/java/tools/src/joptimizer/config/jop-arch.properties http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/config/jop-arch.properties?rev=1.1&content-type=text/x-cvsweb-markup Index: jop-arch.properties =================================================================== # # Copyright (c) 2007,2008, Stefan Hepp # # This file is part of JOPtimizer. # # JOPtimizer is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # JOPtimizer is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # systemclasses=com.jopdesign.sys.JVMHelp,com.jopdesign.sys.JVM,com.jopdesign.sys.Startup nativeclass=com.jopdesign.sys.Native 1.1 jop/java/tools/src/joptimizer/config/jvm-arch.properties http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/config/jvm-arch.properties?rev=1.1&content-type=text/x-cvsweb-markup Index: jvm-arch.properties =================================================================== # # Copyright (c) 2007,2008, Stefan Hepp # # This file is part of JOPtimizer. # # JOPtimizer is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # JOPtimizer is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # systemclasses= nativeclass=

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.