Skip to content

Unstrip constrained #264

Description

@ds5678

This instruction is commonly emitted for using blocks/statements. It precedes a callvirt instruction and affects how the instance for that call is loaded. In Roslyn-compiled code, it is also used for static abstract/virtual, but I don't think Unity supports that.

To ensure that the instance calling the method can be modified (and not just a copy), we need to wrap the call with these two helpers:

public static object? ConstrainedStart<T>(ByReference<T> reference) where T : IIl2CppType<T>
{
    var value = reference.GetValue();
    return value?.Box();
}

public static void ConstrainedFinish<T>(ByReference<T> reference, object? boxedObject) where T : IIl2CppType<T>
{
    var value = T.Unbox(boxedObject);
    reference.SetValue(value);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions