/// <returns></returns>
public static RakudoObject Bootstrap()
{
// Create our KnowHOW type object. Note we don't have a HOW
// just yet, so pass in null.
Representation REPR = REPRRegistry.get_REPR_by_name("KnowHOWREPR");
RakudoObject KnowHOW = REPR.type_object_for(null,null);
// We'll set up a dictionary of our various methods to go into
// KnowHOW's HOW, since we'll want to work with them a bit.
HashMap<String, RakudoObject> KnowHOWMeths = new HashMap<String, RakudoObject>();
KnowHOWMeths.put("new_type", CodeObjectUtility.WrapNativeMethod( new RakudoCodeRef.IFunc_Body() { // C# has a lambda
public RakudoObject Invoke(ThreadContext tc, RakudoObject ignored, RakudoObject capture)
{
// We first create a new HOW instance.
RakudoObject knowHOWTypeObj = CaptureHelper.GetPositional(capture, 0);
RakudoObject HOW = knowHOWTypeObj.getSTable().REPR.instance_of(tc, knowHOWTypeObj.getSTable().WHAT);
// If we have a name arg, stash that value away.
RakudoObject typeName = CaptureHelper.GetNamed(capture, "name");
((KnowHOWREPR.KnowHOWInstance)HOW).Name = typeName != null ? typeName : Ops.box_str(tc, "<anon>");
// Now create a new type object to go with it of the
// desired REPR; we default to P6opaque (note that the
// KnowHOW repr only knows how to store a table of
// methods and attributes, it can't be used for an
// instance object that actually wants to store some
// instance data).
RakudoObject REPRName = CaptureHelper.GetNamed(capture, "repr");
if (REPRName != null)
{
// Look up the REPR.
Representation REPRToUse = REPRRegistry.get_REPR_by_name(Ops.unbox_str(null, REPRName));
return REPRToUse.type_object_for(null, HOW);
}
else
{
// Just go with the P6opaque REPR.
return REPRRegistry.get_REPR_by_name("P6opaque").type_object_for(tc, HOW);