//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); }
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 }
public void SetNested(CTypeModifier cTypeModifier) { if (m_nestedModifier == null) { m_nestedModifier = cTypeModifier; } else { m_nestedModifier.SetNested(cTypeModifier); } }
public CTypeModifier ModifyModifier(CTypeModifier cTypeModifier) { if (cTypeModifier == null) { return(this); } else { SetNested(cTypeModifier); return(this); } }
//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)); }
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); }
private static void PushPointerModifier(CTypeModifier param) { pointerModifers.Push(param); }
//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)); }