Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3586d8387186590199577c59a9ba71dbc2462243 (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
source cs : 'ClassesCS.ecore#/'
target as : 'Classes.ecore#/'

mappings {
	map as::Root from RootCS {
		ownedPackages := ownedPackages.resolve;
	}

	map as::Package from PackageCS {
		name := name;
		ownedClasses := ownedClasses.resolve;
		ownedPackages := ownedPackages.resolve;
	}

	map as::Class from ClassCS {
		name := name;
		ownedOperations := operations.resolve;
		ownedProperties := properties.resolve;
		superClass := if _extends = null then null else resolve.lookup(Class,_extends) endif; 
	}
	
	map as::Property from PropertyCS {
		name := name;
		type := resolve.lookup(Class, typeRef); 
	}
	
	map as::Operation from OperationCS {
		name := name;
		type := resolve.lookup(Class, resultRef);
		ownedParameters := params->collect(x | classes::Parameter{ /*FIXME*/ });
		ownedExpressions := bodyExps.resolve; 
	}
	
	map as::PropertyCallExp from NameExpCS when isPropCallExp {		
		ownedCallExp := ownedNameExp?.resolve;
		referredProperty := if oclContainer().oclIsKindOf(NameExpCS) 
							then resolve.lookupFrom(Property, resolve.owningSource.type, name)
							else resolve.lookup(Property, name)
							endif;
		type := resolve.oclAsType(as::PropertyCallExp).referredProperty.type;
	}
	
	map as::OperationCallExp from NameExpCS when isOpCallExp {	
		ownedCallExp := ownedNameExp?.resolve;
		ownedArguments := roundedBrackets.args.resolve;
		referredOperation := if oclContainer().oclIsKindOf(NameExpCS) 
							then resolve.lookupFrom(Operation, resolve.owningSource.type, name, resolve.oclAsType(as::OperationCallExp).ownedArguments) /*FIXME cast */
							else resolve.lookup(Operation, name, resolve.oclAsType(as::OperationCallExp).ownedArguments) /*FIXME cast */
							endif;
		type := resolve.oclAsType(as::OperationCallExp).referredOperation.type;	
	}
	
	map as::Argument from ArgumentCS {
		name := name;
	}	
}



disambiguation {
	 NameExpCS {
	 	isOpCallExp := roundedBrackets <> null;
	 	isPropCallExp := roundedBrackets = null;
	 }
}

nameresolution {
		
	named-element NamedElement name-property name; 	  /*from target */
	name-referencer PathElementCS name-property name; /*from source */
	name-qualifier PathNameCS name-segments-property path; /*from source */
	
	Root {
		scopes 
			Package using ownedPackages;
	}
	
	Package {
		named-element 
			qualifies Package using ownedPackages,
					   Class using ownedClasses;
		
		scopes-occluding 
			Package using ownedPackages
			Class using ownedClasses;
	}

	Class {
		named-element
			qualifies Operation using ownedOperations,
					   Property using ownedProperties;
					   
		scopes-occluding
			Operation using ownedOperations occluding self->closure(superClass).ownedOperations
			Property using ownedProperties occluding self->closure(superClass).ownedProperties;
		
		exports 
			Operation using ownedOperations
	    	Property using ownedProperties; 
	}
	
	Operation {
		named-element
			filtered by args : OrderedSet(Argument)
				when args->size() = ownedParameters->size() and
						args->forAll(x | x.name = ownedParameters->at(args->indexOf(x)).name);
	}
	
	Property {
		named-element;
	}
}

helpers {
	
}

Back to the top