1
0

function.js 677 B

1234567891011121314151617181920212223242526272829303132
  1. import { Types } from './../../typeSystem/types';
  2. export class Function {
  3. constructor(name, returnType, formalParameters, commandBlock) {
  4. this.name = name;
  5. this.returnType = returnType;
  6. this.formalParameters = formalParameters;
  7. this.commandBlock = commandBlock;
  8. this._sourceInfo = null;
  9. }
  10. get isMain () {
  11. return this.name === null && this.returnType.isCompatible(Types.VOID);
  12. }
  13. get commands () {
  14. return this.commandBlock.commands;
  15. }
  16. get variablesDeclarations () {
  17. return this.commandBlock.variables;
  18. }
  19. set sourceInfo (sourceInfo) {
  20. this._sourceInfo = sourceInfo;
  21. }
  22. get sourceInfo () {
  23. return this._sourceInfo;
  24. }
  25. }