Interface VariableDeclarations

All Superinterfaces:
Serializable
All Known Implementing Classes:
InstancesHelper, NoVariables, SimpleVariableDeclarations, StatsHelper, VariableDeclarationsCompositor

public interface VariableDeclarations extends Serializable
Interface to expose variables to a program.

It is deliberately kept very simple to give as little constraints as possible to implementations.

There is an implied invariant here:
hasVariable(String) == true -> getVariable(String) != null

hasVariable(String) should be pure i.e. have no side effects.
Whereas getVariable(String) may have side effects.
(This is useful for creating variables on the fly in getVariable(String))
Version:
$Revision: 1000 $
Author:
Benjamin Weber ( benweber at student dot ethz dot ch )
  • Method Summary

    Modifier and Type
    Method
    Description
    Tries to fetch a variable
    boolean
    Whether the variable is declared
  • Method Details

    • hasVariable

      boolean hasVariable(String name)
      Whether the variable is declared
      Parameters:
      name - name of the variable being queried
      Returns:
      whether the variable is declared
    • getVariable

      Node getVariable(String name)
      Tries to fetch a variable

      Before a variable is fetched it should be checked whether it is declared through hasVariable(String).
      Parameters:
      name - name of the variable to be fetched
      Returns:
      an AST (abstract syntax tree) node representing the variable