X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fprotothread%2FProtothreadVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fprotothread%2FProtothreadVisitor.java;h=88937a7c7bdec32e6d47f2a08c82661bc72032e2;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/protothread/ProtothreadVisitor.java b/dol/src/dol/visitor/protothread/ProtothreadVisitor.java new file mode 100644 index 0000000..88937a7 --- /dev/null +++ b/dol/src/dol/visitor/protothread/ProtothreadVisitor.java @@ -0,0 +1,96 @@ +/* $Id: ProtothreadVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.protothread; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import dol.datamodel.pn.ProcessNetwork; +import dol.util.Copier; +import dol.visitor.PNVisitor; + +/** + * + */ +public class ProtothreadVisitor extends PNVisitor { + + /** + * Constructor. + */ + public ProtothreadVisitor(String packageName) { + _packageName = packageName; + } + + /** + * + */ + public void visitComponent(ProcessNetwork x) { + try { + _generateDirHierarchy(); + + x.accept(new ProtothreadMakefileVisitor(_srcDir)); + x.accept(new ProtothreadModuleVisitor(_srcDir)); + x.accept(new ProtothreadProcessVisitor(_wrapperDir)); + + } catch (Exception e) { + System.out.println(" SystemC PN Visitor: exception " + + "occured: " + e.getMessage()); + e.printStackTrace(); + } + + } + + /** + * + */ + private void _generateDirHierarchy() + throws IOException, FileNotFoundException { + + File dir = new File(_packageName); + dir.mkdirs(); + + _srcDir = _packageName + _delimiter + _srcDirName; + dir = new File(_srcDir); + dir.mkdirs(); + + _libDir = _srcDir + _delimiter + _libDirName; + dir = new File(_libDir); + dir.mkdirs(); + + _processDir = _srcDir + _delimiter + _processDirName; + dir = new File(_processDir); + dir.mkdirs(); + + _wrapperDir = _srcDir + _delimiter + _wrapperDirName; + dir = new File(_wrapperDir); + dir.mkdirs(); + + // copy library + String libraryPath = _ui.getMySystemCLib(); + libraryPath = libraryPath.replaceAll("systemC", + "protothread"); + File source = new File(libraryPath); + File destination = new File(_libDir); + new Copier().copy(source, destination); + + //copy process src code + source = new File(_srcDirName); + destination = new File(_processDir); + new Copier().copy(source, destination); + } + + protected String _packageName = null; + + protected String _srcDir = ""; + protected static String _srcDirName = "src"; + + protected String _libDir = ""; + protected static String _libDirName = "lib"; + + protected String _processDir = ""; + protected static String _processDirName = "processes"; + + protected String _wrapperDir = ""; + protected static String _wrapperDirName = "wrappers"; +} +