Ejemplo n.º 1
0
        // SetUloh1 - this method is done. Do the same with two similar methods below it
        public EXEPrimitiveVariable FindPrimitiveVariableByName(String Name)
        {
            EXEPrimitiveVariable Result       = null;
            EXEScope             CurrentScope = this;

            while (CurrentScope != null)
            {
                foreach (EXEPrimitiveVariable CurrentVariable in CurrentScope.PrimitiveVariables)
                {
                    if (CurrentVariable.Name == Name)
                    {
                        Result = CurrentVariable;
                        break;
                    }
                }

                if (Result != null)
                {
                    break;
                }

                CurrentScope = CurrentScope.SuperScope;
            }

            return(Result);
        }
Ejemplo n.º 2
0
        public String Evaluate(EXEScope Scope, CDClassPool ExecutionSpace)
        {
            String Result = null;

            String ValueType = EXETypes.DetermineVariableType("", this.Value);

            if (ValueType == null)
            {
                return(Result);
            }

            // If we have simple value, e.g. 5, 3.14, "hi Madelyn", we are good
            if (!EXETypes.ReferenceTypeName.Equals(ValueType))
            {
                Result = this.Value;
            }
            // We got here because we have a variable name, the variable is of primitive value
            else if (EXETypes.ReferenceTypeName.Equals(ValueType))
            {
                EXEPrimitiveVariable ThisVariable = Scope.FindPrimitiveVariableByName(this.Value);
                if (ThisVariable != null)
                {
                    Result = ThisVariable.Value;
                }
            }

            /*Console.WriteLine("Operand: " + this.Value);
             * Console.WriteLine("Result: " + Result);*/

            return(Result);
        }
Ejemplo n.º 3
0
        public bool AddVariable(EXEPrimitiveVariable Variable)
        {
            bool Result = false;

            if (!VariableNameExists(Variable.Name))
            {
                this.PrimitiveVariables.Add(Variable);
                Result = true;
            }

            return(Result);
        }
Ejemplo n.º 4
0
        public override Boolean Execute(OALProgram OALProgram, EXEScope Scope)
        {
            //Console.WriteLine("Assignment is being executed");
            Boolean Result = false;

            String AssignedValue = this.AssignedExpression.Evaluate(Scope, OALProgram.ExecutionSpace);

            if (AssignedValue == null)
            {
                return(Result);
            }

            // If we are assigning to a variable
            if (this.AttributeName == null)
            {
                //Console.WriteLine("Assigning value: " + AssignedValue + " to variable " + this.VariableName);

                EXEPrimitiveVariable Variable = Scope.FindPrimitiveVariableByName(this.VariableName);
                // If the variable doesnt exist, we simply create it
                if (Variable == null)
                {
                    //Console.WriteLine("Creating new var " + this.VariableName);
                    Result = Scope.AddVariable(new EXEPrimitiveVariable(this.VariableName, AssignedValue));
                }
                //If variable exists and its type is UNDEFINED
                else if (EXETypes.UnitializedName.Equals(Variable.Type))
                {
                    //Console.WriteLine("Assigning to unitialized var" + this.VariableName);
                    Result = Variable.AssignValue(Variable.Name, AssignedValue);
                }
                // If the variable exists and is primitive
                else if (!EXETypes.ReferenceTypeName.Equals(Variable.Type))
                {
                    //Console.WriteLine("Assigning to initialized var" + this.VariableName);
                    // If the types don't match, this fails and returns false
                    AssignedValue = EXETypes.AdjustAssignedValue(Variable.Type, AssignedValue);
                    Result        = Variable.AssignValue("", AssignedValue);
                }

                // Variable exists and is not primitive. What to do, what to do?
                // We do nothing, we CANNOT ASSIGN TO HANDLES!!!
            }
            // We are assigning to an attribute of a variable
            else
            {
                EXEReferenceEvaluator RefEvaluator = new EXEReferenceEvaluator();
                Result = RefEvaluator.SetAttributeValue(this.VariableName, this.AttributeName, Scope, OALProgram.ExecutionSpace, AssignedValue);
                //Console.WriteLine("Tried to assign " + AssignedValue + " to " + this.VariableName + "." + this.AttributeName);
            }

            //Console.WriteLine("Assignment Result: " + Result);
            return(Result);
        }