Ejemplo n.º 1
0
Archivo: fgs.cs Proyecto: Sciumo/gaigen
 /// <summary>
 /// Determines whether this fgs is a converter. To be a converted, the name
 /// of the function should start with and underscore (<c>_</c>) and the remaining
 /// part of the name should be a specialized multivector typename.
 /// </summary>
 /// <returns>true if this fgs is a converter (underscore constructor).</returns>
 public bool IsConverter(Specification S)
 {
     if (ArgumentTypeNames.Length != 1) return false;
     else if ((Name.Length > 0) && (Name[0] == '_'))
         return (S.IsSpecializedMultivectorName(Name.Substring(1)));
     else return false;
 }
Ejemplo n.º 2
0
Archivo: xml.cs Proyecto: Sciumo/gaigen
        /// <summary>
        /// Parses an XML_CONSTANT element and stores the result.
        /// 
        /// The XML_CONSTANT element should contain the name, type and basis blades values.
        /// </summary>
        /// <param name="E">XML_CONSTANT element</param>
        private static void ParseConstantElementAndAttributes(Specification S, XmlElement E)
        {
            string constantName = null;
            string typeName = null;

            { // handle attributes
                XmlAttributeCollection A = E.Attributes;

                // handle all attributes
                for (int i = 0; i < A.Count; i++)
                {
                    // name
                    if (A[i].Name == XML_NAME)
                        constantName = A[i].Value;

                    // type
                    else if (A[i].Name == XML_TYPE)
                        typeName = A[i].Value;
                }

                // sanity check on name
                if (constantName == null)
                    throw new G25.UserException("XML parsing error: Missing '" + XML_NAME + "' attribute in element '" + XML_CONSTANT + "'.");
                if (typeName == null)
                    throw new G25.UserException("XML parsing error: Missing '" + XML_TYPE + "' attribute in element '" + XML_CONSTANT + "'.");

                // check if name is already present
                if (!S.IsSpecializedMultivectorName(typeName))
                    throw new G25.UserException("In constant definition: type '" + typeName + "' is not a specialized multivector.");

            } // end of 'handle attributes'

            // parse list of basis blades and optional comment
            List<G25.rsbbp.BasisBlade> L = ParseBasisBladeList(S, E.FirstChild, constantName);
            string comment = ParseComment(S, E.FirstChild);

            SMV type = S.GetType(typeName) as SMV;

            // add new type to list of specialized multivectors (constuctor should check if all are constant
            S.AddConstant(new ConstantSMV(constantName, type, L, comment));
        }