/// <summary> /// Define a scalar /// </summary> /// <param name="offset"></param> public AttrVar(int offset) { m_offset = offset; m_type = null;//Single integers have the default null type }
/// <summary> /// Define an array /// </summary> /// <param name="offset"></param> /// <param name="startIndex"></param> /// <param name="endIndex"></param> public AttrVar(int offset, AttrType type) { m_offset = offset; m_type = type; }
/// <summary> /// When a type is declared after any number of variables have been added, /// set all cached variables to that type and add them to the current scope. /// The type is always an array. /// Clear the cached variables afterwards /// </summary> /// <param name="type"></param> public void commitTypedVar(AttrType type) { Scope curScope = m_scopes.Peek(); //Add variables by name mapped to their attribute to the top hashmap of a stack of hashes foreach (String var in m_Vars) { curScope.set(var, new AttrVar(curScope.m_offset, type)); //make room on the stack for this array curScope.m_offset += Attribute.INTEGER_SIZE * (type.m_endIndex - type.m_startIndex + 1); } m_Vars.Clear();//clear the cached variables }