/// <summary> /// Determines if given the current scoping state, can a variable be defined without causing a conflict /// </summary> /// <param name="name">name of the variable</param> /// <param name="scope">the scope level of the variable to be defined</param> /// <returns>whether or not the variable can be defined without conflict</returns> public bool CanVariableBeDefined(string name, LSLVariableScope scope) { if (scope == LSLVariableScope.Global) { return(!GlobalVariables.ContainsKey(name)); } if (scope == LSLVariableScope.Local) { return(!_scopeVariables.Peek().ContainsKey(name)); } return(true); }
public void DefineVariable(LSLVariableDeclarationNode decl, LSLVariableScope scope) { //return a clone of the node into the global pool of variables, so if we modify it //it does not modify the tree node we put it if (scope == LSLVariableScope.Global) { _globalVariables.Add(decl.Name, decl); } if (scope == LSLVariableScope.Local) { _scopeVariables.Peek().Add(decl.Name, decl); } }