Commit b42916f8 authored by Lukáš Marek's avatar Lukáš Marek
Browse files

parser integrated into driver, added missing implementation here and there,...

parser integrated into driver, added missing implementation here and there, high priority tasks marked as TODO!
parent 28aa6fef
package ch.usi.dag.disl;
public class CompilerStub {
byte [] compile(String fileName) {
// TODO! read class from file instead of compiling
return null;
}
}
......@@ -9,6 +9,7 @@ import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import ch.usi.dag.disl.analyzer.Analyzer;
import ch.usi.dag.disl.parser.Parser;
import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.marker.MarkedRegion;
import ch.usi.dag.disl.weaver.Weaver;
......@@ -16,6 +17,9 @@ import ch.usi.dag.jborat.agent.Instrumentation;
public class DiSLDriver implements Instrumentation {
final String PROP_DISL_CLASSES = "disl.classes";
final String PROP_CLASSES_DELIM = ",";
List<Snippet> snippets = new LinkedList<Snippet>();
List<Analyzer> analyzers = new LinkedList<Analyzer>();
Weaver weaver;
......@@ -23,13 +27,32 @@ public class DiSLDriver implements Instrumentation {
public DiSLDriver() {
super();
// TODO compile DiSL classes
String classesToCompile = System.getProperty(PROP_DISL_CLASSES);
List<byte []> compiledClasses = new LinkedList<byte []>();
// TODO replace for real compiler
CompilerStub compiler = new CompilerStub();
// *** compile DiSL classes ***
for(String file : classesToCompile.split(PROP_CLASSES_DELIM)) {
compiledClasses.add(compiler.compile(file));
}
// TODO parse DiSL classes
// *** parse compiled classes ***
// - create snippets
// - create analyzers
// TODO initialize viewer
Parser parser = new Parser();
for(byte [] classAsBytes : compiledClasses) {
parser.parse(classAsBytes);
}
// initialize fields
snippets = parser.getSnippets();
analyzers = parser.getAnalyzers();
weaver = new Weaver();
}
/**
......
......@@ -2,6 +2,6 @@ package ch.usi.dag.disl.analyzer;
public interface Analyzer {
// TODO
// TODO refine interface
void analyse();
}
package ch.usi.dag.disl.parser;
import java.util.List;
import ch.usi.dag.disl.analyzer.Analyzer;
import ch.usi.dag.disl.snippet.Snippet;
// The parser takes annotated java files as input and outputs some
// specification for the other three steps.
public class Parser {
public static void parse() {
public void parse(byte [] classAsBytes) {
// TODO! this method can be called many times
}
public List<Snippet> getSnippets() {
// TODO! implement
return null;
}
public List<Analyzer> getAnalyzers() {
// TODO! implement
return null;
}
}
......@@ -7,7 +7,7 @@ public class SnippetImpl {
protected Marker marker;
protected Scope scope;
// TODO protected ?Code? asmCode;
// TODO! protected ?Code? asmCode;
public Marker getMarker() {
return marker;
......
package ch.usi.dag.disl.snippet.scope;
import org.objectweb.asm.tree.MethodNode;
public class ScopeImpl implements Scope {
@Override
public boolean matches(MethodNode method) {
// TODO implementation
return true;
}
}
package ch.usi.dag.disl.util;
// TODO use this class for analyses and marker parameter parsing
public class Parameter {
protected String name;
......
......@@ -9,9 +9,12 @@ import ch.usi.dag.disl.snippet.Snippet;
import ch.usi.dag.disl.snippet.marker.MarkedRegion;
// The weaver instruments byte-codes into java class.
public interface Weaver {
public class Weaver {
// TODO include analysis
void instrument(ClassNode classNode,
Map<Snippet, List<MarkedRegion>> snippetMarkings);
public void instrument(ClassNode classNode,
Map<Snippet, List<MarkedRegion>> snippetMarkings) {
// TODO! implement
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment