@@ -80,9 +80,14 @@ let verify_name s env current_env =
80
80
if (Hashtbl. mem current_env.variables s) <> true then
81
81
begin
82
82
(* second find in global env *)
83
- if (Hashtbl. mem (Hashtbl. find env current_env.this_class).attributes s) <> true
84
- then raise(UnknownVariable (s))
85
- else Some (Hashtbl. find (Hashtbl. find env current_env.this_class).attributes s)
83
+ if (Hashtbl. mem (Hashtbl. find env current_env.this_class).attributes s) = true
84
+ then Some (Hashtbl. find (Hashtbl. find env current_env.this_class).attributes s)
85
+ else
86
+ begin
87
+ if (Hashtbl. mem env s) = true then
88
+ Some (Ref ({ tpath = [] ; tid = s }))
89
+ else raise(UnknownVariable (s))
90
+ end
86
91
end
87
92
else Some (Hashtbl. find current_env.variables s)
88
93
@@ -169,10 +174,25 @@ let rec verify_expression env current_env e =
169
174
e.etype < - verify_call_expr m al env current_env.this_class
170
175
| Some c ->
171
176
List. iter (verify_expression env current_env) al;
172
- let class_name = string_of_expression(c) in
173
- e.etype < - verify_call_expr m al env class_name
177
+ verify_expression env current_env c;
178
+ (match c.etype with
179
+ | Some t ->
180
+ let class_name = stringOf t in
181
+ e.etype < - verify_call_expr m al env class_name
182
+ | None -> () )
174
183
)
175
- | Attr (r ,a ) -> () (* TODO*)
184
+ | Attr (r ,a ) ->
185
+ (* we consider only the case when r is the name of the class and r has no type for the moment *)
186
+ verify_expression env current_env r;
187
+ (match r.etype with
188
+ | Some t ->
189
+ let class_name = stringOf t in
190
+ let attrs_table = (Hashtbl. find env class_name).attributes in
191
+ if (Hashtbl. mem attrs_table a) <> true then
192
+ raise(UnknownAttribute (a, class_name))
193
+ else
194
+ e.etype < - Some (Hashtbl. find attrs_table a)
195
+ | None -> () )
176
196
| If (e1 , e2 , e3 ) -> () (* TODO*)
177
197
| Val v ->
178
198
e.etype < - verify_value v
0 commit comments