private void ResolveStateVariables()
        {
            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 <VariableDeclaration> stateVars = context.GetStateVarsByContract(contract);
                        foreach (VariableDeclaration stateVar in stateVars)
                        {
                            string name = stateVar.Name;
                            context.AddStateVarToDynamicType(name, contract, stateVar);
                        }
                    }
                    else
                    {
                        HashSet <VariableDeclaration> stateVars = context.GetStateVarsByContract(baseContract);
                        foreach (VariableDeclaration stateVar in stateVars)
                        {
                            if (stateVar.Visibility == EnumVisibility.PRIVATE)
                            {
                                continue;
                            }

                            string name = stateVar.Name;
                            context.AddStateVarToDynamicType(name, contract, stateVar);
                        }
                    }
                }
            }

            // PrintStateVarResolutionMap();
        }