Example #1
0
        /// <summary>
        /// Adds a temporary variable.
        /// </summary>
        /// <returns>The temporary variable.</returns>
        /// <param name="type">Type.</param>
        public Variable AddTemporaryVariable(GraphicFooType type)
        {
            string   id       = temporaryPrefix + temporaryVariables.GetCount();
            Variable variable = new Variable(id, type);

            temporaryVariables.AddVariable(variable);
            return(variable);
        }
Example #2
0
        /// <summary>
        /// Adds a global temporary.
        /// </summary>
        /// <returns>The global temporary.</returns>
        /// <param name="type">Type.</param>
        public static Variable AddGlobalTemporary(GraphicFooType type)
        {
            string   id       = temporaryPrefix + globalTemporary.GetCount();
            Variable variable = new Variable(id, type);

            globalTemporary.AddVariable(variable);
            return(variable);
        }
Example #3
0
        /// <summary>
        /// Matchs the function parameters.
        /// </summary>
        /// <param name="procedure">Procedure.</param>
        /// <param name="parameters">Parameters.</param>
        private static void MatchParameters(
            Procedure procedure,
            VariableBlock parameters)
        {
            // Check parameter count consistency
            int procedureParameterCount = procedure.GetParameterCount();
            int parameterCallCount      = parameters.GetCount();

            if (procedureParameterCount != parameterCallCount)
            {
                Console.WriteLine(
                    "Call to {1}, with wrong numer of parameters ({2})",
                    procedure.name,
                    parameterCallCount
                    );
                return;
            }

            List <Variable> parameterList          = parameters.ToList();
            List <Variable> procedureParameterList =
                procedure.GetParameters().ToList();

            // Assign parameters
            for (int i = 0; i < parameterCallCount; i++)
            {
                if (parameterList [i].type == procedureParameterList [i].type)
                {
                    // TODO define paramX
                    Quadruple param =
                        new Quadruple(
                            Operators.Param,
                            ProgramMemory.FindVariable(
                                scope,
                                parameterList [i].name
                                ),
                            procedure.GetParameters().GetVariableAt(i)
                            );
                    PushQuadruple(param);
                }
                else
                {
                    Console.WriteLine(
                        "On call to {1}, parameter [{2}] {3} does not match the expected type {4}",
                        procedure.name,
                        i,
                        procedureParameterList [i].name,
                        procedureParameterList [i].type.ToString()
                        );
                    return;
                }
            }
        }
Example #4
0
 /// <summary>
 /// Gets the parameter count.
 /// </summary>
 /// <returns>The parameter count.</returns>
 public int GetParameterCount()
 {
     return(parameters.GetCount());
 }