def _endInterface(anEndInterfaceStmt, cur): # get all the procedurenames from the mock symtab... mockSymtab = cur.val.symtab if (cur.val._in_iface.name): ifName = cur.val._in_iface.name cur.val.symtab = cur.val.symtab.parent genericSymtabEntry = cur.val.symtab.lookup_name(ifName) for name in mockSymtab.ids.keys(): try: specificSymtabEntry = cur.val.symtab.lookup_name(name) if not specificSymtabEntry: specifcSymtabEntry = SymtabEntry( SymtabEntry.ProcedureEntryKind()) cur.val.symtab.enter_name(name, specifcSymtabEntry) DebugManager.debug( '\tmodule procedure NOT already present in symbol table -- adding ' + specifcSymtabEntry.debug(name)) else: DebugManager.debug( '\tmodule procedure already has SymtabEntry' + specificSymtabEntry.debug(name)) # if the entry has a type, we know it's a function newEntryKind = specificSymtabEntry.typetab_id and SymtabEntry.FunctionEntryKind \ or SymtabEntry.ProcedureEntryKind specificSymtabEntry.enterEntryKind(newEntryKind()) genericSymtabEntry.addResolveName(name, specifcSymtabEntry) except SymtabError, e: # add lineNumber and symbol name to any SymtabError we encounter e.lineNumber = e.lineNumber or aProcedureStmt.lineNumber e.symbolName = e.symbolName or aProcedureName raise e
def _processProcedureStmt(aProcedureStmt, curr): localSymtab = curr.val.symtab DebugManager.debug('[Line ' + str(aProcedureStmt.lineNumber) + ']: stmt2unit._processProcedureStmt: called on "' + str(aProcedureStmt) + '" with localSymtab ' + str(localSymtab)) for aProcedureName in aProcedureStmt.procedureList: try: theSymtabEntry = localSymtab.lookup_name(aProcedureName) if not theSymtabEntry: newSymtabEntry = SymtabEntry(SymtabEntry.ProcedureEntryKind()) localSymtab.enter_name(aProcedureName, newSymtabEntry) DebugManager.debug( '\t_processProcedureStmt: module procedure NOT already present in symbol table -- adding ' + newSymtabEntry.debug(aProcedureName)) else: DebugManager.debug( '\t_processProcedureStmt: module procedure already has SymtabEntry' + theSymtabEntry.debug(aProcedureName)) # if the entry has a type, we know it's a function newEntryKind = theSymtabEntry.typetab_id and SymtabEntry.FunctionEntryKind \ or SymtabEntry.ProcedureEntryKind theSymtabEntry.enterEntryKind(newEntryKind()) theGenericSymtabEntry = localSymtab.lookup_name( curr.val._in_iface.name) if (theGenericSymtabEntry.genericInfo): if (theGenericSymtabEntry.genericInfo.genericName != curr.val._in_iface.name.lower()): raise SymtabError('mismatched generic name') if (not (aProcedureName in theGenericSymtabEntry. genericInfo.resolvableTo.keys())): theGenericSymtabEntry.genericInfo.resolvableTo[ aProcedureName] = theSymtabEntry else: theGenericSymtabEntry.genericInfo = GenericInfo() theGenericSymtabEntry.genericInfo.genericName = curr.val._in_iface.name.lower( ) theGenericSymtabEntry.genericInfo.resolvableTo[ aProcedureName] = theSymtabEntry except SymtabError, e: # add lineNumber and symbol name to any SymtabError we encounter e.lineNumber = e.lineNumber or aProcedureStmt.lineNumber e.symbolName = e.symbolName or aProcedureName raise e