private void ResolveFunctions() { ResolutionHelper resolutionHelper = new ResolutionHelper(context); List <ContractDefinition> sortedContracts = resolutionHelper.TopologicalSortByDependency(context.ContractDefinitions); foreach (ContractDefinition contract in sortedContracts) { // create a deep copy List <int> linearizedBaseContractIds = new List <int>(contract.LinearizedBaseContracts); linearizedBaseContractIds.Reverse(); foreach (int id in linearizedBaseContractIds) { ContractDefinition baseContract = context.GetASTNodeById(id) as ContractDefinition; Debug.Assert(baseContract != null); if (baseContract == contract) { HashSet <FunctionDefinition> functions = context.GetFuncDefintionsInContract(contract); foreach (FunctionDefinition function in functions) { string signature = TransUtils.ComputeFunctionSignature(function); context.AddFunctionToDynamicType(signature, contract, function); } } else { HashSet <FunctionDefinition> functions = context.GetFuncDefintionsInContract(baseContract); foreach (FunctionDefinition function in functions) { if (function.Visibility == EnumVisibility.PRIVATE) { continue; } string signature = TransUtils.ComputeFunctionSignature(function); context.AddFunctionToDynamicType(signature, contract, function); } // Events // TODO: Do we need to lookup by signature? HashSet <EventDefinition> events = context.GetEventDefintionsInContract(baseContract); foreach (var evt in events) { context.AddEventToContract(contract, evt); } } } } // PrintFunctionResolutionMap(); }
public override bool Visit(EventDefinition node) { Debug.Assert(currentContract != null); context.AddEventToContract(currentContract, node); return(false); }