|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectabc.weaving.aspectinfo.Unification
public class Unification
A class for representing the unification of two Syntax objects. Two such objects s1 and s2 are unifiable if there is a syntax object s and two renamings ren1, ren2 such that ren1(s)=s1, ren2(s)=s2. In general we can replace = by 'equivalent to'. Specifically s can have more free vars than s1 or s2. In this case some vars in s are mapped to an empty VarBox by one of the renamings ren1, ren2.
This class encapsulates the renamings ren1, ren2, as well as the result s. In addition, two typemaps are stored, to give the types of free vars occurring in s1, s2 (to prevent variables of different types from being unified).
A number of special case methods are defined to get and set the Syntax result when its type is known, in particular Pointcut. A number of methods provide access to the renamings and the typemaps. The class does NOT perform unification, it just holds renamings etc in a convenient form. Most methods are duplicated for convenience, one copy for each renaming
Finally, this class contains the unifyWithFirst() property. If this is true, then the intention is that the unification to be performed should return as result s=s1, the first of the two Syntax objects. In this case unification reduces to renaming. When this holds the result value should be set to the same reference as s1, not just an equivalent syntax object. For brevity we refer to this as restricted unification.
VarBox
Constructor Summary | |
---|---|
Unification(boolean unifyWithFirst)
|
Method Summary | |
---|---|
void |
clearUnifyWithFirst()
Set the unifyWithFirst() property to false. |
boolean |
containsKey1(Var key)
Tests whether the first renaming contains a variable as a key |
boolean |
containsKey2(Var key)
Tests whether the second renaming contains a variable as a key |
boolean |
containsKeyAsString1(java.lang.String s)
Tests whether the first renaming contains this key, identified by its name |
boolean |
containsKeyAsString2(java.lang.String s)
Tests whether the second renaming contains this key, identified by its name |
boolean |
containsValue1(VarBox val)
Tests whether the first renaming contains a VarBox as a value |
boolean |
containsValue2(VarBox val)
Tests whether the second renaming contains a VarBox as a value |
boolean |
containsVarValue1(Var v)
Test whether ren1 contains a key mapping to v (ie mapping to a VarBox containing v) |
boolean |
containsVarValue2(Var v)
Test whether ren2 contains a key mapping to v (ie mapping to a VarBox containing v) |
VarBox |
get1(Var key)
Get the VarBox associated with a Var under the first renaming |
VarBox |
get2(Var key)
Get the VarBox associated with a Var under the second renaming |
ArgPattern |
getArgPattern()
Returns the result of unification as an ArgPattern |
Var |
getByValue1(VarBox val)
Get the key mapping to a value in ren1, null if there is none |
Var |
getByValue2(VarBox val)
Get the key mapping to a value in ren2, null if there is none |
Var |
getByVarValue1(Var v)
Get the key mapping to a Var value in ren1, null if there is none |
Var |
getByVarValue2(Var v)
Get the key mapping to a Var value in ren2, null if there is none |
VarBox |
getFromString1(java.lang.String s)
Get the VarBox bound to a variable of this name (if any, null otherwise) under ren1 |
VarBox |
getFromString2(java.lang.String s)
Get the VarBox bound to a variable of this name (if any, null otherwise) under ren2 |
Pointcut |
getPointcut()
Returns the result of unification as a Pointcut |
java.util.Hashtable |
getRen1()
Returns the renaming ren1 taking the result s to the first syntax s1 |
java.util.Hashtable |
getRen2()
Returns the renaming ren2 taking the result s to the first syntax s2 |
Syntax |
getSyntax()
Returns the result of unification. |
AbcType |
getType1(java.lang.String s)
Returns the type of a given free var in the first typemap |
AbcType |
getType2(java.lang.String s)
Returns the type of a given free var in the second typemap |
java.util.Hashtable |
getTypeMap(int dir)
Returns the typemap assigning types to free vars in either syntax object, depending on dir |
java.util.Hashtable |
getTypeMap1()
Returns the typemap assigning types to free vars in the first syntax object s1 |
java.util.Hashtable |
getTypeMap2()
Returns the typemap assigning types to free vars in the second syntax object s2 |
Var |
getVar()
Returns the result of unification as a Var |
boolean |
isTargetSet1(Var v)
Tests whether the VarBox that v maps to under ren1 contains a variable |
boolean |
isTargetSet2(Var v)
Tests whether the VarBox that v maps to under ren2 contains a variable |
java.util.Enumeration |
keys1()
The keys in the first renaming |
java.util.Enumeration |
keys2()
The keys in the second renaming |
void |
put1(Var key,
VarBox val)
Add a binding in the first renaming |
void |
put2(Var key,
VarBox val)
Add a binding in the second renaming |
void |
putVar1(Var key,
Var val)
Add a binding in the first renaming. |
void |
putVar2(Var key,
Var val)
Add a binding in the second renaming. |
void |
removeTargetAsString(int dir,
java.lang.String s)
Remove the target of a binding by its string name from the specified renaming. |
void |
removeTargetAsString1(java.lang.String s)
Remove the target of a binding by its string name. |
void |
removeTargetAsString2(java.lang.String s)
Remove the target of a binding by its string name. |
void |
resetBindings()
Reset the bindings (and the result) of unification BUT does not reset the typemaps |
void |
setArgPattern(ArgPattern p)
Sets the result of unification to the ArgPattern p |
void |
setPointcut(Pointcut pc)
Sets the result of unification to the pointcut pc |
void |
setSyntax(Syntax s)
Sets the result of unification to s (instanceof Syntax) |
void |
setTypeMap1(java.util.Hashtable typeMap)
Sets the typemap assigning types to free vars in the first syntax object s1 |
void |
setTypeMap2(java.util.Hashtable typeMap)
Sets the typemap assigning types to free vars in the second syntax object s2 |
void |
setUnifyWithFirst()
Set the unifyWithFirst() property to true. |
void |
setVar(Var v)
Sets the result of unification to the variable v |
boolean |
unifyWithFirst()
Returns true if restricted unification is to be done. |
java.util.Collection |
values1()
The values in the first renaming |
java.util.Collection |
values2()
The values in the second renaming |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Unification(boolean unifyWithFirst)
Method Detail |
---|
public void resetBindings()
public void setUnifyWithFirst()
public void clearUnifyWithFirst()
public boolean unifyWithFirst()
public Pointcut getPointcut()
public ArgPattern getArgPattern()
public Var getVar()
public Syntax getSyntax()
public java.util.Hashtable getRen1()
public java.util.Hashtable getRen2()
public void setPointcut(Pointcut pc)
pc
- the Pointcut result of unificationpublic void setVar(Var v)
v
- the Var result of unificationpublic void setArgPattern(ArgPattern p)
p
- the ArgPattern result of unificationpublic void setSyntax(Syntax s)
s
- the result of unification, of type Syntaxpublic void setTypeMap1(java.util.Hashtable typeMap)
typeMap
- a mapping String->AbcType giving types to free vars in s1public void setTypeMap2(java.util.Hashtable typeMap)
typeMap
- a mapping String->AbcType giving types to free vars in s2public java.util.Hashtable getTypeMap1()
public java.util.Hashtable getTypeMap2()
public java.util.Hashtable getTypeMap(int dir)
dir
- 1 for the first syntax object, 2 for the second syntax object
public AbcType getType1(java.lang.String s)
s
- the name of a free variable in the first Syntax
public AbcType getType2(java.lang.String s)
s
- the name of a free variable in the second Syntax
public java.util.Enumeration keys1()
public java.util.Enumeration keys2()
public java.util.Collection values1()
public java.util.Collection values2()
public boolean containsKey1(Var key)
key
- the variable to test for membership as a key
public boolean containsKey2(Var key)
key
- the variable to test for membership as a key
public boolean containsValue1(VarBox val)
val
- the VarBox to test for membership as a value
public boolean containsValue2(VarBox val)
val
- the VarBox to test for membership as a value
public VarBox get1(Var key)
key
- the Var to get the associated value for
public VarBox get2(Var key)
key
- the Var to get the associated value for
public void put1(Var key, VarBox val)
key
- the Var to bind under ren1val
- the VarBox to bind key topublic void put2(Var key, VarBox val)
key
- the Var to bind under ren2val
- the VarBox to bind key topublic void putVar1(Var key, Var val)
key
- the Var to bind under ren1val
- the Var to bind key topublic void putVar2(Var key, Var val)
key
- the Var to bind under ren2val
- the Var to bind key topublic Var getByValue1(VarBox val)
val
- the value to find a key in ren1 for
public Var getByValue2(VarBox val)
val
- the value to find a key in ren2 for
public boolean containsVarValue1(Var v)
v
- the Var to find as a value in ren1true
- if ren1 contains a key mapping to a VarBox containing v, false otherwisepublic boolean containsVarValue2(Var v)
v
- the Var to find as a value in ren2true
- if ren2 contains a key mapping to a VarBox containing v, false otherwisepublic Var getByVarValue1(Var v)
val
- the Var value to find a key in ren1 for
public Var getByVarValue2(Var v)
val
- the Var value to find a key in ren2 for
public void removeTargetAsString(int dir, java.lang.String s)
dir
- 1 to specify the first renaming, 2 for the second renamings
- the name of the variable (key) to remove the target binding for.public void removeTargetAsString1(java.lang.String s)
removeTargetAsString
public void removeTargetAsString2(java.lang.String s)
removeTargetAsString
public boolean containsKeyAsString1(java.lang.String s)
s
- the name of a Var to look for as a key
public boolean containsKeyAsString2(java.lang.String s)
s
- the name of a Var to look for as a key
public VarBox getFromString1(java.lang.String s)
s
- the name of the variable used as a key
public VarBox getFromString2(java.lang.String s)
s
- the name of the variable used as a key
public boolean isTargetSet1(Var v)
v
- the Var to get the binding from ren1 for. NOTE that this assumes that
v is bound to a value by ren1
public boolean isTargetSet2(Var v)
v
- the Var to get the binding from ren1 for. NOTE that this assumes that
v is bound to a value by ren2
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |