1
0

functionCall.js 824 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { Expression } from './expression';
  2. import { LanguageDefinedFunction } from '../../processor/definedFunctions';
  3. export class FunctionCall extends Expression {
  4. constructor (id, actualParameters) {
  5. super();
  6. this.id = id;
  7. this.actualParameters = actualParameters;
  8. }
  9. get isMainCall () {
  10. return this.id === null;
  11. }
  12. get parametersSize () {
  13. return this.actualParameters.length;
  14. }
  15. toString () {
  16. let name = null;
  17. if(this.isMainCall) {
  18. name = LanguageDefinedFunction.getMainFunctionName();
  19. } else {
  20. name = LanguageDefinedFunction.getLocalName(this.id);
  21. }
  22. let params = null;
  23. if(this.actualParameters.length == 0) {
  24. params = "()";
  25. } else {
  26. const strParams = this.actualParameters.map(v => v.toString());
  27. params = "(" + strParams.join(",") + ")";
  28. }
  29. return name + params;
  30. }
  31. }