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; } }
public bool ContainsSymbol(Symbol search) { lock (symLock) { return symbolTable.Contains(search); } }
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; } }
public void RemoveSymbol(Symbol symName) { lock (symLock) { if (symbolTable.Contains(symName)) { symbolTable.Remove(symName); } } }
public bool AddSymbol(Symbol symbol) { lock (symLock) { if (symbolTable.Contains(symbol)) { return false; } symbolTable.Add(symbol); return true; } }
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; } } }