Skip to content

Commit

Permalink
Fixed a bug where variables could not be accessed more than one layer…
Browse files Browse the repository at this point in the history
… lower in structures.
  • Loading branch information
griderd committed Aug 3, 2014
1 parent 4ced39f commit 17cf4a0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
23 changes: 22 additions & 1 deletion FileFormat/CodeGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,27 @@ bool CheckForGlobalName(string name)
return false;
}

bool TryParseGlobalName(string name, out Variable v)
{
v = null;

try
{
CompoundType curr = current;
while (curr != null)
{
v = curr.Variables[name];
if (v != null) return true;
else curr = curr.Parent;
}
return false;
}
catch
{
return false;
}
}

bool TryParseLocalName(string name, out Variable v)
{
v = null;
Expand Down Expand Up @@ -558,7 +579,7 @@ CompoundType CreateStruct(string name, string structName, string countVar)
CompoundType c = null;

if (CheckForGlobalName(name)) return null;
if (!TryParseLocalName(countVar, out cv)) return null;
if (!TryParseGlobalName(countVar, out cv)) return null;

try
{
Expand Down
6 changes: 3 additions & 3 deletions FileFormat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Program

static void Main(string[] args)
{
Console.WriteLine("Grider Software FileFormat " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
Console.WriteLine();

if (args.Length < 2)
{
PrintHelp();
Expand Down Expand Up @@ -55,9 +58,6 @@ static void Main(string[] args)
}
}

Console.WriteLine("Grider Software FileFormat " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
Console.WriteLine();

// Generate code
CodeGen code = new CodeGen(inputFile, outputFile);

Expand Down
4 changes: 2 additions & 2 deletions FileFormat/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.3.25")]
[assembly: AssemblyFileVersion("1.0.3.25")]
[assembly: AssemblyVersion("1.0.4.32")]
[assembly: AssemblyFileVersion("1.0.4.32")]

0 comments on commit 17cf4a0

Please sign in to comment.