Commit dfa62f13 authored by Peter's avatar Peter
Browse files

dev

parent 70ff03f6
Loading
Loading
Loading
Loading
Loading
−1
Changes for src/main/java/hk/quantr/verilogcompiler/VerilogHelper.java: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -118,7 +118,6 @@ public class VerilogHelper {
								delta++;
							}
							delta--;
							// end add to macroListing

							rewriter.replace(token, macroBody);
							rewriter.delete(token.getTokenIndex() - 1); // delete `
+3 −1
Changes for src/main/java/hk/quantr/verilogcompiler/listener/preprocess/VerilogPreProcessorListener.java: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -34,13 +34,15 @@ public class VerilogPreProcessorListener extends VerilogParserBaseListener {
//		int noOfTab = StringUtils.countMatches(line, "\t");

		int lineNo = ctx.stop.getLine() - 1;
		System.out.println(lineNo);
//		System.out.println(">>>>" + lineNo + " = " + ctx.getText());

		MacroListing parentMacro = ps.getByLastLineNo(lineNo, ps.getMaxParseNo());
		if (parentMacro == null) {
			System.out.println("shit " + lineNo);
			System.exit(929);
		}
		parentMacro.children.add(new MacroListing(parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, "$display(" + ctx.variable_lvalue().getText() + ");", MacroListing.Type.PROFILING));
		parentMacro.children.add(new MacroListing(parentMacro.parseNo + 1, lineNo, parentMacro.originalLineNo, lineNo + " >> $display(" + ctx.variable_lvalue().getText() + ");", MacroListing.Type.PROFILING));
	}

	@Override
+1 −1
Changes for src/main/java/hk/quantr/verilogcompiler/macro/MacroListing.java: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class MacroListing {
//		if (type == Type.MACRO) {
//			return lineNo + "\t" + secondLineNo + "\t" + type + "(" + uuid + ")" + "\t" + line;
//		} else {
		return originalLineNo + "    " + lineNo + "    " + type + "    " + line.trim();
		return originalLineNo + "    " + lineNo + "    " + type + "    " + line.trim() + " >> " + children.isEmpty();
//		}
	}

+27 −5
Changes for src/main/java/hk/quantr/verilogcompiler/macro/ParseStructure.java: 27 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ package hk.quantr.verilogcompiler.macro;

import hk.quantr.verilogcompiler.macro.MacroListing.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;

@@ -72,7 +74,7 @@ public class ParseStructure {
	public int getMaxParseNo() {
		int parseNo = -1;
		for (MacroListing temp : fatternMacroListing()) {
			if (temp.parseNo > parseNo) {
			if (temp.type != Type.PROFILING && temp.parseNo > parseNo) {
				parseNo = temp.parseNo;
			}
		}
@@ -98,14 +100,34 @@ public class ParseStructure {
	}

	public MacroListing getByLastLineNo(int lineNo, int parseNo) {
		ArrayList<MacroListing> temp = fatternMacroListing();
		int bingoX = 0;
		List<MacroListing> temp = fatternMacroListing().stream().filter(c -> c.type != Type.PROFILING && c.children.isEmpty()).collect(Collectors.toList());
		int bingoX = -1;
		if (lineNo == 83) {
			System.out.println("");
		}
		for (int x = temp.size() - 1; x >= 0; x--) {
			if (temp.get(x).type!=Type.PROFILING && temp.get(x).lineNo <= lineNo && temp.get(x).parseNo == parseNo) {
			if (x == 130) {
				System.out.println("");
			}
			if (temp.get(x).lineNo <= lineNo && temp.get(x).parseNo == parseNo) {
				bingoX = x;
				break;
			}
		}
		if (bingoX == -1) {
			System.err.println("bingoX is -1");
		}
		return temp.get(bingoX + (lineNo - temp.get(bingoX).lineNo));
		int delta = lineNo - temp.get(bingoX).lineNo;
//		int tempDelta = bingoX;
//		MacroListing deltaMacroListing = temp.get(tempDelta);
//		while (delta > 0) {
//			if (deltaMacroListing.children.stream().filter(c -> c.type != Type.PROFILING).count() == 0) {
//				delta--;
//			}
//			tempDelta++;
//			deltaMacroListing = temp.get(tempDelta);
//		}
		return temp.get(bingoX + delta);
	}

}