2019-07-05 21:53:45 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2019 faddenSoft
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
using Asm65;
|
|
|
|
|
|
2019-07-20 20:28:10 +00:00
|
|
|
|
namespace SourceGen.WpfGui {
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Symbol edit dialog.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class EditDefSymbol : Window, INotifyPropertyChanged {
|
2021-07-20 20:08:19 +00:00
|
|
|
|
// 256-byte zero page, +1 for 16-bit access at $ff.
|
|
|
|
|
private const int MAX_VAR_WIDTH = 257;
|
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// <summary>
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// Result; will be set non-null on OK.
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// </summary>
|
2019-08-26 00:25:15 +00:00
|
|
|
|
public DefSymbol NewSym { get; private set; }
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
2020-04-23 17:42:54 +00:00
|
|
|
|
public enum InputField {
|
|
|
|
|
Unknown = 0, Label, Value, Comment
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Determines which field gets focus initially.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public InputField InitialFocusField { get; set; }
|
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set to true when all fields are valid. Controls whether the OK button is enabled.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsValid {
|
|
|
|
|
get { return mIsValid; }
|
2019-08-26 00:25:15 +00:00
|
|
|
|
set { mIsValid = value; OnPropertyChanged(); }
|
2019-07-05 21:53:45 +00:00
|
|
|
|
}
|
|
|
|
|
private bool mIsValid;
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
public string Label {
|
|
|
|
|
get { return mLabel; }
|
|
|
|
|
set { mLabel = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private string mLabel;
|
|
|
|
|
|
|
|
|
|
public string Value {
|
|
|
|
|
get { return mValue; }
|
|
|
|
|
set { mValue = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private string mValue;
|
|
|
|
|
|
|
|
|
|
public string VarWidth {
|
|
|
|
|
get { return mWidth; }
|
|
|
|
|
set { mWidth = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private string mWidth;
|
|
|
|
|
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
public string WidthLimitLabel {
|
|
|
|
|
get { return mWidthLimitLabel; }
|
|
|
|
|
set { mWidthLimitLabel = value; OnPropertyChanged(); }
|
|
|
|
|
}
|
|
|
|
|
private string mWidthLimitLabel;
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
public string Comment {
|
|
|
|
|
get { return mComment; }
|
|
|
|
|
set { mComment = value; OnPropertyChanged(); }
|
|
|
|
|
}
|
|
|
|
|
private string mComment;
|
|
|
|
|
|
2019-08-29 00:34:29 +00:00
|
|
|
|
public bool IsAddress {
|
|
|
|
|
get { return mIsAddress; }
|
|
|
|
|
set { mIsAddress = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private bool mIsAddress;
|
|
|
|
|
|
|
|
|
|
public bool IsConstant {
|
|
|
|
|
get { return mIsConstant; }
|
|
|
|
|
set { mIsConstant = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private bool mIsConstant;
|
|
|
|
|
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
public string ConstantLabel {
|
|
|
|
|
get { return mConstantLabel; }
|
|
|
|
|
set { mConstantLabel = value; OnPropertyChanged(); }
|
|
|
|
|
}
|
|
|
|
|
private string mConstantLabel;
|
|
|
|
|
|
2019-10-15 23:37:14 +00:00
|
|
|
|
public bool IsReadChecked {
|
|
|
|
|
get { return mIsReadChecked; }
|
|
|
|
|
set { mIsReadChecked = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private bool mIsReadChecked;
|
|
|
|
|
|
|
|
|
|
public bool IsWriteChecked {
|
|
|
|
|
get { return mIsWriteChecked; }
|
|
|
|
|
set { mIsWriteChecked = value; OnPropertyChanged(); UpdateControls(); }
|
|
|
|
|
}
|
|
|
|
|
private bool mIsWriteChecked;
|
|
|
|
|
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
public bool ReadOnlyValueAndType {
|
|
|
|
|
get { return mReadOnlyValueAndType; }
|
|
|
|
|
set { mReadOnlyValueAndType = value; OnPropertyChanged(); }
|
|
|
|
|
}
|
|
|
|
|
public bool NotReadOnlyValueAndType {
|
|
|
|
|
get { return !mReadOnlyValueAndType; }
|
|
|
|
|
}
|
|
|
|
|
private bool mReadOnlyValueAndType;
|
|
|
|
|
|
2019-10-15 23:37:14 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set to true if we should create a Variable rather than a project symbol.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsVariable {
|
|
|
|
|
get { return mIsVariable; }
|
|
|
|
|
set { mIsVariable = value; OnPropertyChanged(); }
|
|
|
|
|
}
|
|
|
|
|
public bool IsNotVariable {
|
|
|
|
|
get { return !mIsVariable; }
|
|
|
|
|
}
|
|
|
|
|
private bool mIsVariable;
|
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Format object to use when formatting addresses and constants.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private Formatter mNumFormatter;
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// <summary>
|
2022-03-01 23:03:12 +00:00
|
|
|
|
/// Initial values for fields. May be null.
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// </summary>
|
2022-03-01 23:03:12 +00:00
|
|
|
|
private DefSymbol mInitialSym;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Original symbol. May be null if this is a new symbol.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private DefSymbol mOrigSym;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// List of existing symbols, for uniqueness check. The list will not be modified.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private SortedList<string, DefSymbol> mDefSymbolList;
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Full symbol table, for extended uniqueness check.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private SymbolTable mSymbolTable;
|
|
|
|
|
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set to true if the width value is optional.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool mIsWidthOptional;
|
|
|
|
|
|
2019-12-30 01:59:35 +00:00
|
|
|
|
private Brush mDefaultLabelColor = SystemColors.WindowTextBrush;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
|
|
|
|
// INotifyPropertyChanged implementation
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// <summary>
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
/// Constructor, for editing a project or platform symbol.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public EditDefSymbol(Window owner, Formatter formatter,
|
2022-03-01 23:03:12 +00:00
|
|
|
|
SortedList<string, DefSymbol> defList, DefSymbol origSym, DefSymbol initVals,
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
SymbolTable symbolTable)
|
2022-03-01 23:03:12 +00:00
|
|
|
|
: this(owner, formatter, defList, origSym, initVals, symbolTable, false, false) { }
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-09-08 23:41:54 +00:00
|
|
|
|
/// Constructor, for editing a local variable, or editing a project symbol with
|
|
|
|
|
/// the value field locked.
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// </summary>
|
2022-03-01 23:03:12 +00:00
|
|
|
|
/// <param name="owner">Parent window.</param>
|
|
|
|
|
/// <param name="formatter">Formatter object.</param>
|
|
|
|
|
/// <param name="defList">List of DefSymbols against which we test label uniqueness.</param>
|
|
|
|
|
/// <param name="origSym">Original symbol definition. The new label is allowed to
|
|
|
|
|
/// match this.</param>
|
|
|
|
|
/// <param name="initVals">Initial values for fields. This might be null, might be
|
|
|
|
|
/// the same as origSym, or might be the result of a previous unsaved edit.</param>
|
|
|
|
|
/// <param name="symbolTable">Full symbol table, for an extended uniqueness check
|
|
|
|
|
/// used for local variables (which must not clash with user labels).</param>
|
|
|
|
|
/// <param name="isVariable">Set true when editing a local variable table entry.</param>
|
|
|
|
|
/// <param name="lockValueAndType">Set true to prevents edits to the value and type.</param>
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
/// <remarks>
|
|
|
|
|
/// TODO(someday): disable the "constant" radio button unless CPU=65816.
|
|
|
|
|
/// </remarks>
|
2019-07-05 21:53:45 +00:00
|
|
|
|
public EditDefSymbol(Window owner, Formatter formatter,
|
2022-03-01 23:03:12 +00:00
|
|
|
|
SortedList<string, DefSymbol> defList, DefSymbol origSym, DefSymbol initVals,
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
SymbolTable symbolTable, bool isVariable, bool lockValueAndType) {
|
2019-07-05 21:53:45 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
Owner = owner;
|
|
|
|
|
DataContext = this;
|
|
|
|
|
|
|
|
|
|
mNumFormatter = formatter;
|
|
|
|
|
mDefSymbolList = defList;
|
2022-03-01 23:03:12 +00:00
|
|
|
|
mOrigSym = origSym;
|
|
|
|
|
mInitialSym = initVals;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
mSymbolTable = symbolTable;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
IsVariable = isVariable;
|
Instruction operand editor rework, part 2
Implemented local variable editing. Operands that have a local
variable reference, or are eligible to have one, can now be edited
directly from the instruction operand edit dialog.
Also, updated the code list double-click handler so that, if you
double-click on the opcode of an instruction that uses a local
variable reference, the selection and view will jump to the place
where that variable was defined.
Also, tweaked the way the References window refers to references
to an address that didn't use a symbol at that address. Updated
the explanation in the manual, which was a bit confusing.
Also, fixed some odds and ends in the manual.
Also, fixed a nasty infinite recursion bug (issue #47).
2019-09-08 01:57:22 +00:00
|
|
|
|
mReadOnlyValueAndType = lockValueAndType;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
|
2019-08-26 23:58:53 +00:00
|
|
|
|
Label = Value = VarWidth = Comment = string.Empty;
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
|
2019-10-28 04:29:44 +00:00
|
|
|
|
int maxWidth;
|
2019-08-26 23:58:53 +00:00
|
|
|
|
if (isVariable) {
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
ConstantLabel = (string)FindResource("str_VariableConstant");
|
2021-07-20 20:08:19 +00:00
|
|
|
|
maxWidth = MAX_VAR_WIDTH;
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
} else {
|
|
|
|
|
ConstantLabel = (string)FindResource("str_ProjectConstant");
|
|
|
|
|
maxWidth = 65536;
|
2019-08-26 23:58:53 +00:00
|
|
|
|
}
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
mIsWidthOptional = !isVariable;
|
|
|
|
|
|
|
|
|
|
string fmt = (string)FindResource("str_WidthLimitFmt");
|
|
|
|
|
WidthLimitLabel = string.Format(fmt, maxWidth);
|
2019-07-05 21:53:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
2022-03-01 23:03:12 +00:00
|
|
|
|
if (mInitialSym != null) {
|
|
|
|
|
Label = mInitialSym.GenerateDisplayLabel(mNumFormatter);
|
|
|
|
|
Value = mNumFormatter.FormatValueInBase(mInitialSym.Value,
|
|
|
|
|
mInitialSym.DataDescriptor.NumBase);
|
|
|
|
|
if (mInitialSym.HasWidth) {
|
|
|
|
|
VarWidth = mInitialSym.DataDescriptor.Length.ToString();
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
}
|
2022-03-01 23:03:12 +00:00
|
|
|
|
Comment = mInitialSym.Comment;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
2022-03-01 23:03:12 +00:00
|
|
|
|
if (mInitialSym.IsConstant) {
|
2019-08-29 00:34:29 +00:00
|
|
|
|
IsConstant = true;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
} else {
|
2019-08-29 00:34:29 +00:00
|
|
|
|
IsAddress = true;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
}
|
2019-10-15 23:37:14 +00:00
|
|
|
|
|
2022-03-01 23:03:12 +00:00
|
|
|
|
if (mInitialSym.Direction == DefSymbol.DirectionFlags.Read) {
|
2019-10-15 23:37:14 +00:00
|
|
|
|
IsReadChecked = true;
|
2022-03-01 23:03:12 +00:00
|
|
|
|
} else if (mInitialSym.Direction == DefSymbol.DirectionFlags.Write) {
|
2019-10-15 23:37:14 +00:00
|
|
|
|
IsWriteChecked = true;
|
|
|
|
|
} else {
|
|
|
|
|
IsReadChecked = IsWriteChecked = true;
|
|
|
|
|
}
|
2019-07-05 21:53:45 +00:00
|
|
|
|
} else {
|
2019-10-15 23:37:14 +00:00
|
|
|
|
IsAddress = IsReadChecked = IsWriteChecked = true;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateControls();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-15 00:48:54 +00:00
|
|
|
|
private void Window_ContentRendered(object sender, EventArgs e) {
|
2020-04-23 17:42:54 +00:00
|
|
|
|
TextBox field;
|
|
|
|
|
switch (InitialFocusField) {
|
|
|
|
|
case InputField.Value:
|
|
|
|
|
field = valueTextBox;
|
|
|
|
|
break;
|
|
|
|
|
case InputField.Comment:
|
|
|
|
|
field = commentTextBox;
|
|
|
|
|
break;
|
|
|
|
|
case InputField.Label:
|
|
|
|
|
default:
|
|
|
|
|
field = labelTextBox;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
field.SelectAll();
|
|
|
|
|
field.Focus();
|
2019-09-15 00:48:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Validates input and updates controls appropriately.
|
|
|
|
|
/// </summary>
|
2019-07-05 21:53:45 +00:00
|
|
|
|
private void UpdateControls() {
|
2019-08-26 00:25:15 +00:00
|
|
|
|
if (!IsLoaded) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
2019-08-31 01:33:05 +00:00
|
|
|
|
// Label must be valid and not already exist in the table we're editing. (For project
|
2019-08-26 00:25:15 +00:00
|
|
|
|
// symbols, it's okay if an identical label exists elsewhere.)
|
2019-11-13 01:24:41 +00:00
|
|
|
|
string trimLabel = Symbol.TrimAndValidateLabel(Label, string.Empty,
|
|
|
|
|
out bool labelValid, out bool unused1, out bool unused2, out bool unused3,
|
|
|
|
|
out Symbol.LabelAnnotation unused4);
|
2019-08-26 00:25:15 +00:00
|
|
|
|
bool labelUnique;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
2019-11-09 04:44:45 +00:00
|
|
|
|
if (mDefSymbolList.TryGetValue(trimLabel, out DefSymbol existing)) {
|
2022-01-12 22:07:30 +00:00
|
|
|
|
// We found a match. See if we're just seeing the symbol we're editing.
|
2022-03-01 23:03:12 +00:00
|
|
|
|
// If there's no "original" symbol, then the fact that we matched anything
|
|
|
|
|
// means the label is not unique. Otherwise, we consider it unique if the
|
|
|
|
|
// label matches the original symbol.
|
2022-01-12 22:07:30 +00:00
|
|
|
|
//
|
2022-03-01 23:03:12 +00:00
|
|
|
|
// We only need to check the label. Since we're comparing the original
|
|
|
|
|
// symbol to the value from the symbol table, it should be a total match,
|
|
|
|
|
// but the other fields don't actually matter. It's safer to let the Symbol
|
|
|
|
|
// class comparison operators do the work though.
|
|
|
|
|
labelUnique = (existing == mOrigSym);
|
|
|
|
|
//labelUnique = mOrigSym != null &&
|
|
|
|
|
// Asm65.Label.LABEL_COMPARER.Equals(existing.Label, mOrigSym.Label);
|
2019-07-05 21:53:45 +00:00
|
|
|
|
} else {
|
|
|
|
|
labelUnique = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 00:34:29 +00:00
|
|
|
|
// For local variables, do a secondary uniqueness check across the full symbol table.
|
2019-08-26 00:25:15 +00:00
|
|
|
|
if (labelUnique && mSymbolTable != null) {
|
2019-11-09 04:44:45 +00:00
|
|
|
|
labelUnique = !mSymbolTable.TryGetValue(trimLabel, out Symbol sym);
|
2019-08-31 01:33:05 +00:00
|
|
|
|
|
|
|
|
|
// It's okay if this and the other are both variables.
|
2019-10-15 23:37:14 +00:00
|
|
|
|
if (!labelUnique && IsVariable && sym.IsVariable) {
|
2019-08-31 01:33:05 +00:00
|
|
|
|
labelUnique = true;
|
|
|
|
|
}
|
2019-08-26 00:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
// Value must be blank, meaning "erase any earlier definition", or valid value.
|
|
|
|
|
// (Hmm... don't currently have a way to specify "no symbol" in DefSymbol.)
|
|
|
|
|
//if (!string.IsNullOrEmpty(valueTextBox.Text)) {
|
2019-11-13 01:24:41 +00:00
|
|
|
|
bool valueValid = ParseValue(out int thisValue, out int unused5);
|
2019-07-05 21:53:45 +00:00
|
|
|
|
//} else {
|
|
|
|
|
// valueValid = true;
|
|
|
|
|
//}
|
|
|
|
|
|
2019-08-26 00:25:15 +00:00
|
|
|
|
bool widthValid = true;
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
int thisWidth = -1;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
if (IsConstant && !IsVariable) {
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
// width field is ignored
|
|
|
|
|
} else if (string.IsNullOrEmpty(VarWidth)) {
|
|
|
|
|
// blank field is okay if the width is optional
|
|
|
|
|
widthValid = mIsWidthOptional;
|
|
|
|
|
} else if (!Asm65.Number.TryParseInt(VarWidth, out thisWidth, out int unusedBase) ||
|
|
|
|
|
thisWidth < DefSymbol.MIN_WIDTH || thisWidth > DefSymbol.MAX_WIDTH ||
|
2021-07-20 20:08:19 +00:00
|
|
|
|
(IsVariable && thisWidth > MAX_VAR_WIDTH)) {
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
// All widths must be between 1 and 65536. For a variable, the full thing must
|
2021-07-20 20:08:19 +00:00
|
|
|
|
// fit on zero page, except on 65816 where a 16-bit access at $ff can extend
|
|
|
|
|
// off the end of the direct page.
|
|
|
|
|
//
|
|
|
|
|
// We test the variable width here so that we highlight the "width limit" label,
|
|
|
|
|
// rather than the "value range" label.
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
widthValid = false;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 20:32:45 +00:00
|
|
|
|
bool valueRangeValid = true;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
if (IsVariable && valueValid && widthValid) {
|
2021-07-20 20:08:19 +00:00
|
|
|
|
// $ff with width 1 is okay, $ff with width 2 is okay on 65816, width=3 is bad
|
|
|
|
|
if (thisValue < 0 || thisValue + thisWidth > MAX_VAR_WIDTH) {
|
2019-08-29 20:32:45 +00:00
|
|
|
|
valueRangeValid = false;
|
|
|
|
|
}
|
2019-10-27 19:26:34 +00:00
|
|
|
|
} else if (IsAddress && valueValid) {
|
|
|
|
|
// limit to positive 24-bit integers; use a long for value+width so we
|
|
|
|
|
// don't get fooled by overflow
|
|
|
|
|
long lvalue = thisValue;
|
|
|
|
|
if (thisWidth > 0) {
|
|
|
|
|
lvalue += thisWidth - 1;
|
|
|
|
|
}
|
|
|
|
|
if (thisValue < 0 || lvalue > 0x00ffffff) {
|
|
|
|
|
valueRangeValid = false;
|
|
|
|
|
}
|
2019-08-29 20:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 00:34:29 +00:00
|
|
|
|
Symbol.Type symbolType = IsConstant ? Symbol.Type.Constant : Symbol.Type.ExternalAddr;
|
|
|
|
|
|
|
|
|
|
// For a variable, the value must also be unique within the table. Values have
|
|
|
|
|
// width, so we need to check for overlap.
|
|
|
|
|
bool valueUniqueValid = true;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
if (IsVariable && valueValid && widthValid) {
|
2019-08-29 00:34:29 +00:00
|
|
|
|
foreach (KeyValuePair<string, DefSymbol> kvp in mDefSymbolList) {
|
2022-03-01 23:03:12 +00:00
|
|
|
|
if (kvp.Value != mOrigSym &&
|
2019-09-01 03:32:43 +00:00
|
|
|
|
DefSymbol.CheckOverlap(kvp.Value, thisValue, thisWidth, symbolType)) {
|
2019-08-29 00:34:29 +00:00
|
|
|
|
valueUniqueValid = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:37:14 +00:00
|
|
|
|
bool rwValid = true;
|
|
|
|
|
if (!IsVariable && IsAddress) {
|
|
|
|
|
rwValid = IsReadChecked || IsWriteChecked;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-05 21:53:45 +00:00
|
|
|
|
labelNotesLabel.Foreground = labelValid ? mDefaultLabelColor : Brushes.Red;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
labelUniqueLabel.Foreground = projectLabelUniqueLabel.Foreground =
|
|
|
|
|
labelUnique ? mDefaultLabelColor : Brushes.Red;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
valueNotesLabel.Foreground = valueValid ? mDefaultLabelColor : Brushes.Red;
|
2019-10-27 19:26:34 +00:00
|
|
|
|
addrValueRangeLabel.Foreground = valueRangeValid ? mDefaultLabelColor : Brushes.Red;
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
varValueRangeLabel.Foreground = valueRangeValid ? mDefaultLabelColor : Brushes.Red;
|
|
|
|
|
varValueUniqueLabel.Foreground = valueUniqueValid ? mDefaultLabelColor : Brushes.Red;
|
2019-08-26 00:25:15 +00:00
|
|
|
|
widthNotesLabel.Foreground = widthValid ? mDefaultLabelColor : Brushes.Red;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
checkReadWriteLabel.Foreground = rwValid ? mDefaultLabelColor : Brushes.Red;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
2019-08-29 00:34:29 +00:00
|
|
|
|
IsValid = labelValid && labelUnique && valueValid && valueRangeValid &&
|
2019-10-15 23:37:14 +00:00
|
|
|
|
valueUniqueValid && widthValid && rwValid;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool ParseValue(out int value, out int numBase) {
|
2019-08-26 00:25:15 +00:00
|
|
|
|
string str = Value;
|
2019-07-05 21:53:45 +00:00
|
|
|
|
if (str.IndexOf('/') >= 0) {
|
|
|
|
|
// treat as address
|
|
|
|
|
numBase = 16;
|
|
|
|
|
return Asm65.Address.ParseAddress(str, (1 << 24) - 1, out value);
|
|
|
|
|
} else {
|
|
|
|
|
return Asm65.Number.TryParseInt(str, out value, out numBase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OkButton_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
ParseValue(out int value, out int numBase);
|
|
|
|
|
FormatDescriptor.SubType subType = FormatDescriptor.GetSubTypeForBase(numBase);
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
int width = -1;
|
2019-10-15 23:37:14 +00:00
|
|
|
|
if (IsConstant && !IsVariable) {
|
Allow explicit widths in project/platform symbols, part 1
The ability to give explicit widths to local variables worked out
pretty well, so we're going to try adding the same thing to project
and platform symbols.
The first step is to allow widths to be specified in platform files,
and set with the project symbol editor. The DefSymbol editor is
also used for local variables, so a bit of dancing is required.
For platform/project symbols the width is optional, and is totally
ignored for constants. (For variables, constants are used for the
StackRel args, so the width is meaningful and required.)
We also now show the symbol's type (address or constant) and width
in the listing. This gets really distracting when overused, so we
only show it when the width is explicitly set. The default width
is 1, which most things will be, so users can make an aesthetic
choice there. (The place where widths make very little sense is when
the symbol represents a code entry point, rather than a data item.)
The maximum width of a local variable is now 256, but it's not
allowed to overlap with other variables or run of the end of the
direct page. The maximum width of a platform/project symbol is
65536, with bank-wrap behavior TBD.
The local variable table editor now refers to stack-relative
constants as such, rather than simply "constant", to make it clear
that it's not just defining an 8-bit constant.
Widths have been added to a handful of Apple II platform defs.
2019-10-01 21:58:24 +00:00
|
|
|
|
// width field is ignored, don't bother parsing
|
|
|
|
|
} else if (!string.IsNullOrEmpty(VarWidth)) {
|
|
|
|
|
bool ok = Asm65.Number.TryParseInt(VarWidth, out width, out int unusedNumBase);
|
|
|
|
|
Debug.Assert(ok);
|
2019-08-26 00:25:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-15 23:37:14 +00:00
|
|
|
|
DefSymbol.DirectionFlags direction;
|
|
|
|
|
if (IsReadChecked && IsWriteChecked) {
|
|
|
|
|
direction = DefSymbol.DirectionFlags.ReadWrite;
|
|
|
|
|
} else if (IsReadChecked) {
|
|
|
|
|
direction = DefSymbol.DirectionFlags.Read;
|
|
|
|
|
} else if (IsWriteChecked) {
|
|
|
|
|
direction = DefSymbol.DirectionFlags.Write;
|
|
|
|
|
} else {
|
|
|
|
|
Debug.Assert(false);
|
|
|
|
|
direction = DefSymbol.DirectionFlags.None;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-09 04:44:45 +00:00
|
|
|
|
// Parse and strip the annotation.
|
2019-11-13 01:24:41 +00:00
|
|
|
|
string trimLabel = Symbol.TrimAndValidateLabel(Label, string.Empty, out bool unused1,
|
|
|
|
|
out bool unused2, out bool unused3, out bool unused4,
|
|
|
|
|
out Symbol.LabelAnnotation anno);
|
2019-11-09 04:44:45 +00:00
|
|
|
|
NewSym = new DefSymbol(trimLabel, value,
|
2019-10-15 23:37:14 +00:00
|
|
|
|
IsVariable ? Symbol.Source.Variable : Symbol.Source.Project,
|
2019-11-09 04:44:45 +00:00
|
|
|
|
IsConstant ? Symbol.Type.Constant : Symbol.Type.ExternalAddr, anno,
|
2019-10-15 23:37:14 +00:00
|
|
|
|
subType, width, width > 0, Comment, direction, null, string.Empty);
|
2019-07-05 21:53:45 +00:00
|
|
|
|
|
|
|
|
|
DialogResult = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|