Navigation Menu

Skip to content

Commit

Permalink
Fixed small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltasarq committed Mar 22, 2017
1 parent 7e861e5 commit 1f3c115
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Core/AppInfo.cs
Expand Up @@ -9,7 +9,7 @@ public static class AppInfo
/// <summary>Author of the app.</summary>
public const string Author = "jbgarcia@uvigo.es";
/// <summary>Version of the app.</summary>
public const string Version = "1.3 20170214";
public const string Version = "1.4 20170401";
/// <summary>Website for this app.</summary>
public const string Web = "http://webs.uvigo.es/jbgarcia/prys/csim/";
/// <summary>Extension for files created by this app.</summary>
Expand Down
3 changes: 1 addition & 2 deletions Core/FunctionLibrary/Time.cs
Expand Up @@ -31,9 +31,8 @@ public override void Execute(RValue[] realParams)
var result = new NoPlaceTempVariable( this.Machine.TypeSystem.GetIntType() );
result.LiteralValue = new IntLiteral(
this.Machine,
System.Convert.ToInt64(
System.Math.Ceiling(
System.DateTime.Now.TimeOfDay.TotalSeconds ) ) );
System.DateTime.Now.TimeOfDay.TotalSeconds ).ToBigInteger() );

this.Machine.ExecutionStack.Push( result );
}
Expand Down
2 changes: 1 addition & 1 deletion Core/Literals/DoubleLiteral.cs
Expand Up @@ -63,7 +63,7 @@ public override byte[] GetRawValue()
/// <returns>The value as <see cref="BigInteger"/>.</returns>
public override BigInteger GetValueAsInteger()
{
return System.Convert.ToInt64( this.Value );
return this.Value.ToBigInteger();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Core/Literals/FloatLiteral.cs
Expand Up @@ -64,7 +64,7 @@ public override byte[] GetRawValue()
/// <returns>The value as <see cref="BigInteger"/>.</returns>
public override BigInteger GetValueAsInteger()
{
return System.Convert.ToInt64( this.Value );
return this.Value.ToBigInteger();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Core/Literals/TypeLiteral.cs
Expand Up @@ -95,7 +95,7 @@ public override byte[] GetRawValue()
/// <returns>The value as a <see cref="BigInteger"/>.</returns>
public override BigInteger GetValueAsInteger()
{
return System.Convert.ToInt64( this.Value.Size );
return this.Value.Size.ToBigInteger();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Core/Opcodes/AccessOpcode.cs
Expand Up @@ -44,7 +44,7 @@ public override void Execute()

// Access the pointed value
if ( vbleType != null ) {
BigInteger address = System.Convert.ToInt64( vble.LiteralValue.Value );
BigInteger address = vble.LiteralValue.Value.ToBigInteger();
vble = new InPlaceTempVariable( vbleType.DerreferencedType );
vble.Address = address;
this.Machine.TDS.AddVariableInPlace( vble );
Expand Down
5 changes: 4 additions & 1 deletion Ui/MainWindow.cs
Expand Up @@ -534,8 +534,11 @@ private void UpdateSymbolTable()
ReadOnlyCollection<Variable> variables = this.machine.TDS.Variables;

this.tvSymbolTable.Nodes.Clear();

foreach(Variable vble in variables) {
if ( vble is TempVariable ) {
continue;
}

string varTypeAddr = vble.Type.Name + " :" + vble.Type.Size
+ " ["
+ FromIntToPrettyHex( vble.Address, this.machine.WordSize )
Expand Down
40 changes: 29 additions & 11 deletions Ui/SchemaDrawer.cs
Expand Up @@ -29,7 +29,7 @@ public class SchemaDrawer {
public SchemaDrawer(Machine m)
{
this.Machine = m;
this.boxes = new Dictionary<BigInteger, GrphBoxedVariable>();
this.boxes = new Dictionary<BigInteger, List<GrphBoxedVariable>>();

var normalFont = new Font( FontFamily.GenericMonospace, 12 );
var smallFont = new Font( FontFamily.GenericMonospace, 10 );
Expand All @@ -54,10 +54,22 @@ public void InitGraphics(Bitmap bitmap)
private void AddVariablesAsBoxes(IEnumerable<Variable> list)
{
foreach (Variable v in list) {
if ( v is TempVariable) {
continue;
}

var box = GrphBoxedVariable.Create( v, this.GraphInfo );

foreach(var boxInfo in box.GetInvolvedBoxes()) {
this.boxes.Add( boxInfo.Key, boxInfo.Value );
List<GrphBoxedVariable> l;

if ( this.boxes.TryGetValue( boxInfo.Key, out l) ) {
l.Add( boxInfo.Value );
} else {
l = new List<GrphBoxedVariable>();
l.Add( boxInfo.Value );
this.boxes.Add( boxInfo.Key, l );
}
}

this.rows.AddBox( box );
Expand Down Expand Up @@ -144,15 +156,19 @@ public void Draw(Bitmap surface)
this.Cls();

// Draw relationships
foreach(GrphBoxedVariable box in this.boxes.Values) {
if ( box.Variable is PtrVariable ) {
this.DrawRelationship( box );
}
foreach(IList<GrphBoxedVariable> storedBoxes in this.boxes.Values) {
foreach(GrphBoxedVariable box in storedBoxes) {
if ( box.Variable is PtrVariable ) {
this.DrawRelationship( box );
}
}
}

// Draw the boxes themselves
foreach(GrphBoxedVariable box in this.boxes.Values) {
box.Draw();
foreach(IList<GrphBoxedVariable> storedBoxes in this.boxes.Values) {
foreach(GrphBoxedVariable box in storedBoxes) {
box.Draw();
}
}

return;
Expand All @@ -163,14 +179,16 @@ private void DrawRelationship(GrphBoxedVariable box)
var ptrVble = box.Variable as PtrVariable;

if ( ptrVble != null ) {
var address = (BigInteger) ptrVble.IntValue.Value;
BigInteger address = ptrVble.IntValue.Value;
GrphBoxedVariable pointedBox = null;
List<GrphBoxedVariable> l;

if ( address == 0 ) {
this.DrawNullPointer( box );
}
else
if ( this.boxes.TryGetValue( address, out pointedBox ) ) {
if ( this.boxes.TryGetValue( address, out l ) ) {
pointedBox = l[0];
float delta = 0;

if ( !( pointedBox is Drawer.GrphBoxedArray ) ) {
Expand Down Expand Up @@ -313,7 +331,7 @@ public void UpdateFont(int step)
get; set;
}

private Dictionary<BigInteger, GrphBoxedVariable> boxes;
private Dictionary<BigInteger, List<GrphBoxedVariable>> boxes;

private Bitmap bmBoard;
private Graphics board;
Expand Down

0 comments on commit 1f3c115

Please sign in to comment.