mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-13 23:11:41 +00:00
Also handle indirect recursive inlining
This commit is contained in:
@ -265,8 +265,8 @@ export class Compiler extends DiagnosticEmitter {
|
||||
currentFunction: Function;
|
||||
/** Current outer function in compilation, if compiling a function expression. */
|
||||
currentOuterFunction: Function | null = null;
|
||||
/** Current inline function in compilation. */
|
||||
currentInlineFunction: Function | null = null;
|
||||
/** Current inline functions stack. */
|
||||
currentInlineFunctions: Function[] = [];
|
||||
/** Current enum in compilation. */
|
||||
currentEnum: Enum | null = null;
|
||||
/** Current type in compilation. */
|
||||
@ -5259,20 +5259,16 @@ export class Compiler extends DiagnosticEmitter {
|
||||
// Inline if explicitly requested
|
||||
if (inline) {
|
||||
assert(!instance.is(CommonFlags.TRAMPOLINE)); // doesn't make sense
|
||||
if (instance === this.currentInlineFunction) {
|
||||
// skip inlining when trying to inline a function into itself and print a warning when
|
||||
// instead compiling the function the normal way.
|
||||
if (instance === this.currentFunction) {
|
||||
this.warning(
|
||||
DiagnosticCode.Function_0_cannot_be_inlined_into_itself,
|
||||
reportNode.range, instance.internalName
|
||||
);
|
||||
}
|
||||
if (this.currentInlineFunctions.includes(instance)) {
|
||||
this.warning(
|
||||
DiagnosticCode.Function_0_cannot_be_inlined_into_itself,
|
||||
reportNode.range, instance.internalName
|
||||
);
|
||||
} else {
|
||||
this.currentInlineFunction = instance;
|
||||
let ret = this.compileCallInlineUnchecked(instance, argumentExpressions, reportNode, thisArg);
|
||||
this.currentInlineFunction = null;
|
||||
return ret;
|
||||
this.currentInlineFunctions.push(instance);
|
||||
let expr = this.compileCallInlineUnchecked(instance, argumentExpressions, reportNode, thisArg);
|
||||
this.currentInlineFunctions.pop();
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user