Skip to content

Inliner/Init leaves behind singleline functions #511

Open
@Frotty

Description

@Frotty

After the inline phase there are many functions like this

function C1 takes nothing returns boolean
return true
endfunction

Left behind which are from packages which init's have apparently been inlined, or been empty anyways.
I was able to fix this by linking all these functionm together and running the inliner step again:

    private void checkFunc(ImFunction func) {
        if (func.getParameters().size() == 0 && func.getBody().size() == 1 && func.getBody().get(0) instanceof ImReturn) {
            ImReturn imr = (ImReturn) func.getBody().get(0);
            if (imr.getReturnValue() instanceof ImBoolVal) {
                boolean bval = ((ImBoolVal) imr.getReturnValue()).getValB();
                if (bval) {
                    if (rootTrueFunc == null) {
                        rootTrueFunc = func;
                    } else {
                        imr.setReturnValue(JassIm.ImFunctionCall(imr.getTrace(), rootTrueFunc, JassIm.ImExprs(), true, CallType.NORMAL));
                    }
                }
            }
        }
    }

But I guess this is not an ideal solution

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions