git @ Cat's Eye Technologies Castile / 1f6326e
Prevent `make` where struct is inaccessible. Chris Pressey 3 years ago
1 changed file(s) with 9 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3333 self.context = ScopedContext(global_context, level='global')
3434 self.toplevel_context = ScopedContext({}, self.context, level='toplevel')
3535 self.context = self.toplevel_context
36 self.current_defn = None
3637
3738 self.forwards = {}
3839 self.structs = {} # struct name -> StructDefinition
240241 if t.name not in self.structs:
241242 raise CastileTypeError("undefined struct %s" % t.name)
242243 struct_defn = self.structs[t.name]
244 if struct_defn.scope_idents is not None:
245 scope_idents = [ast.value for ast in struct_defn.scope_idents]
246 if self.current_defn not in scope_idents:
247 raise CastileTypeError("inaccessible struct %s for make: %s not in %s" %
248 (t.name, self.current_defn, scope_idents)
249 )
243250 if len(struct_defn.content_types) != len(ast.children) - 1:
244251 raise CastileTypeError("argument mismatch")
245252 i = 0
286293 ast.type = Void()
287294 self.resolve_structs(ast)
288295 elif ast.tag == 'Defn':
296 self.current_defn = ast.value
289297 t = self.type_of(ast.children[0])
298 self.current_defn = None
290299 if ast.value in self.forwards:
291300 self.assert_eq(self.forwards[ast.value], t)
292301 del self.forwards[ast.value]