Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 449 remove commented code #648

Merged
merged 4 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions col/src/main/java/vct/col/ast/print/AbstractPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void pre_visit(ASTNode node){
}
Origin o=node.getOrigin();
if (o==null){
//throw new Error("found "+node.getClass()+" without origin");
o=missing;
}
out.enter(node.getOrigin());
Expand Down Expand Up @@ -153,7 +152,6 @@ public void visit(NameExpression e){
}

public void visit(MethodInvokation e){
//boolean statement=!in_expr;
setExpr();
if (e.object()!=null) {
// TODO: manage precedence properly.
Expand Down
20 changes: 3 additions & 17 deletions col/src/main/java/vct/col/ast/print/CPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void pre_visit(ASTNode node) {
nextExpr();
lbl.accept(this);
out.printf(":");
// out.printf("[");
}
}

Expand All @@ -53,10 +52,7 @@ public void visit(PrimitiveType t){
}

public void visit(ASTClass cl){
//if (cl.getDynamicCount()>0) {
// Fail("dynamic entries are illegal in C");
//}
for(ASTNode item:cl.dynamicMembers()){
for(ASTNode item:cl.dynamicMembers()){
item.accept(this);
}
for(ASTNode item:cl.staticMembers()){
Expand Down Expand Up @@ -97,7 +93,7 @@ public void visit(Contract c){
}
public void visit(Method m){
Contract c=m.getContract();
if (c!=null) visit(c); //c.accept(this);
if (c!=null) visit(c);
nextExpr();
m.getReturnType().accept(this);
out.printf(" %s(",m.getName());
Expand Down Expand Up @@ -161,17 +157,7 @@ public void visit(LoopStatement l){
super.visit(l);
}
}

/*
public void visit(ConstantExpression ce){
if (ce.value instanceof StringValue){
out.print("\""+org.apache.commons.lang3.StringEscapeUtils.escapeJava(ce.toString())+"\"");
} else {
out.print(ce.toString());
}
}
*/


public void visit(ReturnStatement s){
if (s.getExpression()==null){
out.printf("return");
Expand Down
49 changes: 0 additions & 49 deletions col/src/main/java/vct/col/ast/print/JavaPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void pre_visit(ASTNode node){
nextExpr();
lbl.accept(this);
out.printf(":");
//out.printf("[");
}
if (node.annotated()) for(ASTNode ann:node.annotations()) {
if (ann==null){
Expand Down Expand Up @@ -303,12 +302,10 @@ public void visit(ASTSpecial s){
case Goto:
out.print("goto ");
s.args[0].accept(this);
//out.println(";");
break;
case Label:
out.print("label ");
s.args[0].accept(this);
//out.println(";");
break;
case With:
out.print("WITH");
Expand Down Expand Up @@ -616,7 +613,6 @@ public void visit(ASTClass cl){
for(ASTNode item:cl){
if (item.isStatic()){
if (item instanceof DeclarationStatement) out.printf("static ");
// else out.println("/* static */");
}
item.accept(this);
out.println("");
Expand Down Expand Up @@ -788,37 +784,6 @@ private void visitVeriFast(Contract contract) {
}

public void visit(IfStatement s){
/* CaseSet conflicts with send/recv in ghost mode!
if (s.isValidFlag(ASTNode.GHOST) && s.getFlag(ASTNode.GHOST)){
int N=s.getCount();
out.printf ("/*@ CaseSet[");
for(int i=0;i<N;i++){
if (i>0) out.printf (" @ ");
out.printf("(");
nextExpr();
s.getGuard(i).accept(this);
out.printf(",");
ASTNode n=s.getStatement(i);
if (n instanceof BlockStatement){
BlockStatement block=(BlockStatement)n;
int M=block.getLength();
for(int j=0;j<M;j++){
if(j>0) out.printf(";");
nextExpr();
block.getStatement(j).accept(this);
}
} else {
Abort("statement in caseset is not a block at %s",n.getOrigin());
}
out.printf(")");
if(i==N-1){
out.lnprintf("];");
} else {
out.lnprintf(",");
}
}
out.lnprintf(" @ * /");
} else {*/
int N=s.getCount();
out.printf("if (");
nextExpr();
Expand All @@ -845,7 +810,6 @@ public void visit(IfStatement s){
out.lnprintf(";");
}
}
//}
}

private boolean self_terminating(ASTNode s) {
Expand Down Expand Up @@ -1125,18 +1089,6 @@ public void visit(MethodInvokation s){
} else {
super.visit(s);
}
//if (s.get_before()!=null){
// out.printf("/*@ ");
// out.printf("with ");
// s.get_before().accept(this);
// out.printf(" */");
//}
//if (s.get_after()!=null){
// out.printf("/*@ ");
// out.printf("then ");
// s.get_after().accept(this);
// out.printf(" */");
//}
}


Expand Down Expand Up @@ -1361,7 +1313,6 @@ public void visit(ParallelRegion region){
}

public void visit(ConstantExpression ce){
//if (!in_expr) Abort("constant %s outside of expression for %s",ce,ce.getOrigin());
if (ce.value() instanceof StringValue){
out.print("\""+StringEscapeUtils.escapeJava(ce.toString())+"\"");
} else {
Expand Down
9 changes: 1 addition & 8 deletions col/src/main/java/vct/col/ast/print/PVLPrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public void pre_visit(ASTNode node){
nextExpr();
lbl.accept(this);
out.printf(":");
//out.printf("[");
}
if (node.annotated()) for(ASTNode ann:node.annotations()) {
if (ann==null){
Expand Down Expand Up @@ -296,12 +295,10 @@ public void visit(ASTSpecial s){
case Goto:
out.print("goto ");
s.args[0].accept(this);
//out.println(";");
break;
case Label:
out.print("label ");
s.args[0].accept(this);
//out.println(";");
break;
case With:
out.print("WITH");
Expand Down Expand Up @@ -568,7 +565,6 @@ public void visit(ASTClass cl){
}
if (item.isStatic()){
if (item instanceof DeclarationStatement) out.printf("static ");
// else out.println("/* static */");
}
item.accept(this);
out.println("");
Expand Down Expand Up @@ -648,9 +644,7 @@ public void visit(Method m){
if (m.getKind()==Method.Kind.Pure){
out.printf("pure ");
}
if (m.getKind()==Method.Kind.Constructor){
// out.printf("/*constructor*/ ");
} else {
if (m.getKind()!=Method.Kind.Constructor){
result_type.accept(this);
out.printf(" ");
}
Expand Down Expand Up @@ -728,7 +722,6 @@ public void visit(IfStatement s){
out.lnprintf(";");
}
}
//}
}

private boolean self_terminating(ASTNode s) {
Expand Down
1 change: 0 additions & 1 deletion col/src/main/java/vct/col/ast/stmt/decl/NameSpace.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public NameSpace add(ASTNode item) {
} else if (item==null) {
} else {
hre.lang.System.Warning("cannot insert %s into name space.",item);
//Abort("cannot insert %s into name space.",item.getClass());
}
return this;
}
Expand Down
15 changes: 0 additions & 15 deletions col/src/main/java/vct/col/ast/stmt/decl/ProgramUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,7 @@ public Iterable<ASTDeclaration> get(){
private HashMap<ClassName,Method> adt_map=new HashMap<ClassName,Method>();

private HashMap<ClassName,Method> proc_map=new HashMap<ClassName,Method>();

/*
public void addClass(ClassName name,ASTClass cl){
classes.put(name,cl);
cl.attach(this,name);
}

public void addClass(String name[],ASTClass cl){
addClass(new ClassName(name),cl);
}

public void addClass(ClassType type,ASTClass cl){
addClass(type.getNameFull(),cl);
}
*/

/**
* Create an empty program unit.
*/
Expand Down
3 changes: 0 additions & 3 deletions col/src/main/java/vct/col/ast/syntax/CSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ public static void setCommon(Syntax syntax){

syntax.addPrimitiveType(PrimitiveSort.Double,"double");
syntax.addPrimitiveType(PrimitiveSort.Integer,"int");
//syntax.addPrimitiveType(Fraction,"frac");
syntax.addPrimitiveType(PrimitiveSort.Long,"long");
syntax.addPrimitiveType(PrimitiveSort.Void,"void");
//syntax.addPrimitiveType(Resource,"resource");
syntax.addPrimitiveType(PrimitiveSort.Boolean,"bool");
//syntax.addPrimitiveType(Class,"classtype");
syntax.addPrimitiveType(PrimitiveSort.Char,"char");
syntax.addPrimitiveType(PrimitiveSort.Float,"float");

Expand Down
66 changes: 7 additions & 59 deletions col/src/main/java/vct/col/ast/syntax/PVLSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public static PVLSyntax get(){
syntax.addPostfix(PostDecr,"--",140);
syntax.addOperator(NewArray,-1,"new ","[","]");
syntax.addOperator(Subscript,145,"","[","]"); // TODO: check if relative order to Select is OK!
//syntax.addInfix(SubType,"<:",90);
//syntax.addInfix(SuperType,":>",90);
syntax.addInfix(Implies,"==>",30);
//syntax.addInfix(IFF,"<==>",30);
syntax.addInfix(Implies,"==>",30);
syntax.addLeftFix(Wand,"-*",30);
syntax.addFunction(Perm,"Perm");
syntax.addFunction(HistoryPerm,"HPerm");
Expand All @@ -51,13 +48,10 @@ public static PVLSyntax get(){
syntax.addFunction(Empty,"isEmpty");
syntax.addFunction(RemoveAt, "removeAt");
syntax.addFunction(SeqPermutation, "permutationOf");
//syntax.addFunction(Head,"head");
//syntax.addFunction(Tail,"tail");
syntax.addFunction(Value,"Value");
syntax.addFunction(Value,"Value");

syntax.addFunction(PointsTo,"PointsTo");
syntax.addFunction(IterationOwner,"\\owner");
//syntax.addFunction(ArrayPerm,"ArrayPerm");
syntax.addFunction(Old,"\\old");

syntax.addFunction(OptionSome, "Some");
Expand Down Expand Up @@ -96,33 +90,13 @@ public static PVLSyntax get(){
syntax.addLeftFix(Plus,"+",110);
syntax.addLeftFix(Minus,"-",110);

/*
// 10 shift << >> >>>
syntax.addInfix(LeftShift,"<<", 100);
syntax.addInfix(RightShift,">>", 100);
syntax.addInfix(UnsignedRightShift,">>", 100);
// 9 relational < > <= >= instanceof
*/
syntax.addInfix(LT,"<",90);
syntax.addInfix(LT,"<",90);
syntax.addInfix(LTE,"<=",90);
syntax.addInfix(GT,">",90);
syntax.addInfix(GTE,">=",90);
/*
syntax.addInfix(Instance," instanceof ",90);
// 8 equality == !=
* */
syntax.addInfix(EQ,"==",80);
syntax.addInfix(NEQ,"!=",80);
/*
// 7 bitwise AND &
syntax.addInfix(BitAnd,"&",70);
// 6 bitwise exclusive OR ^
syntax.addInfix(BitXor,"^",60);
// 5 bitwise inclusive OR |
syntax.addInfix(BitOr,"|",50);
// 4 logical AND &&
*/
syntax.addLeftFix(And,"&&",40);
syntax.addLeftFix(And,"&&",40);
syntax.addLeftFix(Star,"**",40);
// 3 logical OR ||
syntax.addLeftFix(Or,"||",30);
Expand All @@ -135,43 +109,17 @@ public static PVLSyntax get(){
*/
syntax.addRightFix(Assign,"=",10);

/*
syntax.addRightFix(AddAssign,"+=",10);
syntax.addRightFix(SubAssign,"-=",10);
syntax.addRightFix(MulAssign,"*= ",10);
syntax.addRightFix(DivAssign,"/=",10);
syntax.addRightFix(RemAssign,"%=",10);
syntax.addRightFix(AndAssign,"&=",10);
syntax.addRightFix(XorAssign,"^=",10);
syntax.addRightFix(OrAssign,"|=",10);
syntax.addRightFix(ShlAssign,"<<=",10);
syntax.addRightFix(ShrAssign,">>=",10);
syntax.addRightFix(SShrAssign,">>>=",10);

syntax.addPrimitiveType(Double,"double");
*/
syntax.addPrimitiveType(PrimitiveSort.Integer,"int");
syntax.addPrimitiveType(PrimitiveSort.Integer,"int");
syntax.addPrimitiveType(PrimitiveSort.ZFraction,"zfrac");
syntax.addPrimitiveType(PrimitiveSort.Fraction,"frac");
//syntax.addPrimitiveType(Long,"long");
syntax.addPrimitiveType(PrimitiveSort.Void,"void");
syntax.addPrimitiveType(PrimitiveSort.Resource,"resource");
syntax.addPrimitiveType(PrimitiveSort.Boolean,"boolean");
syntax.addPrimitiveType(PrimitiveSort.Process,"process");
syntax.addPrimitiveType(PrimitiveSort.String,"string");
syntax.addPrimitiveType(PrimitiveSort.Map,"map");

/*
syntax.addPrimitiveType(Class,"classtype");
syntax.addPrimitiveType(Char,"char");
syntax.addPrimitiveType(Float,"float");
*/
//syntax.addPrimitiveType(UInteger,"/*unsigned*/ int");
//syntax.addPrimitiveType(ULong,"/*unsigned*/ long");
//syntax.addPrimitiveType(UShort,"/*unsigned*/ short");
//syntax.addPrimitiveType(Short,"short");

syntax.addReserved(FullPerm,"write");

syntax.addReserved(FullPerm,"write");
syntax.addReserved(ReadPerm,"read");
syntax.addReserved(NoPerm,"none");
syntax.addReserved(EmptyProcess,"empty");
Expand Down
8 changes: 1 addition & 7 deletions col/src/main/java/vct/col/ast/syntax/Syntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,7 @@ public void addReserved(ASTReserved word,String string) {
syntax2reserved.put(string,word);
}

/*
public Iterable<String> reserved(){
return reserved2syntax.keySet();
}
*/

public boolean is_reserved(String text) {
public boolean is_reserved(String text) {
return syntax2reserved.containsKey(text);
}

Expand Down
1 change: 0 additions & 1 deletion col/src/main/java/vct/col/ast/type/PrimitiveType.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public boolean supertypeof(ProgramUnit context, Type t) {
}
if (t instanceof PrimitiveType){
PrimitiveType pt=(PrimitiveType)t;
//Warning("testing (%s/%s)",this.sort,pt.sort);
if (equals(pt)) return true;
switch(this.sort){
case Void:
Expand Down
1 change: 0 additions & 1 deletion col/src/main/java/vct/col/ast/util/ASTFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ public OperatorExpression new_record(Type type,ASTNode ... args){
* Create an instantiation of a new object and invoke a constructor on it.
*/
public MethodInvokation new_object(ClassType type,ASTNode ... args){
//return expression(StandardOperator.Build,type,args);
return invokation(null,type,Method.JavaConstructor, args);
}

Expand Down
Loading