Example #1
0
        //exit function prototype scope
        public static void EndFunctionDeclarator(bool isPointer, int numParam)
        {
            CIdentifier.ExitFunctionPrototypeScope();

            CDeclarator old = PopDeclarator();

            List <CParamater> Params = new List <CParamater>();

            for (int i = 0; i < numParam; i++)
            {
                Params.Add(PopParam());
            }

            CDeclarator result = new CDeclarator();

            result.Identifer    = old.Identifer;
            result.TypeModifier = CTypeModifier.FunctionModifier(Params).ModifyModifier(old.TypeModifier);

            if (isPointer)
            {
                result.TypeModifier = PopPointerModifier().ModifyModifier(result.TypeModifier);
            }

            PushDeclarator(result);
        }
Example #2
0
            public CTypeModifier(CTypeModifierType type, IEnumerable <CType> paramTypes, CTypeModifier nested)
            {
                modifierType = type;
                m_paramTypes = paramTypes != null?paramTypes.ToList() : null;

                m_nestedModifier = nested;
                arraySize        = 0; // todo this will be passed in at contruction time
            }
Example #3
0
 public void SetNested(CTypeModifier cTypeModifier)
 {
     if (m_nestedModifier == null)
     {
         m_nestedModifier = cTypeModifier;
     }
     else
     {
         m_nestedModifier.SetNested(cTypeModifier);
     }
 }
Example #4
0
 public CTypeModifier ModifyModifier(CTypeModifier cTypeModifier)
 {
     if (cTypeModifier == null)
     {
         return(this);
     }
     else
     {
         SetNested(cTypeModifier);
         return(this);
     }
 }
Example #5
0
        //pointer modifier
        //cahnges a type to be a pointer
        public static void PushPointerModifier(int numQualifiers, bool isNested)
        {
            List <CDeclarationSpecifier> quals = new List <CDeclarationSpecifier>();

            for (int i = 0; i < numQualifiers; i++)
            {
                quals.Add(PopDeclSpec());
            }

            CTypeModifier nestedPointer = isNested ? PopPointerModifier() : null;

            PushPointerModifier(CTypeModifier.PointerModifier(quals, nestedPointer));
        }
Example #6
0
        public static void ArrayDeclarator(bool isPointer, int numTypeQualifiers, bool hasAssgnExpr)
        {
            CDeclarator old = PopDeclarator();

            CExpression assgn = hasAssgnExpr ? CExpression.PopExpression() : null;

            List <CDeclarationSpecifier> qualifiers = new List <CDeclarationSpecifier>();

            for (int i = 0; i < numTypeQualifiers; i++)
            {
                qualifiers.Add(PopDeclSpec());
            }

            CDeclarator result = new CDeclarator();

            result.Identifer    = old.Identifer;
            result.TypeModifier = CTypeModifier.ArrayModifier(qualifiers, assgn).ModifyModifier(old.TypeModifier);
            if (isPointer)
            {
                result.TypeModifier = PopPointerModifier().ModifyModifier(result.TypeModifier);
            }

            PushDeclarator(result);
        }
Example #7
0
 private static void PushPointerModifier(CTypeModifier param)
 {
     pointerModifers.Push(param);
 }
Example #8
0
 //makes a type T into T*
 //ignore specifers for now
 public static CTypeModifier PointerModifier(IEnumerable <CDeclarationSpecifier> quals, CTypeModifier nestedPointer)
 {
     return(new CTypeModifier(CTypeModifierType.Pointer, null, nestedPointer));
 }