Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dotnet] Add variant of the capture former that takes a flattening sp…
…ecification.
  • Loading branch information
jnthn committed Nov 20, 2010
1 parent a180bfb commit d73ce45
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions dotnet/runtime/Metamodel/Representations/P6capture.cs
Expand Up @@ -18,6 +18,7 @@ internal sealed class Instance : RakudoObject
{
public RakudoObject[] Positionals;
public Dictionary<string, RakudoObject> Nameds;
public int[] FlattenSpec;
public Instance(SharedTable STable)
{
this.STable = STable;
Expand Down
37 changes: 35 additions & 2 deletions dotnet/runtime/Runtime/CaptureHelper.cs
Expand Up @@ -13,6 +13,21 @@ namespace Rakudo.Runtime
/// </summary>
public static class CaptureHelper
{
/// <summary>
/// Don't flatten.
/// </summary>
public const int FLATTEN_NONE = 0;

/// <summary>
/// Flatten positionally.
/// </summary>
public const int FLATTEN_POS = 1;

/// <summary>
/// Flatten named.
/// </summary>
public const int FLATTEN_NAMED = 2;

/// <summary>
/// Cache of the native capture type object.
/// </summary>
Expand All @@ -31,7 +46,7 @@ public static RakudoObject FormWith()
/// <summary>
/// Forms a capture from the provided positional arguments.
/// </summary>
/// <param name="Args"></param>
/// <param name="PosArgs"></param>
/// <returns></returns>
public static RakudoObject FormWith(RakudoObject[] PosArgs)
{
Expand All @@ -43,7 +58,8 @@ public static RakudoObject FormWith(RakudoObject[] PosArgs)
/// <summary>
/// Forms a capture from the provided positional and named arguments.
/// </summary>
/// <param name="Args"></param>
/// <param name="PosArgs"></param>
/// <param name="NamedArgs"></param>
/// <returns></returns>
public static RakudoObject FormWith(RakudoObject[] PosArgs, Dictionary<string, RakudoObject> NamedArgs)
{
Expand All @@ -53,6 +69,23 @@ public static RakudoObject FormWith(RakudoObject[] PosArgs, Dictionary<string, R
return C;
}

/// <summary>
/// Forms a capture from the provided positional and named arguments
/// and the given flattening spec.
/// </summary>
/// <param name="PosArgs"></param>
/// <param name="NamedArgs"></param>
/// <param name="FlattenSpec"></param>
/// <returns></returns>
public static RakudoObject FormWith(RakudoObject[] PosArgs, Dictionary<string, RakudoObject> NamedArgs, int[] FlattenSpec)
{
var C = (P6capture.Instance)CaptureTypeObject.STable.REPR.instance_of(null, CaptureTypeObject);
C.Positionals = PosArgs;
C.Nameds = NamedArgs;
C.FlattenSpec = FlattenSpec;
return C;
}

/// <summary>
/// Get a positional argument from a capture.
/// </summary>
Expand Down

0 comments on commit d73ce45

Please sign in to comment.