Skip to content

Commit

Permalink
Exposed Stack and IsReachable properties on emitter.
Browse files Browse the repository at this point in the history
These are essential for consumers to know.  For instance, in order to spill the stack.  Without IsReachable, it is impossible for an emitter to know whether to emit instructions such as a return without doing their own redundant reachability tracking.

Closes PR #4

Co-authored-by: n8allan <[email protected]>
  • Loading branch information
arlm and n8allan committed Aug 7, 2019
1 parent 49d8390 commit 0118d3e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Sigil/Emit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,29 @@ private set

private readonly RollingVerifier CurrentVerifiers;

/// <summary>
/// The list of potential types on the current stack.
/// </summary>
public Type[][] Stack
{
get
{
return CurrentVerifiers.GetCurrentStack().Item2.Select(sl => sl.Select(si => si.Type).ToArray()).ToArray();
}
}

/// <summary>
/// If false, the current location is not reachable. This is useful information, for instance, when
/// emitting an expression statement where the result is to be discarded, but the emitted node is a throw.
/// </summary>
public bool IsReachable
{
get
{
return !MustMark;
}
}

private bool MustMark;

private readonly LinqList<int> ElidableCasts;
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Impl/RollingVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public virtual VerificationResult ConditionalBranch(params Label[] toLabels)
return VerificationResult.Successful();
}

private SigilTuple<bool, LinqStack<LinqList<TypeOnStack>>> GetCurrentStack()
internal SigilTuple<bool, LinqStack<LinqList<TypeOnStack>>> GetCurrentStack()
{
SigilTuple<bool, LinqStack<LinqList<TypeOnStack>>> ret = null;
for(var i = 0; i < CurrentlyInScope.Count; i++)
Expand Down

0 comments on commit 0118d3e

Please sign in to comment.