Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[dotnet] add variants of the boxing Ops that use the current thread's…
… default types' representations
  • Loading branch information
diakopter committed Nov 24, 2010
1 parent c46ad28 commit b34f13f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions dotnet/runtime/Runtime/Ops/Boxing.cs
Expand Up @@ -26,6 +26,18 @@ public static RakudoObject box_int(ThreadContext TC, int Value, RakudoObject To)
return Result;
}

/// <summary>
/// Boxes a native int into its matching value type.
/// </summary>
/// <param name="Value"></param>
/// <returns></returns>
public static RakudoObject box_int(ThreadContext TC, int Value)
{
var Result = TC.DefaultIntBoxType.STable.REPR.instance_of(TC, TC.DefaultIntBoxType);
TC.DefaultIntBoxType.STable.REPR.set_int(TC, Result, Value);
return Result;
}

/// <summary>
/// Boxes a native num into its matching value type.
/// </summary>
Expand All @@ -39,6 +51,18 @@ public static RakudoObject box_num(ThreadContext TC, double Value, RakudoObject
return Result;
}

/// <summary>
/// Boxes a native num into its matching value type.
/// </summary>
/// <param name="Value"></param>
/// <returns></returns>
public static RakudoObject box_num(ThreadContext TC, int Value)
{
var Result = TC.DefaultNumBoxType.STable.REPR.instance_of(TC, TC.DefaultNumBoxType);
TC.DefaultNumBoxType.STable.REPR.set_num(TC, Result, Value);
return Result;
}

/// <summary>
/// Boxes a native string into its matching value type.
/// </summary>
Expand All @@ -52,6 +76,18 @@ public static RakudoObject box_str(ThreadContext TC, string Value, RakudoObject
return Result;
}

/// <summary>
/// Boxes a native string into its matching value type.
/// </summary>
/// <param name="Value"></param>
/// <returns></returns>
public static RakudoObject box_str(ThreadContext TC, string Value)
{
var Result = TC.DefaultStrBoxType.STable.REPR.instance_of(TC, TC.DefaultStrBoxType);
TC.DefaultStrBoxType.STable.REPR.set_str(TC, Result, Value);
return Result;
}

/// <summary>
/// Unboxes a boxed int.
/// </summary>
Expand Down

0 comments on commit b34f13f

Please sign in to comment.