From 7d54933f37c946695d74d70abce166497fa39468 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 6 Mar 2009 18:41:05 +0000 Subject: [PATCH] Support cast nodes --- .../OwnershipAnalysis/OwnershipAnalysis.java | 30 ++++++++++++++++--- .../OwnershipAnalysis/OwnershipGraph.java | 24 ++++++++++++++- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index 2e093ef5..ac17f9bf 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -274,6 +274,9 @@ public class OwnershipAnalysis { // special field descriptors for array elements private Hashtable mapTypeToArrayField; + // special field descriptors for variables with type, no field name + private Hashtable mapTypeToVarField; + // a special temp descriptor for setting more than one parameter label // to the all-aliased-parameters heap region node @@ -325,6 +328,9 @@ public class OwnershipAnalysis { mapTypeToArrayField = new Hashtable(); + mapTypeToVarField = + new Hashtable(); + if( writeAllDOTs ) { mapMethodContextToNumUpdates = new Hashtable(); } @@ -675,6 +681,26 @@ public class OwnershipAnalysis { } break; + case FKind.FlatCastNode: + FlatCastNode fcn = (FlatCastNode) fn; + lhs = fcn.getDst(); + rhs = fcn.getSrc(); + TypeDescriptor td = fcn.getType(); + assert td != null; + + FieldDescriptor fd = mapTypeToVarField.get( td ); + if( fd == null ) { + fd = new FieldDescriptor(new Modifiers(Modifiers.PUBLIC), + td, + "", + null, + false); + mapTypeToVarField.put( td, fd ); + } + + og.assignTypedTempXEqualToTempY(lhs, rhs, fd); + break; + case FKind.FlatFieldNode: FlatFieldNode ffn = (FlatFieldNode) fn; lhs = ffn.getDst(); @@ -729,10 +755,6 @@ public class OwnershipAnalysis { assert lhs.getType().isArray(); TypeDescriptor tdElement = lhs.getType().dereference(); - - System.out.println( "lhs.Type = "+lhs.getType().toPrettyString() ); - System.out.println( "tdElement = "+tdElement.toPrettyString() ); - FieldDescriptor fdElement = mapTypeToArrayField.get( tdElement ); if( fdElement == null ) { fdElement = new FieldDescriptor(new Modifiers(Modifiers.PUBLIC), diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index 5aafa3ac..13abf6f7 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -407,6 +407,28 @@ public class OwnershipGraph { } + public void assignTypedTempXEqualToTempY(TempDescriptor x, + TempDescriptor y, + FieldDescriptor f) { + + LabelNode lnX = getLabelNodeFromTemp(x); + LabelNode lnY = getLabelNodeFromTemp(y); + + clearReferenceEdgesFrom(lnX, null, true); + + Iterator itrYhrn = lnY.iteratorToReferencees(); + while( itrYhrn.hasNext() ) { + ReferenceEdge edgeY = itrYhrn.next(); + HeapRegionNode referencee = edgeY.getDst(); + ReferenceEdge edgeNew = edgeY.copy(); + edgeNew.setSrc(lnX); + edgeNew.setFieldDesc(f); + + addReferenceEdge(lnX, referencee, edgeNew); + } + } + + public void assignTempXEqualToTempYFieldF(TempDescriptor x, TempDescriptor y, FieldDescriptor f) { @@ -1800,7 +1822,7 @@ public class OwnershipGraph { // if the type is not a class don't match because // primitives are copied, no memory aliases ClassDescriptor cdDst = tdDst.getClassDesc(); - if( cdDst == null ) { + if( cdDst == null && !tdDst.isArray() ) { return false; } -- 2.34.1