TypeReferences.jrag 1.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
aspect User_Types {
  syn String Type.getTypeName();
  eq Type.getTypeName() = getClass().getName();
  eq PrimType.getTypeName() = getName();
  eq UserType.getTypeName() = getName();

  syn boolean Type.isUserType();
  eq Type.isUserType() = false;
  eq UserType.isUserType() = true;
}

aspect Type_References {
 
  // The dependencies on other type declarations for a Decl.
  coll Set<Decl> Decl.type_dependencies() [new HashSet<Decl>()] with add;

  Field contributes ((UserType)getType()).decl()   
  when parentDecl() != null && getType().isUserType()
  to Decl.type_dependencies() 
  for parentDecl();

  UserType contributes decl()   
  when parentDecl() != null 
  to Decl.type_dependencies() 
  for parentDecl();
  /*
  Field contributes getType().decl()   
  when parentDecl() != null && getType().isLeafType()
  to Decl.type_dependencies() 
  for parentDecl();
  */


  // The references from other type declarations to a Decl.
  coll Set<Decl> Decl.type_references() [new HashSet<Decl>()] with add;

  Decl contributes this
  to Decl.type_references()
  for each type_dependencies();

  syn boolean Decl.hasDependencies();
  eq Decl.hasDependencies() = !type_dependencies().isEmpty();

  syn boolean Decl.isReferenced();
  eq Decl.isReferenced() = !type_references().isEmpty();
}