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;
 }
Exemplo n.º 3
0
        //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;
        }
Exemplo n.º 4
0
 public bool HasVariable(BlockVariable variable)
 {
     if (GetVariable(variable) != null)
         return true;
     else
         return false;
 }
Exemplo n.º 5
0
        /// <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;
        }
Exemplo n.º 6
0
        public BlockVariable GetVariable(BlockVariable variable)
        {
            foreach (BlockVariable var in Variables)
                if (var.Equals(variable))
                    return var;

            return null;
        }
Exemplo n.º 7
0
 public void AddVariable(BlockVariable newVariable)
 {
     Variables.AddLast(newVariable);
 }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
 //NOTE: we only allow the assignment to a variable, constants
 //      can't change value.
 public ProgramChunkAssignment(BlockVariable variable, ProgramChunkExpression expression)
 {
     Variable = variable;
     Expression = expression;
 }