package processor;

import java.util.HashMap;

public class StackFrame {

	public enum FrameType {
		FUNCTION,
		LOOP
	}
	
    private HashMap< String, Object > data;
    private FrameType type;
    
    public StackFrame( FrameType type )
    {
    	this.type = type;
        data = new HashMap< String, Object >();
    }
    
    public FrameType getType()
    {
    	return type;
    }
    
    public <T> void declare( String name, T value )
    {
        data.put( name, (Object)value );
    }
    
    public <T> void set( String name, T value )
    {
        data.put( name, (Object)value );
    }
    
    public void undeclare( String name )
    {
        data.remove( name );
    }
    
    public boolean isDefined( String name )
    {
        return data.containsKey( name );
    }
    
    @SuppressWarnings("unchecked")
    public <T> T get( String name )
    {
        return (T)data.get( name );
    }
}
