@@ -221,20 +221,20 @@ relation lookup_class: (Env.Env, Absyn.Path, bool) => (SCode.Class, Env.Env) =
221221
222222 (* Builtin classes Integer, Real, String, Boolean can not be overridden
223223 search top environment directly. *)
224- rule is_primitive(path) => true &
224+ rule is_primitive(path) => true &
225225 Env.top_frame(env) => f &
226- lookup_class_in_frame(f,[f],id,msg) => (c,env)
226+ lookup_class_in_frame(f,[f],id,msg) => (c,env)
227227 -----------------------------------
228228 lookup_class(env,path as Absyn.IDENT(id),msg) => (c,env)
229229
230- rule is_primitive(path) => true &
230+ rule is_primitive(path) => true &
231231 print "ERROR, primitive class not found on top env: "&
232232 Env.print_env_str(env) => s &
233- print s
233+ print s
234234 -------------------------------
235235 lookup_class(env,path,msg) => fail
236236
237- rule lookup_class_in_env(env,path,msgflag)
237+ rule lookup_class_in_env(env,path,msgflag)
238238 => (c as SCode.CLASS(id,_,encflag,restr,_), env')
239239 --------------------------------------
240240 lookup_class(env, path as Absyn.IDENT(name),msgflag)
@@ -243,17 +243,17 @@ relation lookup_class: (Env.Env, Absyn.Path, bool) => (SCode.Class, Env.Env) =
243243
244244 rule (* If we search for A1.A2....An.x while in scope A1.A2...An
245245 , just search for x. Must do like this to ensure finite recursion *)
246- Env.get_env_path(env) => SOME(ep) &
246+ Env.get_env_path(env) => SOME(ep) &
247247 Absyn.strip_last(p) => packp &
248248 ModUtil.path_equal(ep,packp) => true &
249249 Absyn.path_last_ident(p) => id &
250- lookup_class(env,Absyn.IDENT(id),msgflag) => (c,env')
250+ lookup_class(env,Absyn.IDENT(id),msgflag) => (c,env')
251251 --------------------------------------
252252 lookup_class(env, p as Absyn.QUALIFIED(_,_),msgflag)
253253 => (c, env')
254254
255255 (* Qualified name in non package*)
256- rule lookup_class(env,Absyn.IDENT(pack),msgflag)
256+ rule lookup_class(env,Absyn.IDENT(pack),msgflag)
257257 => (c as SCode.CLASS(id,_,encflag,restr,_),env') &
258258 Env.open_scope(env',encflag,SOME(id)) => env2 &
259259 ClassInf.start(restr,id) => ci_state &
@@ -262,28 +262,29 @@ relation lookup_class: (Env.Env, Absyn.Path, bool) => (SCode.Class, Env.Env) =
262262 => (env'',cistate1) &
263263 not ClassInf.valid(cistate1,SCode.R_PACKAGE) & (* Has to do additional check for encapsulated classes, see rule below *)
264264
265- lookup_class(env'',path,msgflag) => (c',env''')
265+ lookup_class(env'',path,msgflag) => (c',env''')
266266 --------------------------------------
267267 lookup_class(env, p as Absyn.QUALIFIED(pack,path),msgflag)
268268 => (c', env''')
269269
270270 (* Qualified names in package*)
271- rule lookup_class(env,Absyn.IDENT(pack),msgflag)
271+ rule lookup_class(env,Absyn.IDENT(pack),msgflag)
272272 => (c as SCode.CLASS(id,_,encflag,restr,_),env1) &
273273 Env.open_scope(env1,encflag,SOME(id)) => env2 &
274274 ClassInf.start(restr,id) => ci_state &
275275
276276 Inst.partial_inst_class_in(env2,Types.NOMOD,Prefix.NOPRE,
277277 Connect.empty_set,ci_state,c,false,[])
278278 => (env4,cistate1) &
279- ClassInf.valid(cistate1,SCode.R_PACKAGE) & (* Has NOT to do additional check for encapsulated classes, see rule above *)
279+ ClassInf.valid(cistate1,SCode.R_PACKAGE) & (* Has NOT to do additional check for encapsulated classes, see rule above *)
280280 lookup_class(env4,path,msgflag) => (c',env5)
281281 --------------------------------------
282282 lookup_class(env, p as Absyn.QUALIFIED(pack,path), msgflag)
283283 => (c', env5)
284284
285- rule print "-lookup_class failed\n " &
285+ rule print "-lookup_class failed " &
286286 Absyn.path_string path => s &
287+ print s & print "\n" &
287288(* Env.print_env env & *)
288289(* Print.get_string => str & print "Env: " & print str & print "\n" & *)
289290(* Print.print_buf "#Error, class " & Print.print_buf s & *)
@@ -1245,7 +1246,6 @@ relation is_in_builtin_env: Absyn.Path => bool =
12451246 -------------------------------------------------------
12461247 is_in_builtin_env(path) => fail
12471248end
1248-
12491249(** relation: lookup_class_in_env
12501250 **
12511251 ** Helper relation to lookup_class. Searches the environment for the class.
@@ -1255,38 +1255,38 @@ relation lookup_class_in_env: (Env.Env,Absyn.Path,bool)
12551255 => (SCode.Class, Env.Env) =
12561256
12571257 rule (*print "looking in env for " & print id &*)
1258- lookup_class_in_frame(frame,frame::fs,id,msg) => (c,env')
1258+ lookup_class_in_frame(frame,frame::fs,id,msg) => (c,env')
12591259 ---------------------
12601260 lookup_class_in_env(env as (frame::fs),Absyn.IDENT(id),msg)
12611261 => (c,env')
12621262
12631263 rule (* Special case if looking up the class that -is- encapsulated. That must be allowed. *)
1264- id = sid &
1264+ id = sid &
12651265 lookup_class_in_env(fs,aid,true) => (c,env)
12661266 ---------------------
12671267 lookup_class_in_env(env as Env.FRAME(SOME(sid),_,_,_,_,_,true)::fs, aid as Absyn.IDENT(id),_)
12681268 => (c,env)
12691269
1270- rule Builtin.initial_env() => i_env &
1270+ rule Builtin.initial_env() => i_env &
12711271 not lookup_class_in_env( i_env, aid,false)=>(_,_) &
12721272 Env.print_env_path_str(env) => scope &
1273- Error.add_message(Error.LOOKUP_ERROR,[id,scope])
1273+ Error.add_message(Error.LOOKUP_ERROR,[id,scope])
12741274 ---------------------
12751275 lookup_class_in_env(env as Env.FRAME(SOME(sid),_,_,_,_,_,true)::fs, aid as Absyn.IDENT(id),true) => fail
12761276
1277- rule Builtin.initial_env() => i_env &
1277+ rule Builtin.initial_env() => i_env &
12781278 not lookup_class_in_env( i_env, aid,false)=>(_,_)
12791279 ---------------------
12801280 lookup_class_in_env(Env.FRAME(sid,_,_,_,_,_,true)::fs,
12811281 aid as Absyn.IDENT(id),false) => fail
12821282
1283- rule Builtin.initial_env() => i_env &
1283+ rule Builtin.initial_env() => i_env &
12841284 lookup_class_in_env( i_env, aid,msgflag)=> (c,env')
12851285 ---------------------------------------------------
12861286 lookup_class_in_env(Env.FRAME(sid,_,_,_,_,_,true)::fs,
12871287 aid as Absyn.IDENT(id),msgflag ) => (c,env')
12881288
1289- rule lookup_class_in_env(fs,id,msgflag) => (c, env')
1289+ rule lookup_class_in_env(fs,id,msgflag) => (c, env')
12901290 -----------------------------------------------
12911291 lookup_class_in_env((f as Env.FRAME(sid,_,_,_,_,_,false))::fs,
12921292 id ,msgflag )
@@ -1597,3 +1597,16 @@ end
15971597
15981598
15991599
1600+
1601+
1602+
1603+
1604+
1605+
1606+
1607+
1608+
1609+
1610+
1611+
1612+
0 commit comments