ShaderGen icon indicating copy to clipboard operation
ShaderGen copied to clipboard

[Enhancement] Support method overloading

Open thargy opened this issue 7 years ago • 0 comments

Currently, method overloading doesn't work. To support, method numbering would help, e.g. (extending the example in #73):

    public struct SimpleConstructedStruct
    {
        public readonly float OutFloat;

        public SimpleConstructedStruct(float outFloat)
        {
            OutFloat = outFloat;
        }

        public SimpleConstructedStruct Increment()
        {
            return new SimpleConstructedStruct (OutFloat + 1.0f);
        }

        public SimpleConstructedStruct Increment(float amount)
        {
            return new SimpleConstructedStruct (OutFloat + amount);
        }
    }

...
    SimpleConstructedStruct s = new SimpleConstructedStruct(1.0f);
    s = s.SimpleConstructedStruct();
    s = s.SimpleConstructedStruct(1.0f);

Should be written as:

    struct SimpleConstructedStruct
    {
        float OutFloat;
    };

    SimpleConstructedStruct_0_ctor(float outFloat)
    {
        SimpleConsructedStruct this;
        this.OutFloat = outFloat;
        return this;
    }

    SimpleConstructedStruct_Increment(SimpleConstructedStruct this)
    {
        return SimpleConstructedStruct_0_ctor(this.OutFloat + 1.0);
    }

    SimpleConstructedStruct_Increment_2(SimpleConstructedStruct this, float amount)
    {
        return SimpleConstructedStruct_0_ctor(this.OutFloat + amount);
    }

...
    SimpleConstructedStruct s = SimpleConstructedStruct_0_ctor(1.0);
    s = SimpleConstructedStruct_Increment(s);
    s = SimpleConstructedStruct_Increment_2(s, 1.0);

thargy avatar May 19 '18 23:05 thargy