import { Expression } from './expression'; import { LanguageDefinedFunction } from '../../processor/definedFunctions'; export class FunctionCall extends Expression { /** * * @param {string} id * @param {Expression[]} actualParameters */ constructor (id, actualParameters) { super(); this.id = id; this.actualParameters = actualParameters; } get isMainCall () { return this.id === null; } get parametersSize () { return this.actualParameters.length; } toString () { let name = null; if(this.isMainCall) { name = LanguageDefinedFunction.getMainFunctionName(); } else { name = LanguageDefinedFunction.getLocalName(this.id); } let params = null; if(this.actualParameters.length == 0) { params = "()"; } else { const strParams = this.actualParameters.map(v => v.toString()); params = "(" + strParams.join(",") + ")"; } if(this.parenthesis) { return `(${name + params})`; } else { return name + params; } } }