mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-09 11:31:24 +00:00
Rough layout of local variable tables
Create the XAML and some skeletal classes.
This commit is contained in:
parent
5dcdbe3f3a
commit
5fe032c93a
@ -23,6 +23,8 @@ namespace SourceGen {
|
||||
/// Instances are immutable.
|
||||
/// </summary>
|
||||
public class DefSymbol : Symbol {
|
||||
public const int NO_WIDTH = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Data format descriptor.
|
||||
/// </summary>
|
||||
@ -40,8 +42,9 @@ namespace SourceGen {
|
||||
public string Tag { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of bytes referenced by the symbol. Useful for identifying two-byte and
|
||||
/// three-byte pointers. Used for Variables.
|
||||
/// Number of bytes referenced by the symbol. Useful for identifying multi-byte items,
|
||||
/// such as two-byte and three-byte pointers. Used for Variables. Value will be
|
||||
/// NO_WIDTH if unset.
|
||||
/// </summary>
|
||||
public int Width { get; private set; }
|
||||
|
||||
@ -62,6 +65,7 @@ namespace SourceGen {
|
||||
Debug.Assert(source == Source.Platform || source == Source.Project);
|
||||
Debug.Assert(type == Type.ExternalAddr || type == Type.Constant);
|
||||
Xrefs = new XrefSet();
|
||||
Width = NO_WIDTH;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1069,6 +1069,8 @@ namespace SourceGen {
|
||||
// isn't the ORG at the start of the file. (This may temporarily do
|
||||
// double-spacing if we do a partial update, because we won't be able to
|
||||
// "see" the previous line. Harmless.)
|
||||
// TODO: consider always adding blanks, and doing a fix-up pass afterward.
|
||||
// (but keep in mind that blank lines should always come above things)
|
||||
//
|
||||
// Interesting case:
|
||||
// .dd2 $1000
|
||||
|
64
SourceGen/LocalVariableTable.cs
Normal file
64
SourceGen/LocalVariableTable.cs
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace SourceGen {
|
||||
/// <summary>
|
||||
/// Table of redefinable variables. A project may have several of these, at different
|
||||
/// offsets. The contents of later tables overwrite the contents of earlier tables.
|
||||
/// </summary>
|
||||
public class LocalVariableTable {
|
||||
/// <summary>
|
||||
/// List of variables. The symbol's label must be unique within a table, so we sort
|
||||
/// on that.
|
||||
/// </summary>
|
||||
private SortedList<string, DefSymbol> mVariables;
|
||||
|
||||
/// <summary>
|
||||
/// If set, all values from previous VariableTables should be discarded when this
|
||||
/// table is encountered.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Might be useful to allow addresses (DP ops) and constants (StackRel ops) to be
|
||||
/// cleared independently, but I suspect the typical compiled-language scenario will
|
||||
/// involve StackRel for args and a sliding DP for locals, so generally it makes
|
||||
/// sense to just clear both.
|
||||
/// </remarks>
|
||||
public bool ClearPrevious { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indexer.
|
||||
/// </summary>
|
||||
/// <param name="key">Symbol's label.</param>
|
||||
/// <returns>Matching symbol. Throws an exception if not found.</returns>
|
||||
public DefSymbol this[string key] {
|
||||
get {
|
||||
return mVariables[key];
|
||||
}
|
||||
set {
|
||||
mVariables[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs an empty table.
|
||||
/// </summary>
|
||||
public LocalVariableTable() {
|
||||
mVariables = new SortedList<string, DefSymbol>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1685,6 +1685,18 @@ namespace SourceGen {
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanEditLocalVariableTable() {
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
public void EditLocalVariableTable() {
|
||||
// TODO
|
||||
EditLocalVariableTable dlg = new EditLocalVariableTable(mMainWin);
|
||||
if (dlg.ShowDialog() != true) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanEditLongComment() {
|
||||
if (SelectionAnalysis.mNumItemsSelected != 1) {
|
||||
return false;
|
||||
|
@ -89,6 +89,7 @@
|
||||
<Compile Include="Tools\WpfGui\ShowText.xaml.cs">
|
||||
<DependentUpon>ShowText.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalVariableTable.cs" />
|
||||
<Compile Include="WpfGui\AboutBox.xaml.cs">
|
||||
<DependentUpon>AboutBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -110,6 +111,9 @@
|
||||
<Compile Include="WpfGui\EditLabel.xaml.cs">
|
||||
<DependentUpon>EditLabel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WpfGui\EditLocalVariableTable.xaml.cs">
|
||||
<DependentUpon>EditLocalVariableTable.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WpfGui\EditLongComment.xaml.cs">
|
||||
<DependentUpon>EditLongComment.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -262,6 +266,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WpfGui\EditLocalVariableTable.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WpfGui\EditLongComment.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
85
SourceGen/WpfGui/EditLocalVariableTable.xaml
Normal file
85
SourceGen/WpfGui/EditLocalVariableTable.xaml
Normal file
@ -0,0 +1,85 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<Window x:Class="SourceGen.WpfGui.EditLocalVariableTable"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SourceGen.WpfGui"
|
||||
mc:Ignorable="d"
|
||||
Title="Edit Local Variable Table"
|
||||
SizeToContent="WidthAndHeight" ResizeMode="NoResize"
|
||||
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
<Grid Margin="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
|
||||
Margin="0,4,0,0" Text="Symbols defined in project:"/>
|
||||
|
||||
<ListView Name="symbolsListView" Grid.Column="0" Grid.Row="1" Margin="0,4,4,0"
|
||||
Height="300"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
ItemsSource="{Binding Variables}"
|
||||
SnapsToDevicePixels="True" SelectionMode="Single"
|
||||
SelectionChanged="SymbolsListView_SelectionChanged"
|
||||
MouseDoubleClick="SymbolsListView_MouseDoubleClick">
|
||||
<ListView.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.View>
|
||||
<GridView AllowsColumnReorder="False">
|
||||
<GridViewColumn Header="Name" Width="118" DisplayMemberBinding="{Binding Label}"/>
|
||||
<GridViewColumn Header="Value" Width="72" DisplayMemberBinding="{Binding Value}"/>
|
||||
<GridViewColumn Header="Type" Width="45" DisplayMemberBinding="{Binding Type}"/>
|
||||
<GridViewColumn Header="Width" Width="45" DisplayMemberBinding="{Binding Width}"/>
|
||||
<GridViewColumn Header="Comment" Width="300" DisplayMemberBinding="{Binding Comment}"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
<StackPanel Grid.Column="1" Grid.Row="1">
|
||||
<Button Name="newSymbolButton" Width="120" Margin="4" Content="_New Symbol..."
|
||||
Click="NewSymbolButton_Click"/>
|
||||
<Button Name="editSymbolButton" Width="120" Margin="4,4" Content="_Edit Symbol..."
|
||||
Click="EditSymbolButton_Click"/>
|
||||
<Button Name="removeSymbolButton" Width="120" Margin="4,4" Content="_Remove"
|
||||
Click="RemoveSymbolButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Column="0" Grid.Row="2" Margin="0,4" Click="DeleteTableButton_Click"
|
||||
Content="Clear values from previous tables"/>
|
||||
|
||||
<DockPanel Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Margin="0,8,0,0" LastChildFill="False">
|
||||
<Button DockPanel.Dock="Left" Content="Delete Table" Width="120"/>
|
||||
<Button DockPanel.Dock="Right" Content="Cancel" Width="70" Margin="8,0,0,0" IsCancel="True"/>
|
||||
<Button DockPanel.Dock="Right" Grid.Column="1" Content="OK" Width="70"
|
||||
IsDefault="True" Click="OkButton_Click"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</Window>
|
83
SourceGen/WpfGui/EditLocalVariableTable.xaml.cs
Normal file
83
SourceGen/WpfGui/EditLocalVariableTable.xaml.cs
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace SourceGen.WpfGui {
|
||||
/// <summary>
|
||||
/// Edit a LocalVariableTable.
|
||||
/// </summary>
|
||||
public partial class EditLocalVariableTable : Window {
|
||||
// Item for the symbol list view.
|
||||
public class FormattedSymbol {
|
||||
public string Label { get; private set; }
|
||||
public string Value { get; private set; }
|
||||
public string Type { get; private set; }
|
||||
public string Width { get; private set; }
|
||||
public string Comment { get; private set; }
|
||||
|
||||
public FormattedSymbol(string label, string value, string type, string width,
|
||||
string comment) {
|
||||
Label = label;
|
||||
Value = value;
|
||||
Type = type;
|
||||
Width = width;
|
||||
Comment = comment;
|
||||
}
|
||||
}
|
||||
public ObservableCollection<FormattedSymbol> Variables { get; private set; } =
|
||||
new ObservableCollection<FormattedSymbol>();
|
||||
|
||||
public EditLocalVariableTable(Window owner) {
|
||||
InitializeComponent();
|
||||
Owner = owner;
|
||||
DataContext = this;
|
||||
}
|
||||
|
||||
public void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
}
|
||||
|
||||
private void OkButton_Click(object sender, RoutedEventArgs e) {
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void DeleteTableButton_Click(object sender, RoutedEventArgs e) {
|
||||
}
|
||||
|
||||
private void SymbolsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
||||
}
|
||||
|
||||
private void SymbolsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
}
|
||||
|
||||
private void NewSymbolButton_Click(object sender, RoutedEventArgs e) {
|
||||
}
|
||||
|
||||
private void EditSymbolButton_Click(object sender, EventArgs e) {
|
||||
}
|
||||
|
||||
private void RemoveSymbolButton_Click(object sender, RoutedEventArgs e) {
|
||||
}
|
||||
}
|
||||
}
|
@ -80,6 +80,7 @@ limitations under the License.
|
||||
<KeyGesture>Ctrl+L</KeyGesture>
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="EditLocalVariableTableCmd" Text="Edit Local Variable Table..."/>
|
||||
<RoutedUICommand x:Key="EditLongCommentCmd" Text="Edit Long Comment...">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Ctrl+M</KeyGesture>
|
||||
@ -192,6 +193,8 @@ limitations under the License.
|
||||
CanExecute="IsProjectOpen" Executed="EditHeaderCommentCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditLabelCmd}"
|
||||
CanExecute="CanEditLabel" Executed="EditLabelCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditLocalVariableTableCmd}"
|
||||
CanExecute="CanEditLocalVariableTable" Executed="EditLocalVariableTableCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditLongCommentCmd}"
|
||||
CanExecute="CanEditLongComment" Executed="EditLongCommentCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditNoteCmd}"
|
||||
@ -324,6 +327,7 @@ limitations under the License.
|
||||
<MenuItem Command="{StaticResource EditLongCommentCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditNoteCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditProjectSymbolCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditLocalVariableTableCmd}"/>
|
||||
<Separator/>
|
||||
<MenuItem Command="{StaticResource HintAsCodeEntryPointCmd}" InputGestureText="Ctrl+H, Ctrl+C"/>
|
||||
<MenuItem Command="{StaticResource HintAsDataStartCmd}" InputGestureText="Ctrl+H, Ctrl+D"/>
|
||||
|
@ -951,6 +951,10 @@ namespace SourceGen.WpfGui {
|
||||
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLabel();
|
||||
}
|
||||
|
||||
private void CanEditLocalVariableTable(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLocalVariableTable();
|
||||
}
|
||||
|
||||
private void CanEditLongComment(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditLongComment();
|
||||
}
|
||||
@ -1081,6 +1085,10 @@ namespace SourceGen.WpfGui {
|
||||
mMainCtrl.EditLabel();
|
||||
}
|
||||
|
||||
private void EditLocalVariableTableCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.EditLocalVariableTable();
|
||||
}
|
||||
|
||||
private void EditLongCommentCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.EditLongComment();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user