def _onTypeName(self, ast): def insideStructDef(self): sdn = None for n in reversed(self._nodes): if n.type == TreeType.STRUCT: sdn = n break return sdn n = len(ast.children) if n == 1: ast.esType = self._findSymbol(fromTree=ast.children[0], type_=ESType) if ast.esType.isStruct() and not ast.esType.parents: assert(insideStructDef(self)) self._raiseException(RecoverableCompileError, fromTree=ast, inlineText='structs can not contain themself. Use a pointer') else: # later we could implement here const / invariant etc. # but now just look up name baseType = self._findSymbol(fromTree=ast.children[0], type_=ESType) if baseType.isStruct() and not baseType.parents: assert(insideStructDef(self)) baseType = ESType.createSelfPointer() # no nesting allowed for now! if ast.children[1].type not in [TreeType.STAR, TreeType.DOUBLESTAR]: self._raiseException(RecoverableCompileError, tree=ast.children[1], inlineText='type constructors are not supported') for x in ast.children[1:]: baseType = baseType.derivePointer() if x.type == TreeType.DOUBLESTAR: baseType = baseType.derivePointer() ast.esType = baseType