From 1c526e586ae3716fc1ada61e7af588c1dbff44e6 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 15 Apr 2004 22:05:22 +0000 Subject: [PATCH] Checking in some checks... --- Repair/RepairCompiler/MCC/IR/DotExpr.java | 7 +++++++ Repair/RepairCompiler/MCC/IR/Expr.java | 4 ++++ Repair/RepairCompiler/MCC/IR/OpExpr.java | 6 ++++-- Repair/RepairCompiler/MCC/IR/Updates.java | 6 ++++++ Repair/RepairCompiler/MCC/IR/VarExpr.java | 4 ++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Repair/RepairCompiler/MCC/IR/DotExpr.java b/Repair/RepairCompiler/MCC/IR/DotExpr.java index 1c5fb47..fbd217d 100755 --- a/Repair/RepairCompiler/MCC/IR/DotExpr.java +++ b/Repair/RepairCompiler/MCC/IR/DotExpr.java @@ -282,6 +282,13 @@ public class DotExpr extends Expr { } } + public boolean isValue() { + FieldDescriptor tmpfd=fd; + if (tmpfd instanceof ArrayDescriptor) + tmpfd=((ArrayDescriptor)tmpfd).getField(); + return (tmpfd.getPtr()||(tmpfd.getType() instanceof ReservedTypeDescriptor)); + } + boolean typechecked=false; public TypeDescriptor typecheck(SemanticAnalyzer sa) { if (typechecked) diff --git a/Repair/RepairCompiler/MCC/IR/Expr.java b/Repair/RepairCompiler/MCC/IR/Expr.java index 596c125..1e13217 100755 --- a/Repair/RepairCompiler/MCC/IR/Expr.java +++ b/Repair/RepairCompiler/MCC/IR/Expr.java @@ -40,6 +40,10 @@ public abstract class Expr { return null; } + public boolean isValue() { + return false; + } + public int[] getRepairs(boolean negated) { System.out.println(this.getClass().getName()); throw new Error("Unrecognized EXPR"); diff --git a/Repair/RepairCompiler/MCC/IR/OpExpr.java b/Repair/RepairCompiler/MCC/IR/OpExpr.java index 8693aa3..c7cdd0d 100755 --- a/Repair/RepairCompiler/MCC/IR/OpExpr.java +++ b/Repair/RepairCompiler/MCC/IR/OpExpr.java @@ -15,6 +15,8 @@ public class OpExpr extends Expr { } public static boolean isInt(Expr e) { + if (e==null) + return false; if ((e instanceof IntegerLiteralExpr)|| ((e instanceof OpExpr)&&(((OpExpr)e).opcode==Opcode.NOP)&&(((OpExpr)e).getLeftExpr() instanceof IntegerLiteralExpr))) return true; @@ -35,8 +37,8 @@ public class OpExpr extends Expr { (isInt(left)&&(opcode==Opcode.RND))) { this.opcode=Opcode.NOP; this.right=null; - int lint=getInt(left); - int rint=getInt(right); + int lint=isInt(left)?getInt(left):0; + int rint=isInt(right)?getInt(right):0; int value=0; if (opcode==Opcode.ADD) { value=lint+rint; diff --git a/Repair/RepairCompiler/MCC/IR/Updates.java b/Repair/RepairCompiler/MCC/IR/Updates.java index 5e3652b..a4e6d80 100755 --- a/Repair/RepairCompiler/MCC/IR/Updates.java +++ b/Repair/RepairCompiler/MCC/IR/Updates.java @@ -23,6 +23,8 @@ class Updates { } public Updates(Expr lexpr, Expr rexpr, Opcode op, boolean negate) { + if (!lexpr.isValue()) + System.out.println("Building invalid update"); leftexpr=lexpr; type=Updates.EXPR; if (negate) { @@ -92,6 +94,8 @@ class Updates { } public Updates(Expr lexpr, Expr rexpr) { + if (!lexpr.isValue()) + System.out.println("Building invalid update"); leftexpr=lexpr; rightexpr=rexpr; type=Updates.EXPR; @@ -99,6 +103,8 @@ class Updates { } public Updates(Expr lexpr, int rpos) { + if (!lexpr.isValue()) + System.out.println("Building invalid update"); leftexpr=lexpr; rightposition=rpos; type=Updates.POSITION; diff --git a/Repair/RepairCompiler/MCC/IR/VarExpr.java b/Repair/RepairCompiler/MCC/IR/VarExpr.java index 51e916a..fcec02c 100755 --- a/Repair/RepairCompiler/MCC/IR/VarExpr.java +++ b/Repair/RepairCompiler/MCC/IR/VarExpr.java @@ -69,6 +69,10 @@ public class VarExpr extends Expr { return vd; } + public boolean isValue() { + return vd.isGlobal(); + } + public void generate(CodeWriter writer, VarDescriptor dest) { // #TBD#: bit of a hack, really should have been type checked properly -- 2.34.1