123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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;
- }
- }
- }
|