/* pointer: * type-qualifier-list(opt) * type-qualifier-list(opt) pointer */ void Pointer(Pointer t) { if (t.Pointee is Pointer ptPointee) { Pointer(ptPointee); } WriteSpace(); fmt.Write('*'); TypeFormatter.WriteQualifier(t.Qualifier, fmt); TypeQualifierList(t); }
public void WriteFormalArgument(Identifier arg, bool writeStorage, TypeFormatter t) { if (writeStorage) { WriteFormalArgumentType(arg, writeStorage); writer.Write(" "); writer.Write(arg.Name); } else { t.Write(arg.DataType, arg.Name); } }
public void VisitDeclaration(Declaration decl) { writer.Indent(); Debug.Assert(decl.Identifier.DataType != null, "The DataType property can't ever be null"); TypeFormatter tf = new TypeFormatter(writer, true); tf.Write(decl.Identifier.DataType, decl.Identifier.Name); if (decl.Expression != null) { writer.Write(" = "); decl.Expression.Accept(this); } writer.Terminate(); }
public void WriteFormalArgument(Identifier arg, bool writeStorage, TypeFormatter t) { if (writeStorage) { WriteFormalArgumentType(arg, writeStorage); writer.Write(" "); writer.Write(arg.Name); } else { if (arg.Storage is OutArgumentStorage) { t.Write(new ReferenceTo(arg.DataType), arg.Name); } else { t.Write(arg.DataType, arg.Name); } } }
public void VisitDeclaration(AbsynDeclaration decl) { writer.Indent(); if (decl.Identifier.DataType != null) { TypeFormatter tf = new TypeFormatter(writer, true); tf.Write(decl.Identifier.DataType, decl.Identifier.Name); } else { writer.Write("?unknown?"); writer.Write(" "); decl.Identifier.Accept(this); } if (decl.Expression != null) { writer.Write(" = "); decl.Expression.Accept(this); } writer.Terminate(";"); }
/* type-specifier: * void * char * short * int * long * float * double * signed * unsigned * _Bool -- C99 * _Complex -- C99 * _Imaginary -- C99 * struct-or-union-specifier * enum-specifier * typedef-name. * * GNU extensions. * simple-type-specifier: * __complex__ * __vector__ */ void TypeSpecifier(DataType t) { TypeFormatter.WriteQualifier(t.Qualifier, fmt); if (t is UnknownType) { fmt.Write("<type-error>"); return; } else if (t is EquivalenceClass) { fmt.Write(t.Name); wantSpace = true; return; } else if (t is PrimitiveType) { //case tree_code.VOID_TYPE: //case tree_code.BOOLEAN_TYPE: //case tree_code.CHAR_TYPE: //case tree_code.INTEGER_TYPE: //case tree_code.REAL_TYPE: //if (TYPE_NAME(t) != null) // t = TYPE_NAME(t); //else // t = c_common_type_for_mode(TYPE_MODE(t), TREE_UNSIGNED(t)); WritePrimitiveTypeName((PrimitiveType)t); //if (declaration && !string.IsNullOrEmpty(declaredName)) // fmt.Write(' '); wantSpace = true; return; } else if (t is VoidType) { WriteVoidType((VoidType)t); wantSpace = true; return; } else if (t is UnionType) { fmt.WriteKeyword("union"); fmt.Write(" "); } else if (t is StructureType) { fmt.WriteKeyword("struct"); fmt.Write(" "); } else if (t is EnumType) { fmt.WriteKeyword("enum"); fmt.Write(" "); } if (string.IsNullOrEmpty(t.Name)) { fmt.Write("<anonymous>"); } else { fmt.Write(t.Name); } wantSpace = true; }