예제 #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                string     fname           = tbFname.Text;
                Types      returnType      = FunctionConfig.TypeFromStr((string)comboType.SelectedItem);
                TaintTypes returnTaintType = FunctionConfig.TaintFromStr((string)comboTaint.SelectedItem);
                Taint      returnTaint     = new Taint(returnTaintType);
                if (returnTaintType == TaintTypes.G)
                {
                    string[] returnDepNames = tbReturnDeps.Text.Split(new char[] { ' ' });
                    foreach (string retDep in returnDepNames)
                    {
                        returnTaint.getDependencies().Add(retDep);
                    }
                }
                IList <FunctionConfig.Param> parameters = new List <FunctionConfig.Param>();
                foreach (DataGridViewRow row in dgParams.Rows)
                {
                    if (row.IsNewRow)
                    {
                        continue;
                    }
                    string     pName      = (string)row.Cells["Name"].Value;
                    Types      pType      = FunctionConfig.TypeFromStr((string)row.Cells["Type"].Value);
                    TaintTypes pTaintType = FunctionConfig.TaintFromStr((string)row.Cells["Taint"].Value);
                    Taint      pTaint     = new Taint(pTaintType);
                    if (pTaintType == TaintTypes.G)
                    {
                        string[] paramDepNames = ((string)row.Cells["Deps"].Value).Split(new char[] { ' ' });
                        foreach (string paramDep in paramDepNames)
                        {
                            pTaint.getDependencies().Add(paramDep);
                        }
                    }
                    FunctionConfig.Param param = new FunctionConfig.Param();
                    param.name       = pName;
                    param.paramType  = pType;
                    param.paramTaint = pTaint;
                    parameters.Add(param);
                }

                function = new FunctionConfig(fname, returnType, returnTaint, parameters);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Function cannot be added! Invalid dependencies");
                this.DialogResult = DialogResult.Cancel;
            }
        }
예제 #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                string fname = tbFname.Text;
                Types returnType = FunctionConfig.TypeFromStr((string)comboType.SelectedItem);
                TaintTypes returnTaintType = FunctionConfig.TaintFromStr((string)comboTaint.SelectedItem);
                Taint returnTaint = new Taint(returnTaintType);
                if (returnTaintType == TaintTypes.G)
                {
                    string[] returnDepNames = tbReturnDeps.Text.Split(new char[] { ' ' });
                    foreach (string retDep in returnDepNames)
                    {
                        returnTaint.getDependencies().Add(retDep);
                    }
                }
                IList<FunctionConfig.Param> parameters = new List<FunctionConfig.Param>();
                foreach (DataGridViewRow row in dgParams.Rows)
                {
                    if (row.IsNewRow)
                        continue;
                    string pName = (string)row.Cells["Name"].Value;
                    Types pType = FunctionConfig.TypeFromStr((string)row.Cells["Type"].Value);
                    TaintTypes pTaintType = FunctionConfig.TaintFromStr((string)row.Cells["Taint"].Value);
                    Taint pTaint = new Taint(pTaintType);
                    if (pTaintType == TaintTypes.G)
                    {
                        string[] paramDepNames = ((string)row.Cells["Deps"].Value).Split(new char[] { ' ' });
                        foreach (string paramDep in paramDepNames)
                        {
                            pTaint.getDependencies().Add(paramDep);
                        }
                    }
                    FunctionConfig.Param param = new FunctionConfig.Param();
                    param.name = pName;
                    param.paramType = pType;
                    param.paramTaint = pTaint;
                    parameters.Add(param);
                }

                function = new FunctionConfig(fname, returnType, returnTaint, parameters);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Function cannot be added! Invalid dependencies");
                this.DialogResult = DialogResult.Cancel;
            }
        }