def Import(modid, modid1): global nofmod if modid1 == "SYSTEM": thismod = ThisModule(modid, modid1, True, key=0) # FIXME I added the 0 SPF nofmod -= 1 thismod.lev = 0 thismod.dsc = system thismod.rdo = True else: fname = MakeFileName(modid1, ".smb") R = Files.Old(fname) if R != None: # Files.Set(R, F, 0) Files.ReadInt(R) # discard. key = Files.ReadInt(R) modname = Files.ReadString(R) thismod = ThisModule(modid, modid1, True, key) thismod.rdo = True class_ = Read(R) # (*version key*) if class_ != versionkey: ORS.Mark("wrong version") class_ = Read(R) while class_ != 0: obj = Object() obj.class_ = class_ obj.name = Files.ReadString(R) obj.type_ = InType(R, thismod) obj.lev = -thismod.lev if class_ == Typ: t = obj.type_ t.typobj = obj k = Read( R ) # (*fixup bases of previously declared pointer types*) while k != 0: typtab[k].base = t k = Read(R) else: if class_ == Const: if obj.type_.form == Real: obj.val = Files.ReadInt(R) else: obj.val = Files.ReadNum(R) elif class_ == Var: obj.val = Files.ReadNum(R) obj.rdo = True obj.next = thismod.dsc thismod.dsc = obj class_ = Read(R) else: ORS.Mark("import not available")
def InType(R, thismod): ref = Read(R) if ref < 0: T = typtab[-ref] # (*already read*) else: t = Type() T = t typtab[ref] = t t.mno = thismod.lev form = Read(R) t.form = form if form == Pointer: t.base = InType(R, thismod) t.size = 4 elif form == Array: t.base = InType(R, thismod) t.len_ = Files.ReadNum(R, ) t.size = Files.ReadNum(R, ) elif form == Record: t.base = InType(R, thismod) if t.base.form == NoTyp: t.base = None obj = None else: obj = t.base.dsc t.len_ = Files.ReadNum(R) # (*TD adr/exno*) t.nofpar = Files.ReadNum(R) # (*ext level*) t.size = Files.ReadNum(R) class_ = Read(R) while class_ != 0: # (*fields*) fld = Object() fld.class_ = class_ fld.name = Files.ReadString(R) if fld.name[0] != 0x0: fld.expo = True fld.type_ = InType(R, thismod) else: fld.expo = False fld.type_ = nilType fld.val = Files.ReadNum(R) fld.next = obj obj = fld class_ = Read(R) t.dsc = obj elif form == Proc: t.base = InType(R, thismod) obj = None np = 0 class_ = Read(R) while class_ != 0: # (*parameters*) par = Object() par.class_ = class_ readonly = Read(R) par.rdo = readonly == 1 par.type_ = InType(R, thismod) par.next = obj obj = par np += 1 class_ = Read(R) t.dsc = obj t.nofpar = np t.size = 4 modname = Files.ReadString(R) if modname: # [0] != 0x0: # (*re-import*) key = Files.ReadInt(R) name = Files.ReadString(R) mod = ThisModule(modname, modname, False, key) obj = mod.dsc # (*search type*) while (obj != None) and (obj.name != name): obj = obj.next if obj != None: T = obj.type_ # (*type object found in object list of mod*) else: # (*insert new type object in object list of mod*) obj = Object() obj.name = name obj.class_ = Typ obj.next = mod.dsc mod.dsc = obj obj.type_ = t t.mno = mod.lev T = t typtab[ref] = T return T