org.jamesii.ml3.parser.buildIns.mathFunctions.IMathFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ml3 Show documentation
Show all versions of ml3 Show documentation
The Modeling Language for Linked Lives, a domain specific modeling language for agent-based
computational demography.
/*
* Copyright 2018 University of Rostock
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jamesii.ml3.parser.buildIns.mathFunctions;
import org.jamesii.ml3.model.types.IType;
import org.jamesii.ml3.model.validation.typeChecking.Scope;
import org.jamesii.ml3.model.values.IValue;
import org.jamesii.ml3.parser.IParseTreeNode;
import org.jamesii.ml3.simulator.context.IContext;
import java.util.Collection;
/**
* Represents one of ML3's buildin maths functions, e.g., absolute value or sine.
*/
public interface IMathFunction {
/**
* Evaluates a function call on the given parameters, using the given source of randomness,
* if the function is stochastic.
*
* @param parameters the parameters
* @param context the context of the evaluation with the important local information
* @return the result of the function call
*/
IValue evaluate(Collection parameters, IContext context);
/**
* Infers the return type of a call to this function, when then parameters are of the given types.
* Sets the return type at the AST node.
* Also checks if the function is called with the correct parameters.
* May report type errors.
*
* @param parameters the parameter's types
* @param currentNode the AST node that is type checked
* @return the return type of the function call represented by the AST node
*/
IType getType(Collection parameters, Scope scope, IParseTreeNode currentNode);
/**
* Returns the function's name.
* @return the function's name
*/
String getName();
}