001/*
002 * Copyright (c) 2012-2017 Institut National des Sciences Appliquées de Lyon (INSA-Lyon)
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 */
009
010package org.eclipse.golo.compiler.ir;
011
012import org.eclipse.golo.compiler.parser.GoloASTNode;
013
014public class FunctionInvocation extends AbstractInvocation {
015
016  private boolean onReference = false;
017  private boolean onModuleState = false;
018  private boolean anonymous = false;
019  private boolean constant = false;
020
021  FunctionInvocation() {
022    super("anonymous");
023    anonymous = true;
024  }
025
026  FunctionInvocation(String name) {
027    super(name);
028  }
029
030  @Override
031  public FunctionInvocation ofAST(GoloASTNode n) {
032    super.ofAST(n);
033    return this;
034  }
035
036  public FunctionInvocation onReference(boolean isOnReference) {
037    this.onReference = isOnReference;
038    return this;
039  }
040
041  public FunctionInvocation onReference() {
042    return onReference(true);
043  }
044
045  public boolean isOnReference() {
046    return onReference;
047  }
048
049  public boolean isAnonymous() {
050    return anonymous;
051  }
052
053  public FunctionInvocation onModuleState(boolean isOnModuleState) {
054    this.onModuleState = isOnModuleState;
055    return this;
056  }
057
058  public FunctionInvocation onModuleState() {
059    return onModuleState(true);
060  }
061
062  public boolean isOnModuleState() {
063    return onModuleState;
064  }
065
066  public FunctionInvocation constant(boolean isConstant) {
067    this.constant = isConstant;
068    return this;
069  }
070
071  public FunctionInvocation constant() {
072    return this.constant(true);
073  }
074
075  public boolean isConstant() {
076    return constant;
077  }
078
079  @Override
080  public FunctionInvocation withArgs(Object... arguments) {
081    super.withArgs(arguments);
082    return this;
083  }
084
085  @Override
086  public String toString() {
087    return String.format("FunctionInvocation{name=%s}", getName());
088  }
089
090  @Override
091  public void accept(GoloIrVisitor visitor) {
092    visitor.visitFunctionInvocation(this);
093  }
094
095}