package pp.s1184725.boppi;

import java.util.*;

import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTreeProperty;

import pp.iloc.model.Reg;
import pp.s1184725.boppi.type.*;

/**
 * This class holds properties of all AST nodes during compilation.
 * 
 * @author Frank Wibbelink
 */
public class Annotations {
	/**
	 * Maps nodes to registers.
	 */
	public ParseTreeProperty<Reg> registers;
	/**
	 * Maps nodes to {@link Type}s.
	 */
	public ParseTreeProperty<Type> types;
	/**
	 * Maps nodes to {@link Variable}s.
	 */
	public ParseTreeProperty<Variable<Type>> variables;
	/**
	 * Maps nodes to their function scope.
	 */
	public ParseTreeProperty<FunctionScope<Type>> function;
	/**
	 * A symbol table
	 */
	public CachingSymbolTable<Type> symbols;
	/**
	 * Maps variable instances to the AST node they reside in.
	 */
	public Map<Variable<Type>,ParserRuleContext> variableRoot;

	/**
	 * Creates a new annotations object with empty maps.
	 */
	public Annotations() {
		registers = new ParseTreeProperty<>();
		types = new ParseTreeProperty<>();
		function = new ParseTreeProperty<>();
		variables = new ParseTreeProperty<>();
		symbols = new CachingSymbolTable<>();
		variableRoot = new HashMap<>();
	}
}
