|
26 | 26 | # ------------------------------------------------------------------------------ |
27 | 27 | """Converter from the BC types (CIL) to the AST types.""" |
28 | 28 |
|
29 | | -from typing import Dict, List |
| 29 | +from typing import Dict, List, Optional |
30 | 30 |
|
31 | 31 | from chb.ast.ASTIndexer import ASTIndexer |
32 | 32 | import chb.ast.ASTNode as AST |
|
48 | 48 | from chb.bctypes.BCVarInfo import BCVarInfo |
49 | 49 |
|
50 | 50 | import chb.util.fileutil as UF |
| 51 | +from chb.util.loggingutil import chklogger |
51 | 52 |
|
52 | 53 | bc2ast_operators: Dict[str, str] = { |
53 | 54 | "div": "div", |
@@ -255,11 +256,16 @@ def convert_funarg(self, arg: BCFunArg) -> AST.ASTFunArg: |
255 | 256 | return AST.ASTFunArg(arg.name, arg.typ.convert(self)) |
256 | 257 |
|
257 | 258 | def convert_named_typ(self, t: BCT.BCTypNamed) -> AST.ASTTyp: |
258 | | - typdef = t.typedef.ttype.convert(self) |
259 | | - namedtype = AST.ASTTypNamed(t.tname, typdef) |
260 | | - self.symboltable.add_typedef(namedtype) |
261 | | - # return namedtype |
262 | | - return typdef |
| 259 | + typdef = t.typedef |
| 260 | + if typdef is not None: |
| 261 | + asttypdef = typdef.ttype.convert(self) |
| 262 | + namedtype = AST.ASTTypNamed(t.tname, asttypdef) |
| 263 | + self.symboltable.add_typedef(namedtype) |
| 264 | + return asttypdef |
| 265 | + else: |
| 266 | + chklogger.logger.error( |
| 267 | + "No definition for typedef %s", t.tname) |
| 268 | + raise UF.CHBError("No definition for typedef name " + t.tname) |
263 | 269 |
|
264 | 270 | def convert_builtin_va_list( |
265 | 271 | self, t: BCT.BCTypBuiltinVaList) -> AST.ASTTypBuiltinVAList: |
|
0 commit comments