Commit 06c65cbc authored by Markus Bauer's avatar Markus Bauer
Browse files

Including new compiler version 2.1

parent 136a7346
No preview for this file type
package compiler;
import gui.Output;
import java.awt.Desktop;
import java.io.File;
import java.io.FileOutputStream;
......@@ -10,9 +11,13 @@ import java.net.URI;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javax.swing.SwingUtilities;
import main.PseuCoCo;
import resources.ResourceLoader;
import start.Start;
import codeGen.Code;
......@@ -20,7 +25,6 @@ import codeGen.CodeGen;
import codeGen.MainCode;
import codeGen.MainCodeGen;
import debugger.DebuggerHandler;
import main.PseuCoCo;
public class Pseuco {
......@@ -125,16 +129,16 @@ public class Pseuco {
* Reseting code
*/
private static void init() {
MainCodeGen.inputNode = null;
MainCodeGen.rootNode = null;
MainCodeGen.output = true;
MainCodeGen.generatedCode = null;
MainCodeGen.isJavaCodeGeneration = true;
MainCodeGen.listOfExternJavaFiles = new LinkedList<String>();
CodeGen.mainCodeObject = new MainCode();
CodeGen.monitors = new HashMap<String, Code>();
CodeGen.structs = new HashMap<String, Code>();
CodeGen.usedVariableNames = new HashSet<String>();
CodeGen.handshakeChannels = new HashSet<String>();
CodeGen.mainPackageName = savedMainPackageName;
CodeGen.monitorPackageName = savedMonitorPackageName;
......
......@@ -8,6 +8,7 @@ package start;
import gui.GUI;
import gui.Output;
import gui.WorkspaceDialog;
import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.File;
......@@ -23,7 +24,7 @@ import compiler.Pseuco;
public class Start {
public static final String version = "v1.1";
public static final String version = "v1.2 beta";
public static String workspace = "";
public static final boolean debug = false;
private static LockApplication lock = new LockApplication();
......
package debugger;
import gui.Output;
import java.lang.reflect.Field;
import java.util.LinkedList;
import compiler.Pseuco;
import codeGen.CodeLine;
import codeGen.CodeLineList;
import gui.Output;
import compiler.Pseuco;
public aspect DebuggerListeners {
public static ThreadListener startListener = null;
......@@ -63,7 +67,7 @@ public aspect DebuggerListeners {
//Redirect join to the PseuCoThread.joinAgent method, to allow joinListener
pointcut joinGeneration(String s) : within(tree.ASTPrimitiveStatement)
&& withincode(* tree.ASTPrimitiveStatement.codeGen(..))
&& withincode(* tree.ASTPrimitiveStatement.generateCode(..))
&& call(StringBuilder StringBuilder.append(String)) && args(s);
StringBuilder around(String s) : joinGeneration(s){
......@@ -89,26 +93,39 @@ public aspect DebuggerListeners {
//give all new threads a name
pointcut getCallCode(String cc) : withincode(* tree.ASTStartExpression.codeGen(..)) &&
call(String createFinalVariables(String)) && args(cc);
pointcut renameAgents() : withincode(* tree.ASTStartExpression.codeGen(..)) &&
call(String generateRunnableCode(String));
pointcut getCallCode(CodeLineList cc) : withincode(* tree.ASTStartExpression.generateCode(..)) &&
call(CodeLineList createFinalVariables(CodeLineList)) && args(cc);
//pointcut renameAgents() : withincode(* tree.ASTStartExpression.generateCode(..)) &&
// call(CodeLineList generateRunnableCode(CodeLineList));
private String lastCallCode = null;
before(String cc) : getCallCode(cc){
before(CodeLineList cc) : getCallCode(cc){
if (Pseuco.debugging){
lastCallCode = cc;
lastCallCode = cc.toString();
}
}
String around() : renameAgents(){
/*CodeLineList around() : renameAgents(){
if (Pseuco.debugging && lastCallCode != null){
String result = "\" [ \\\""+escapeCode(lastCallCode)+"\\\" ]\", "+proceed();
CodeLineList p = proceed();
p.addCodeAtTheBeginning(new CodeLine("\" [ \\\""+escapeCode(lastCallCode)+"\\\" ]\", ", -1));
//String result = "\" [ \\\""+escapeCode(lastCallCode)+"\\\" ]\", "+proceed();
lastCallCode = null;
return result;
return p;
}else{
return proceed();
}
}*/
pointcut renameAgents2(CodeLineList cll) : withincode(* tree.ASTStartExpression.generateCode(..)) &&
call(CodeLineList CodeLineList.concatLast(CodeLineList)) && target(cll);
CodeLineList around(CodeLineList cll) : renameAgents2(cll){
if (cll.getCodeLine(0) != null && cll.getCodeLine(0).getCode().equals("new PseuCoThread(\"")){
cll = cll.concatLast(new CodeLineList(new CodeLine(" [ \\\""+escapeCode(lastCallCode)+"\\\" ]", -1)));
lastCallCode = null;
return cll;
}
return proceed(cll);
}
private String escapeCode(String s){
......@@ -116,7 +133,7 @@ public aspect DebuggerListeners {
}
//also the "waiting main agent"
pointcut nameMainAgent() : call(String codeGen.Code+.generateClassCode(..));
/*pointcut nameMainAgent() : call(String codeGen.Code+.generateClassCode(..));
String around() : nameMainAgent(){
if (Pseuco.debugging){
return proceed().replace("public static PseuCoThread thread = new PseuCoThread();",
......@@ -124,21 +141,31 @@ public aspect DebuggerListeners {
}else{
return proceed();
}
}
}*/
//catch multiple HWInterrupts
pointcut hwcheck() : (withincode(* tree.ASTStmtBlock.codeGen(..)) ||
withincode(* tree.ASTForStatement.codeGen(..))) && call(String shiftCode(..));
pointcut hwcheck() : (withincode(* tree.ASTStmtBlock.generateCode(..)) ||
withincode(* tree.ASTForStatement.generateCode(..))) && call(CodeLineList shiftCode(..));
String around() : hwcheck(){
String res = proceed();
CodeLineList around() : hwcheck(){
CodeLineList res = proceed();
if (Pseuco.debugging){
res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
boolean endedWithInterrupt = false;
LinkedList<CodeLine> lst = res.getCodeLineList();
for (int i = 0; i < lst.size(); i++){
String c = lst.get(i).getCode();
if (endedWithInterrupt && c.matches("^\\s*Simulate\\.HWInterrupt\\(\\);.*$")){
lst.get(i).setCode(c.replaceAll("Simulate\\.HWInterrupt\\(\\);", " "));
}
endedWithInterrupt = c.matches("^.*Simulate\\.HWInterrupt\\(\\);\\s*$");
}
//res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
//res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
//res = res.replaceAll("Simulate\\.HWInterrupt\\(\\);\\s*?Simulate\\.HWInterrupt\\(\\);", "Simulate.HWInterrupt();");
}
return res;
}
......
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