Пример #1
0
 /// <summary>
 /// Adds 'P' to the list of code generator plugins'. 
 /// If P does not support the right language, throws an exception.
 /// Does nothing if 'P' is already on the list.
 /// </summary>
 public void AddCodeGeneratorPlugin(G25.CodeGeneratorPlugin P)
 {
     if (P.Language() != Language)
         throw new Exception("G25.CodeGeneratorLoader.AddCodeGeneratorPlugin(): the code generator does not generate for language '" + Language + "' but for language '" + P.Language() + "' instead");
     // if already on list simply return
     for (int i = 0; i < m_codeGeneratorPlugins.Count; i++)
         if (m_codeGeneratorPlugins[i].GetType() == P.GetType())
             return;
     m_codeGeneratorPlugins.Add(P);
 }
Пример #2
0
        /// <summary>
        /// Sets the main code generator to 'CG'. If CG does not support the right language, throws an exception.
        /// </summary>
        public void SetMainCodeGenerator(G25.CodeGenerator CG)
        {
            if (CG.Language() != Language)
                throw new Exception("G25.CodeGeneratorLoader.SetMainCodeGenerator(): the code generator does not generate for language '" + Language + "' but for language '" + CG.Language() + "' instead");

            if (m_codeGenerator != null)
            {
                if (m_codeGenerator.GetType() == CG.GetType())
                    return;
                // else: TO DO; // a duplicate of the code generator was detected. Now what? throw an exception? write an error message to console? TO DO!
            }

            m_codeGenerator = CG;
        }
Пример #3
0
        /// <summary>
        /// Constructs a new FuncArgInfo class for a specific argument 'argIdx' of function 'F'.
        /// </summary>
        /// <param name="S">Used for retrieving the G25.VariableType of 'm_typeName'.</param>
        /// <param name="F">Function for which this FuncArgInfo describes an argument.</param>
        /// <param name="argIdx">Index of argument. Use -1 for artificial 'return argument' used for the C language.</param>
        /// <param name="FT">Floating point type of the type of the argument.</param>
        /// <param name="defaultTypeName">Name of the type of the argument.</param>
        /// <param name="computeMultivectorValue">Set to true to convert the type into symbolic code. Uses 'F' to obtain the actual name of the variable to use inside the symbolic multivector.</param>
        public FuncArgInfo(G25.Specification S, G25.fgs F, int argIdx, G25.FloatType FT, string defaultTypeName, bool computeMultivectorValue)
        {
            m_mvInterface = true;
            m_name = F.GetArgumentName(argIdx);
            m_typeName = F.GetArgumentTypeName(argIdx, defaultTypeName);
            m_type = S.GetType(m_typeName);
            m_varType = m_type.GetVariableType();
            if (m_varType != VARIABLE_TYPE.FLOAT) m_floatType = FT;
            else m_floatType = S.GetFloatType(m_typeName);

            // set mangled type name (depends on whether type is scalar or not)
            if ((m_varType == VARIABLE_TYPE.FLOAT) || (m_varType == VARIABLE_TYPE.ENUM))
            {
                m_mangledTypeName = m_typeName;
            }
            else {
                m_mangledTypeName = FT.GetMangledName(S, m_typeName);

                // temp (currently disabled) test for C# and Java
                // if (S.OutputCSharpOrJava() && (m_varType == VARIABLE_TYPE.GMV))
                // m_mangledTypeName = m_mangledTypeName + G25.CG.Shared.Main.IF_SUFFIX;
            }

            // set pointer / non pointer flag
            m_pointer = F.GetArgumentPtr(S, argIdx);

            // set array  flag
            m_array = F.GetArgumentArr(S, argIdx);

            m_constant = (argIdx >= 0);

            if (computeMultivectorValue) {
                if (m_varType == VARIABLE_TYPE.SMV)
                {
                    m_multivectorValue = new RefGA.Multivector[1] { Symbolic.SMVtoSymbolicMultivector(S, (G25.SMV)m_type, m_name, m_pointer) };
                }
                else if (m_varType == VARIABLE_TYPE.GMV)
                    m_multivectorValue = Symbolic.GMVtoSymbolicMultivector(S, (G25.GMV)m_type, m_name, m_pointer, -1); // -1 = sym mv for all groups
                else if (m_varType == VARIABLE_TYPE.FLOAT)
                    m_multivectorValue = new RefGA.Multivector[1] { Symbolic.ScalarToSymbolicMultivector(S, (G25.FloatType)m_type, m_name) };
                else
                {
                    // OM: do nothing?
                    m_multivectorValue = null;
                }
            }
        }