import { Types } from './../../typeSystem/types'; export class Function { /** * * @param {string} name * @param {import('./../../typeSystem/itype').IType} returnType * @param {import('./formalParameter').FormalParameter[]} formalParameters * @param {import('./commandBlock').CommandBlock} commandBlock */ constructor(name, returnType, formalParameters, commandBlock) { this.name = name; this.returnType = returnType; this.formalParameters = formalParameters; this.commandBlock = commandBlock; this._sourceInfo = null; } get isMain () { return this.name === null && this.returnType.isCompatible(Types.VOID); } get commands () { return this.commandBlock.commands; } get variablesDeclarations () { return this.commandBlock.variables; } set sourceInfo (sourceInfo) { this._sourceInfo = sourceInfo; } get sourceInfo () { return this._sourceInfo; } hasVariadic () { return this.formalParameters.some( p => p.variadic); } }