Skip to content

Commit

Permalink
tidy: remove superfluous def main methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoulter committed May 27, 2024
1 parent 37a6a42 commit aaba039
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 183 deletions.
52 changes: 0 additions & 52 deletions src/main/scala/edu/nus/worksheet/WorksheetifyScratch.scala

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/scala/edu/nus/worksheet/instrumentor/CDecl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,4 @@ object CDecl {
val tooler = new GibberishPhase(tokens);
tooler.visit(tree);
}

def runDeclaration(input: String) = {
println(input);
println(gibberishToEnglish(input));
println();
}

def main(args: Array[String]) = {
runDeclaration("int x;");
runDeclaration("int x[4];");
runDeclaration("int *x;");

runDeclaration("int *x[3];");
runDeclaration("int (*x[5])[3];");
runDeclaration("int x[5][3];");

runDeclaration("int *(*x)[3];");
runDeclaration("int (**x)[3];");
runDeclaration("int **x[3];");

runDeclaration("int (*x)(void);");

runDeclaration("int (*x)(int*, int, int[5]);");
}
}
12 changes: 0 additions & 12 deletions src/main/scala/edu/nus/worksheet/instrumentor/CProgram.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,3 @@ class CProgram(
// The ProcessBuilder of the compiled CProgram.
def process(): ProcessBuilder = Process(programPath());
}

object CProgram {
def main(args: Array[String]): Unit = {
val inputFileIS =
getClass().getClassLoader().getResourceAsStream("hello.c");
val inputString = Source.fromInputStream(inputFileIS).mkString;

val p = new CProgram(inputString);
p.compile();
p.process() !;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ object FindCompiler {
throw new RuntimeException("Could not find compiler on PATH.");
}
}

def main(args: Array[String]): Unit = {
println("CC: " + findCompilerOnPath());
}
}
29 changes: 0 additions & 29 deletions src/main/scala/edu/nus/worksheet/instrumentor/HeaderUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -192,33 +192,4 @@ object HeaderUtils {

def addSymbolsOfHeaderToScope(header: String, scope: Scope) =
getSymbolsOfHeader(header).foreach(scope.defineSymbol);

def main(args: Array[String]): Unit = {
// String that can be sent down a wire
println("Get CTypes of Stdio.h");
getTypedefsOfHeader("stdio.h");
println("Get CTypes of Stdio.h");
getTypedefsOfHeader("stdio.h");
println("Get CTypes of Stdio.h");
getTypedefsOfHeader("stdio.h");

// val pt = PrimitiveType("x", "int");
// val ptrT = new PointerType("p", pt);
//
// val res = pt.asJson;
// val resStr : String = pt.asJson.spaces2;
//
// println(res.spaces2);
//
// val res2 = ptrT.asJson;
// println(res2.spaces2);
//
// res2.spaces2.decodeOption[CType] match {
// case Some(ct) => {
// println(s"Decoded res2 to $ct");
// }
// case None =>
// println("Couldn't decode res2.");
// }
}
}
29 changes: 0 additions & 29 deletions src/main/scala/edu/nus/worksheet/instrumentor/Instrumentor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -641,33 +641,4 @@ object Instrumentor {
val tooler = instrumentorFor(inputProgram, nonce);
tooler.getInstrumentedProgram();
}

def main(args: Array[String]): Unit = {
val inputProgram = """#include <stdio.h>
int main() {
int x = 3;
int y;
x = 3;
y = 0;
struct MyPoint { int x; int y; };
struct MyPoint p = { 3, 5 };
struct MyPoint q = { 3, 5 };
p = q;
printf("this is line 7 (starting from 1)");
for (int i = 0; i < 5; i++) {
// worksheet filter iteration == 3
}
// Don't want to see *this* comment, though. THREE
for (y = 0; y < 3; y = y + 1) {
// worksheet filter iteration == 7
}
}
""";
println(instrument(inputProgram));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,4 @@ object StringConstruction {
.flatten
.toSeq;
}

def main(args: Array[String]): Unit = {
val cts = getCTypesOfHeader("stdio.h");

for ct <- cts do {
println(ct.id);
}
}
}
25 changes: 0 additions & 25 deletions src/main/scala/edu/nus/worksheet/instrumentor/TypeInference.scala
Original file line number Diff line number Diff line change
Expand Up @@ -644,29 +644,4 @@ object TypeInference {

return tooler.visit(tree);
}

def p_inferType(program: String, of: String): CType = {
println("TypeInfer " + of);
val t = inferType(program, of);
println(t);
println();
return t;
}

def main(args: Array[String]): Unit = {
p_inferType(null, "5");
p_inferType(null, "5.34");
p_inferType(null, "'x'");

p_inferType(null, "\"Abc\"");
p_inferType(null, "\"Abc\" \"def\"");
p_inferType(null, "(5)");
p_inferType(("int x;"), "x");

p_inferType(("int x[2] = {1,2};"), "x[0]");
p_inferType(("struct {int x;} s;"), "s.x");
p_inferType(("struct S {int x;} s; struct S *p = &s;"), "p->x");
p_inferType(("int i;"), "i++");
println("Done");
}
}

0 comments on commit aaba039

Please sign in to comment.