//Function to insert a function into the specified contract. public void InsertFunctionInContract(ContractDefinition contract, FunctionDefinition funcDef) { if (FunctionMapping.ContainsKey(contract) == false) { Debug.Assert(!FunctionSignatureMapping.ContainsKey(contract)); FunctionMapping[contract] = new HashSet <FunctionDefinition>(); FunctionSignatureMapping[contract] = new HashSet <string>(); } Debug.Assert(!FunctionMapping[contract].Contains(funcDef), $"Repeated function warning: {funcDef.Name}"); FunctionMapping[contract].Add(funcDef); string signature = Conversion_Utility_Tool.ComputeFunctionSignature(funcDef); FunctionSignatureMapping[contract].Add(signature); Debug.Assert(!FunctionToContractMap.ContainsKey(funcDef), $" Repeated function warning: {funcDef.Name}"); FunctionToContractMap[funcDef] = contract; }
public void AddFunctionToContract(ContractDefinition contract, FunctionDefinition funcDef) { if (!ContractToFunctionsMap.ContainsKey(contract)) { Debug.Assert(!ContractToFuncSigsMap.ContainsKey(contract)); ContractToFunctionsMap[contract] = new HashSet <FunctionDefinition>(); ContractToFuncSigsMap[contract] = new HashSet <string>(); } Debug.Assert(!ContractToFunctionsMap[contract].Contains(funcDef), $"Duplicated function definition: {funcDef.Name}"); ContractToFunctionsMap[contract].Add(funcDef); string signature = TransUtils.ComputeFunctionSignature(funcDef); Debug.Assert(!ContractToFuncSigsMap[contract].Contains(signature), $"Duplicated function signature: {signature}"); ContractToFuncSigsMap[contract].Add(signature); Debug.Assert(!FunctionToContractMap.ContainsKey(funcDef), $"Duplicated function: {funcDef.Name}"); FunctionToContractMap[funcDef] = contract; }
public ContractDefinition GetContractByFunction(FunctionDefinition funcDef) { Debug.Assert(FunctionToContractMap.ContainsKey(funcDef)); return(FunctionToContractMap[funcDef]); }