Skip to content

Commit

Permalink
Headers now stored in Program.
Browse files Browse the repository at this point in the history
This means that if you need to know any info that a node header has you can get it back out.
Fixes #276
Fixes #181 on YS-Unity
  • Loading branch information
McJones committed Jan 31, 2023
1 parent 8af11cc commit 840c003
Show file tree
Hide file tree
Showing 3 changed files with 598 additions and 23 deletions.
11 changes: 9 additions & 2 deletions YarnSpinner.Compiler/Compiler.cs
Expand Up @@ -926,7 +926,8 @@ public static CompilationResult Compile(CompilationJob compilationJob)
throw new ArgumentOutOfRangeException($"Cannot create an initial value for type {declaration.Type.Name}");
}

if (finalResult.Program != null) {
if (finalResult.Program != null)
{
finalResult.Program.InitialValues.Add(declaration.Name, value);
}
}
Expand Down Expand Up @@ -1369,7 +1370,8 @@ public override void EnterNode(YarnSpinnerParser.NodeContext context)
// var and make it ready to go again
public override void ExitNode(YarnSpinnerParser.NodeContext context)
{
if (string.IsNullOrEmpty(this.CurrentNode.Name)) {
if (string.IsNullOrEmpty(this.CurrentNode.Name))
{
// We don't have a name for this node. We can't emit code for
// it.
this.diagnostics.Add(new Diagnostic(
Expand Down Expand Up @@ -1440,6 +1442,11 @@ public override void ExitHeader(YarnSpinnerParser.HeaderContext context)
this.RawTextNode = true;
}
}

var header = new Header();
header.Key = headerKey;
header.Value = headerValue;
this.CurrentNode.Headers.Add(header);
}

// have entered the body the header should have finished being
Expand Down

0 comments on commit 840c003

Please sign in to comment.