Skip to content
Snippets Groups Projects
Commit d83e075a authored by Johannes Mey's avatar Johannes Mey
Browse files

wip

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 237 additions and 0 deletions
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.*;
aspect Logging {
static Logger ASTNode.logger = LogManager.getLogger(ASTNode.class);
}
aspect JastAddAPIExtension {
/**
* removes the object from the AST, i.e. removes the reference from its parent to the object
*
* Please note that any intrinsic non-containment relations to the object are not removed.
* @return true, if the object had a parent.
*/
public boolean ASTNode.removeSelf() {
if (getParent() == null) {
return false;
} else {
for (int childIndex = 0; childIndex < getParent().numChildren(); childIndex++) {
if (getParent().getChild(childIndex) == this) {
getParent().removeChild(childIndex);
return true;
}
}
}
throw new RuntimeException("unable to remove child, because it was not contained in its parent!");
}
public String Element.customID() {
return getLabel();
}
public String State.toString() {
return getLabel();
}
public String Component.toString() {
return getState().getLabel();
}
}
aspect Util {
}
aspect SMtoDG {
syn DependencyGraph StateMachine.dependencyGraph() {
DependencyGraph dg = new DependencyGraph();
dg.setStateMachine(this);
Map<State,Component> componentMap = new HashMap<>();
for (State s: states()) {
Component n = new Component();
n.setState(s);
dg.addComponent(n);
componentMap.put(s, n);
}
for (Transition t: transitions()) {
Component to = componentMap.get(t.getTo());
Component from = componentMap.get(t.getFrom());
to.addDependency(from);
}
return dg;
}
}
rel Component.State -> State;
rel DependencyGraph.StateMachine? -> StateMachine;
package de.tudresden.inf.st.sle19;
import de.tudresden.inf.st.sle19.jastadd.model.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
public class Main {
private static Logger logger = LogManager.getLogger(Main.class);
public static void main(String[] args) {
logger.info("running main");
// create simple state machine
StateMachine stateMachine = new StateMachine();
// add states A to F
State a = new State();
a.setLabel("a");
stateMachine.addElement(a);
stateMachine.setInitial(a);
State b = new State();
b.setLabel("b");
stateMachine.addElement(b);
State c = new State();
c.setLabel("c");
stateMachine.addElement(c);
State d = new State();
d.setLabel("d");
stateMachine.addElement(d);
State e = new State();
e.setLabel("e");
stateMachine.addElement(e);
stateMachine.addFinal(e);
State f = new State();
f.setLabel("f");
stateMachine.addElement(f);
stateMachine.addFinal(f);
// add transitions
Transition af = new Transition();
af.setFrom(a);
af.setTo(f);
af.setLabel("af");
stateMachine.addElement(af);
Transition ab = new Transition();
ab.setFrom(a);
ab.setTo(b);
ab.setLabel("ab");
stateMachine.addElement(af);
Transition bc = new Transition();
bc.setFrom(b);
bc.setTo(c);
bc.setLabel("bc");
stateMachine.addElement(bc);
Transition bd = new Transition();
bd.setFrom(b);
bd.setTo(d);
bd.setLabel("bd");
stateMachine.addElement(bd);
Transition ce = new Transition();
ce.setFrom(c);
ce.setTo(e);
ce.setLabel("ce");
stateMachine.addElement(ce);
Transition eb = new Transition();
eb.setFrom(e);
eb.setTo(b);
eb.setLabel("eb");
stateMachine.addElement(eb);
Transition ed = new Transition();
ed.setFrom(e);
ed.setTo(d);
ed.setLabel("ed");
stateMachine.addElement(ed);
Transition fa = new Transition();
fa.setFrom(f);
fa.setTo(a);
fa.setLabel("fa");
stateMachine.addElement(fa);
// show reachability table
logger.info("Reachability (ORIGINAL):");
for (State state: stateMachine.states()) {
logger.info("state {}", state);
logger.info(" is in cycle: {}", state.hasCycle());
logger.info(" is reachable from {} and is in cycle: {}", state.reachable());
logger.info(" is inverse reachable from {} and is in cycle: {}", state.inverseReachable());
logger.info(" SCC: {}", state.SCC());
}
logger.info("SCCs: {}", stateMachine.SCC());
DependencyGraph dependencyGraph = stateMachine.dependencyGraph();
logger.info("Reachability (DependencyGraph):");
for (Component component: dependencyGraph.getComponentList()) {
logger.info("component {}", component);
logger.info(" is in cycle: {}", component.hasCycle());
logger.info(" is reachable from {} and is in cycle: {}", component.reachable());
logger.info(" is inverse reachable from {} and is in cycle: {}", component.inverseReachable());
logger.info(" SCC: {}", component.SCC());
}
logger.info("SCCs: {}", dependencyGraph.SCC());
try {
stateMachine.serialize(new File("simpleSM.json"));
} catch (SerializationException e1) {
e1.printStackTrace();
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%highlight{%d{HH:mm:ss.SSS} %-5level} %c{1.} - %msg%n"/>
</Console>
<RollingFile name="RollingFile" fileName="logs/jastadd-ttc19.log"
filePattern="logs/jastadd-ttc19-%i.log">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n"/>
<Policies>
<OnStartupTriggeringPolicy/>
</Policies>
<DefaultRolloverStrategy max="20"/>
</RollingFile>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
</Configuration>
system = ant
sysver = ant-1.8.4
fullname = Ant
domain = parsers/generators/make
status = Active
sysvercount = 23
description = A Java library and command-line tool for supporting processes described in build files as targets and extension points dependent upon each other.
jreversion = 1.5.0_22
license = Apache License * Version 2.0, January 2004; src/apache-ant-1.8.4/LICENSE
distribution = e,r
releasedate = 2012-05-23
sourcepackages = org.apache.tools
n_bin = 1290
n_both = 1290
n_files = 846
n_top(bin) = 850
loc(both) = 217198
ncloc(both) = 105007
url = http://ant.apache.org/
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment