public bool UsesVariable(BlockVariable variable) { if(Variable.Equals(variable)) return true; if(Expression.Equals(variable)) return true; return false; }
public bool UsesVariable(BlockVariable variable) { return false; }
//returns true if any chunks or subblocks use a variable. public bool UsesVariable(BlockVariable variable) { foreach(IProgramChunk chunk in program) if(chunk.UsesVariable(variable)) return true; return false; }
public bool HasVariable(BlockVariable variable) { if (GetVariable(variable) != null) return true; else return false; }
/// <summary> /// Searches for variable in the pool of local variables. /// If it doesn't exist, create a new one, add it to the /// pool, and return it. /// </summary> /// <param name="name">Variable name.</param> /// <returns>BlockVariable. Never null.</returns> public BlockVariable GetVariableByNameForced(string name) { BlockVariable variable = GetVariableByName(name); if (variable == null) { variable = new BlockVariable(name); AddVariable(variable); } return variable; }
public BlockVariable GetVariable(BlockVariable variable) { foreach (BlockVariable var in Variables) if (var.Equals(variable)) return var; return null; }
public void AddVariable(BlockVariable newVariable) { Variables.AddLast(newVariable); }
public bool UsesVariable(BlockVariable variable) { //equals shouldn't be used here but that would be more standard if (Name == variable.Name) return true; return false; }
public bool Equals(BlockVariable variable) { if (this.Name.Equals(variable.Name)) { if (this.Type.Equals(variable.Type) || !(variable.Type == VariableType.UNDEFINED)) if (this.Source.Equals(variable.Source) || !(variable.Source == VariableSource.UNDEFINED)) return true; } return false; }
//NOTE: we only allow the assignment to a variable, constants // can't change value. public ProgramChunkAssignment(BlockVariable variable, ProgramChunkExpression expression) { Variable = variable; Expression = expression; }