public CElement visitEnumType(ClangSharp.Type Type) { try { if (Type.Declaration.Kind != CursorKind.NoDeclFound) { CDataType datatype = (CDataType)visitArithMeticType(Type); datatype.Kind = DataTypeKind.ENUM_TYPE; datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString()); foreach (ClangSharp.Cursor child in Type.Declaration.Children) { CElement literal = _Factory.fac_getCParser().CParser_VisitVariableCursor(child); datatype.Children.Add(literal); datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + literal.ID); } return(datatype); } else { return(CTypeParser_ParseDataType(Type.Canonical)); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
public CElement visitArithMeticType(ClangSharp.Type type) { try { CDataType datatype = new CDataType(); datatype.ID = CCodeFramework.Util.Util.ComputeMd5(type); datatype.ElementKind = ElementKind.DataType; datatype.Kind = DataTypeKind.ARITHMETIC_TYPE; _DB.AstDB_AddElement(datatype); datatype.Name = type.Spelling; if (type.IsConstQualifiedType) { datatype.Qualifier = Qualifier.CONST; } else if (type.IsVolatileQualifiedType) { datatype.Qualifier = Qualifier.VOLATILE; } return(datatype); } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
public CElement visitFunctionprototype(ClangSharp.Type type) { CDataType datatype = (CDataType)visitArithMeticType(type); datatype.Kind = DataTypeKind.FUNCTION_PROTOTYPE; datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString()); return(datatype); }
public CElement visitTypeDefType(ClangSharp.Type type) { CDataType datatype = (CDataType)visitArithMeticType(type); datatype.Kind = DataTypeKind.TYPEDEF_TYPE; if (type.Declaration.Kind != CursorKind.NoDeclFound) { datatype.Parent = CTypeParser_ParseDataType(type.Declaration.TypedefDeclUnderlyingType).ID; } else { datatype.Parent = CTypeParser_ParseDataType(type.Canonical).ID; } datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString() + datatype.Parent); return(datatype); }
public CElement visitStructOrUnionType(ClangSharp.Type type) { try { if (type.Declaration.Kind != CursorKind.NoDeclFound) { CDataType datatype = (CDataType)visitArithMeticType(type); if (type.Declaration.Kind == CursorKind.UnionDecl) { datatype.Kind = DataTypeKind.UNION_TYPE; } else if (type.Declaration.Kind == CursorKind.StructDecl) { datatype.Kind = DataTypeKind.STRUCT_TYPE; } datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString()); foreach (Cursor child in type.Declaration.Children) { datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + child.Spelling + child.Type.Spelling); } foreach (Cursor child in type.Declaration.Children) { if (child.Kind == CursorKind.FieldDecl) { CElement attr = _Factory.fac_getCParser().CParser_VisitVariableCursor(child); if (attr != null) { datatype.Children.Add(attr); } } } return(datatype); } else { return(CTypeParser_ParseDataType(type.Canonical)); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
public CElement visitArrayType(ClangSharp.Type type) { try { CDataType datatype = (CDataType)visitArithMeticType(type); datatype.Kind = DataTypeKind.ARRAY_TYPE; datatype.Parent = CTypeParser_ParseDataType(type.ArrayElementType).ID; datatype.Multiplicity = (int)type.NumOfElements; datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString() + datatype.Parent + datatype.Multiplicity.ToString()); return(datatype); } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }
public DataType Fac_GetXmlDataType(CDataType d) { DataType dt = new DataType(); dt.Name = d.Name; dt.Kind = d.Kind.ToString(); dt.File = d.File; dt.ID = d.ID; dt.Column = d.Column.ToString(); dt.Line = d.Line.ToString(); dt.pointToIDref = d.Parent; dt.underlyingTypeIDref = d.Parent; dt.Qualifier = d.Qualifier.ToString(); dt.StorageClass = d.StorageClass.ToString(); foreach (CVariable v in d.Children) { dt.Attributes.Add(Fac_GetXmlVariableType(v)); } return(dt); }
public CElement visitPointerType(ClangSharp.Type type) { try { if (type != null) { CDataType datatype = (CDataType)visitArithMeticType(type); if (datatype != null) { datatype.Kind = DataTypeKind.POINTER_TYPE; if (type.Pointee.Canonical.TypeKind == ClangSharp.Type.Kind.FunctionProto) { datatype.Kind = DataTypeKind.FUNCTION_POINTER; } CElement elm = CTypeParser_ParseDataType(type.Pointee); if (elm != null) { datatype.Parent = elm.ID; } datatype.ID = CCodeFramework.Util.Util.ComputeMd5ForString(datatype.ID + datatype.Kind.ToString() + datatype.Parent); return(datatype); } else { return(null); } } else { return(null); } } catch (Exception err) { Console.WriteLine(err.ToString()); return(null); } }