예제 #1
0
 private void okButton_Click(object sender, EventArgs e)
 {
     bool checkNameCollision = editingMode == LabelEditMode.Add ?
         true :
         !nameBox.Text.Equals(editedLabel.Name, StringComparison.Ordinal);
     int val = 0;
     Symbol sym = new Symbol()
     {
         Name = nameBox.Text
     };
     if (!Utility.IsWord(nameBox.Text))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidName);
     }
     else if (checkNameCollision && labelContainer.IsSymbolDefined(sym))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_NameAlreadyDefined);
     }
     else if (!Int32.TryParse(offsetBox.Text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out val))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidVariable);
     }
     else
     {
         if (editingMode == LabelEditMode.Edit)
         {
             labelContainer.RemoveVarLabel(editedLabel);
         }
         editedLabel = new VarLabel(val, nameBox.Text, commentBox.Text);
         labelContainer.AddVarLabel(editedLabel);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
     }
 }
예제 #2
0
 public bool ContainsSymbol(Symbol search)
 {
     lock (symLock)
     {
         return symbolTable.Contains(search);
     }
 }
예제 #3
0
 private void okButton_Click(object sender, EventArgs e)
 {
     bool checkNameCollision = editingMode == LabelEditMode.Add ?
         true :
         !nameBox.Text.Equals(editedLabel.Name, StringComparison.Ordinal);
     int off = -1;
     Symbol sym = new Symbol()
     {
         Name = nameBox.Text
     };
     if (!Utility.IsWord(nameBox.Text))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidName);
     }
     else if (checkNameCollision && labelContainer.IsSymbolDefined(sym))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_NameAlreadyDefined);
     }
     else if (!Utility.OffsetStringToInt(offsetBox.Text, out off))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidOffset);
     }
     else
     {
         if (editingMode == LabelEditMode.Edit)
         {
             labelContainer.RemoveFuncLabel(editedLabel);
         }
         editedLabel = new FunctionLabel(off, nameBox.Text, commentBox.Text);
         labelContainer.AddFuncLabel(editedLabel);
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
     }
 }
예제 #4
0
 public void RemoveSymbol(Symbol symName)
 {
     lock (symLock)
     {
         if (symbolTable.Contains(symName))
         {
             symbolTable.Remove(symName);
         }
     }
 }
예제 #5
0
 public bool AddSymbol(Symbol symbol)
 {
     lock (symLock)
     {
         if (symbolTable.Contains(symbol))
         {
             return false;
         }
         symbolTable.Add(symbol);
         return true;
     }
 }
예제 #6
0
 private void okButton_Click(object sender, EventArgs e)
 {
     bool checkNameCollision = editingMode == LabelEditMode.Add ?
         true :
         !nameBox.Text.Equals(editedLabel.Name, StringComparison.Ordinal);
     int off = -1;
     int len = 0;
     Symbol sym = new Symbol()
     {
         Name = nameBox.Text
     };
     if (!Utility.IsWord(nameBox.Text))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidName);
     }
     else if (checkNameCollision && labelContainer.IsSymbolDefined(sym))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_NameAlreadyDefined);
     }
     else if (!Utility.OffsetStringToInt(offsetBox.Text, out off))
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidOffset);
     }
     else if (!Int32.TryParse(lengthBox.Text, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out len) || len <= 0)
     {
         Error.ShowErrorMessage(ErrorMessage.Label_InvalidLength);
     }
     else
     {
         TemplateBuilder tb = new TemplateBuilder();
         string input = dataTemplateBox.Text;
         bool success = false;
         CompError error = new CompError();
         var printTemplate = tb.ValidateTemplate(input, ref error, out success);
         if (!success)
         {
             Error.ShowErrorMessage(error);
         }
         else
         {
             if (editingMode == LabelEditMode.Edit)
             {
                 labelContainer.RemoveDataLabel(editedLabel);
             }
             editedLabel = new DataLabel(off, len, nameBox.Text, printTemplate, commentBox.Text, (DataSectionType)dataTypeBox.SelectedIndex);
             labelContainer.AddDataLabel(editedLabel);
             this.DialogResult = System.Windows.Forms.DialogResult.OK;
         }
     }
 }