dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[DotGNU]Example SQL and XML of DOTGNU/CSCC/csnodes.c


From: James Michael DuPont
Subject: [DotGNU]Example SQL and XML of DOTGNU/CSCC/csnodes.c
Date: Thu, 18 Apr 2002 15:24:34 -0700 (PDT)

Dear Fellow DotGNUers,

I have done the first step in actually *Doing*
something for DotGNU and towards a bridge between the
gcc and pnet and not just thinking and talking  about
what I want to do all the time.

Taking the csnodes.c and running it through the
introspector for one. Tweaking and *SIMPLIFING* the
database model so that you can probably run in on
*ANY* sql database server. Putting it all on a server
that you can download and play with.
Sorry that the last release from me did not have any
documentation or tips on how to use it. One has to be
carefull, the asts are very BIG and hard to use. But
we will get there :=)

I have reduced the database mode down to 3 tables

*node_base
   contains the ID and the type of the node

*node_attr
   contains the ID of the node, type and value of the
attribute.

*node_usage
   contains the fromid, toid , types of nodes and type
of relationship

With these three tables you have a full graph of the
parse tree of the c# compilers node structure.

The SQL for the tables is located on 
http://introspector.sourceforge.net/dotgnu/simple.sql

The data for inserting into the database you will find
in a gz sql file here :
http://introspector.sourceforge.net/dotgnu/____global.xml.sql.gz

The XML that was dumped you will find here :
http://introspector.sourceforge.net/dotgnu/____global.xml.gz
(If you are interested in parsing the XML yourself )
The XML has the following structure: 

<xmlroot> # the root of the document

# tells you what file that was compiled to get these
nodes
<xml_cfile name= NAME OF SOURCE FILE/>

    # each tree node in the parse tree produces such a
xml entry
    <node  idx=NUMBER OF NODE     
           node_name=TYPE OF NODE >

           # RELATIONSHIPS - each relation to a different
node is contained inside of the NODE element
          <   # EACH RELATION is an entity of one of
the following types
              name | type | unql | size | min | max | args |
prms | scpe | flds | body | chan | valu |
              op_0 | op_2 | val  | purp | next

              
              idx="THE ID OF THE OTHER NODE"  
              ref_node_name="THE TYPE OF OTHER NODE TYPE"
           />

           # ATTRIBUTES SOME of the following attributes
might be set : 
          <strg>THE VALUE OF A STRING</strg>
          <srcl>SOURCE LINE</srcl>
          <srcp>SOURCE FILE</srcp>
          <prec>PRECISION</prec>
          <algn>ALIGNMENT</algn>
          <built_in>ALIGNMENT</built_in>
          <low>LOW BYTE of a Constant</low>
          <high>LOW BYTE of a Constant</high>     
          <lngth>Length of a string</lngth>
          <qualconst>is const</qualconst>
          <qualrest>?forgot for now :(</qualrest>
          <qualvol>is volitile</qualcol>          
          <str>SOME TYPE OF PARAMETER FOR THE NODE (extern
for functions, struct for records)</str>

     </node> 
     # MANY OTHER NODEs may follow
</xmlroot>

I am also testing a simple query language for 
accessing the nodes. more about that next time.

The files are located here :
http://introspector.sourceforge.net/dotgnu/

I hope that you can use these files and find them
helpfull. Next step is to create a cross reference
table between the GCC and the CSCC cores.

Following are two example queries that show you the
power of the database.

Mike

First is a list of all the identifiers of record_types
who name begin with IL
introspector_simple=# 

select distinct 
value 
from 
node_usage u,  
node_attr a , 
node_base b 
where 
a.attr_type = 'strg' and 
a.value like '"IL%' 
and a.id=b.id  
and u.to_id = b.id 
and u.usage = 'name' 
and u.from_type = 'record_type';

value                  
----------------------------------------
 "ILNode_AddressOf__"
 "ILNode_AddressOf_vtable__"
 "ILNode_ArrayAccess__"
 "ILNode_ArrayAccess_vtable__"
 "ILNode_ArrayInit__"
 "ILNode_ArrayInit_vtable__"
 "ILNode_AsIs__"
 "ILNode_AsIs_vtable__"
 "ILNode_Assign__"
 "ILNode_Assign_vtable__"
 "ILNode_AttrArgs__"
 "ILNode_BaseAccess__"
 "ILNode_BaseAccess_vtable__"
 "ILNode_BaseElement__"
 "ILNode_BaseElement_vtable__"
 "ILNode_BinaryArith__"
 "ILNode_BinaryArith_vtable__"
 "ILNode_BinaryBitwise__"
 "ILNode_BinaryBitwise_vtable__"
 "ILNode_BinaryExpression_vtable__"
 "ILNode_BinaryShift__"
 "ILNode_BinaryShift_vtable__"
 "ILNode_CastSimple__"
 "ILNode_CastSimple_vtable__"
 "ILNode_CastType__"
 "ILNode_CastType_vtable__"
 "ILNode_Concat__"
 "ILNode_Concat_vtable__"
 "ILNode_Constant__"
 "ILNode_Constant_vtable__"
 "ILNode_DecimalType__"
 "ILNode_DerefField__"
 "ILNode_DerefField_vtable__"
 "ILNode_Deref__"
 "ILNode_Deref_vtable__"
 "ILNode_DocComment__"
 "ILNode_DocComment_vtable__"
 "ILNode_DummyBinaryExpr__"
 "ILNode_DummyBinaryExpr_vtable__"
 "ILNode_DummySem_vtable__"
 "ILNode_DummyUnaryExpr__"
 "ILNode_DummyUnaryExpr_vtable__"
 "ILNode_Dummy_vtable__"
 "ILNode_Expression_vtable__"
 "ILNode_FixAddress__"
 "ILNode_FixAddress_vtable__"
 "ILNode_FixExpr__"
 "ILNode_FixExpr_vtable__"
 "ILNode_FixedDeclList_vtable__"
 "ILNode_Identifier__"
 "ILNode_Identifier_vtable__"
 "ILNode_IndexerAccess__"
 "ILNode_IndexerAccess_vtable__"
 "ILNode_IsNonNull__"
 "ILNode_IsNonNull_vtable__"
 "ILNode_IsNull__"
 "ILNode_IsNull_vtable__"
 "ILNode_LValueBinaryExpr_vtable__"
 "ILNode_LValueNoRefUnaryExpr__"
 "ILNode_LValueNoRefUnaryExpr_vtable__"
 "ILNode_LValueNoRef_vtable__"
 "ILNode_LValueUnaryExpr_vtable__"
 "ILNode_LValue__"
 "ILNode_LValue_vtable__"
 "ILNode_List_vtable__"
 "ILNode_LocalVariableType__"
 "ILNode_LocalVariableType_vtable__"
 "ILNode_LogicalAnd__"
 "ILNode_LogicalAnd_vtable__"
 "ILNode_LogicalNot__"
 "ILNode_LogicalNot_vtable__"
 "ILNode_LogicalOr__"
 "ILNode_LogicalOr_vtable__"
 "ILNode_MemberAccess__"
 "ILNode_MemberAccess_vtable__"
 "ILNode_MemberField__"
 "ILNode_MemberField_vtable__"
 "ILNode_MemberProperty__"
 "ILNode_MemberProperty_vtable__"
 "ILNode_NamedArg__"
 "ILNode_NamedArg_vtable__"
 "ILNode_Namespace__"
 "ILNode_Namespace_vtable__"
 "ILNode_Neg__"
 "ILNode_Neg_vtable__"
 "ILNode_NoOverflow__"
 "ILNode_NoOverflow_vtable__"
 "ILNode_NoPedantic__"
 "ILNode_NoPedantic_vtable__"
 "ILNode_Overflow__"
 "ILNode_Overflow_vtable__"
 "ILNode_Pedantic__"
 "ILNode_Pedantic_vtable__"
 "ILNode_PostDec__"
 "ILNode_PostDec_vtable__"
 "ILNode_PostInc__"
 "ILNode_PostInc_vtable__"
 "ILNode_PreDec__"
 "ILNode_PreDec_vtable__"
 "ILNode_PreInc__"
 "ILNode_PreInc_vtable__"
 "ILNode_QualIdent__"
 "ILNode_QualIdent_vtable__"
 "ILNode_Relational__"
 "ILNode_Relational_vtable__"
 "ILNode_Statement__"
 "ILNode_Statement_vtable__"
 "ILNode_StaticField__"
 "ILNode_StaticProperty__"
 "ILNode_StaticProperty_vtable__"
 "ILNode_ToBool__"
 "ILNode_ToBool_vtable__"
 "ILNode_ToConst__"
 "ILNode_ToConst_vtable__"
 "ILNode_TypeSuffix__"
 "ILNode_TypeSuffix_vtable__"
 "ILNode_UnaryExpression_vtable__"
 "ILNode_Unsafe__"
 "ILNode_Unsafe_vtable__"
 "ILNode_UserBinaryOp__"
 "ILNode_UserBinaryOp_vtable__"
 "ILNode_UserConversion__"
 "ILNode_UserConversion_vtable__"
 "ILNode_UserIncOrDec__"
 "ILNode_UserIncOrDec_vtable__"
 "ILNode_UserLogical__"
 "ILNode_UserLogical_vtable__"
 "ILNode_UserPostDec__"
 "ILNode_UserPostDec_vtable__"
 "ILNode_UserPostInc__"
 "ILNode_UserPostInc_vtable__"
 "ILNode_UserPreDec__"
 "ILNode_UserPreDec_vtable__"
 "ILNode_UserPreInc__"
 "ILNode_UserPreInc_vtable__"
 "ILNode_UserUnaryOp__"
 "ILNode_UsingAlias__"
 "ILNode_UsingAlias_vtable__"
 "ILNode_UsingNamespace__"
 "ILNode_UsingNamespace_vtable__"
 "ILNode__"
 "ILNode_vtable__"


Following is an example query that shows you what type
of nodes point to what other types of nodes in the
current data set (It is loading right now, so not
finished yet). As you can see there is a lot of
information about the tree nodes as records and
fields. 1020 fields in the database, not bad!

introspector_simple# select
from_type,to_type,usage,count(*) from node_usage group
by from_type,to_type,usage order by count(*) desc;
   from_type   |     to_type     | usage | count 
---------------+-----------------+-------+-------
 field_decl    | identifier_node | name  |  1020
 field_decl    | integer_cst     | size  |  1020
 field_decl    | record_type     | scpe  |  1007
 field_decl    | field_decl      | chan  |   917
 field_decl    | pointer_type    | type  |   754
 tree_list     | tree_list       | chan  |   737
 function_decl | function_type   | type  |   512
 function_decl | identifier_node | name  |   512
 tree_list     | pointer_type    | valu  |   495
 function_decl | function_decl   | chan  |   485
 type_decl     | type_decl       | chan  |   345
 function_type | integer_cst     | size  |   322
 function_type | tree_list       | prms  |   319
 record_type   | field_decl      | flds  |   265
 record_type   | integer_cst     | size  |   265
 tree_list     | void_type       | valu  |   260
 type_decl     | identifier_node | name  |   258
 field_decl    | integer_type    | type  |   229
 type_decl     | record_type     | type  |   207
 integer_cst   | integer_type    | type  |   193
 record_type   | identifier_node | name  |   182
 pointer_type  | integer_cst     | size  |   165
 record_type   | record_type     | unql  |   152
 tree_list     | integer_type    | valu  |   152
 integer_type  | integer_cst     | max   |   140
 integer_type  | integer_cst     | min   |   140
 integer_type  | integer_cst     | size  |   140
 function_type | integer_type    | retn  |   133
 type_decl     | integer_type    | type  |   129
 integer_type  | type_decl       | name  |   121
 integer_type  | integer_type    | unql  |   106
 pointer_type  | record_type     | ptd   |   105
 record_type   | type_decl       | name  |   103
 function_type | pointer_type    | retn  |    91
 var_decl      | identifier_node | name  |    78
 function_type | void_type       | retn  |    71
 var_decl      | integer_cst     | size  |    71
 var_decl      | var_decl        | chan  |    69
 const_decl    | enumeral_type   | type  |    65
 const_decl    | identifier_node | name  |    65
 tree_list     | identifier_node | purp  |    64
 tree_list     | integer_cst     | valu  |    64
 const_decl    | const_decl      | chan  |    60
 var_decl      | integer_type    | type  |    44
 pointer_type  | integer_type    | ptd   |    26
 type_decl     | function_decl   | chan  |    24
 var_decl      | pointer_type    | type  |    24
 function_decl | type_decl       | chan  |    19
 tree_list     | enumeral_type   | valu  |    19
 pointer_type  | pointer_type    | unql  |    18
 pointer_type  | function_type   | ptd   |    17
 field_decl    | union_type      | scpe  |    13
 tree_list     | real_type       | valu  |    13
 field_decl    | enumeral_type   | type  |    12
 function_type | real_type       | retn  |    12
 enumeral_type | integer_cst     | max   |    11
 enumeral_type | integer_cst     | min   |    11
 enumeral_type | integer_cst     | size  |    11
 enumeral_type | tree_list       | csts  |    11
 field_decl    | record_type     | type  |    11
 parm_decl     | function_decl   | scpe  |    11
 parm_decl     | identifier_node | name  |    11
 parm_decl     | integer_cst     | size  |    11
 type_decl     | enumeral_type   | type  |    11
 array_type    | integer_cst     | size  |     9
 array_type    | integer_type    | domn  |     9
 field_decl    | array_type      | type  |     9
 pointer_type  | type_decl       | name  |     9
 type_decl     | pointer_type    | type  |     9
 array_type    | integer_type    | elts  |     8
 complex_type  | integer_cst     | size  |     8
 complex_type  | type_decl       | name  |     8
 function_decl | parm_decl       | args  |     8
 function_decl | var_decl        | chan  |     8
 function_type | record_type     | retn  |     8
 pointer_type  | void_type       | ptd   |     8
 type_decl     | complex_type    | type  |     8
 parm_decl     | pointer_type    | argt  |     7
 parm_decl     | pointer_type    | type  |     7
 pointer_type  | pointer_type    | ptd   |     7
 type_decl     | real_type       | type  |     7
 var_decl      | function_decl   | chan  |     7
 enumeral_type | enumeral_type   | unql  |     6
 enumeral_type | type_decl       | name  |     6
 real_type     | integer_cst     | size  |     6
 real_type     | type_decl       | name  |     6
 tree_list     | complex_type    | valu  |     6
 type_decl     | const_decl      | chan  |     6
 var_decl      | array_type      | type  |     6
 const_decl    | type_decl       | chan  |     5
 function_type | enumeral_type   | retn  |     4
 function_type | function_type   | unql  |     4
 function_type | type_decl       | name  |     4
 parm_decl     | integer_type    | argt  |     4
 parm_decl     | integer_type    | type  |     4
 tree_list     | record_type     | valu  |     4
 type_decl     | function_type   | type  |     4
 var_decl      | record_type     | type  |     4
 void_type     | type_decl       | name  |     4
 array_type    | pointer_type    | elts  |     3
 function_type | complex_type    | retn  |     3
 parm_decl     | parm_decl       | chan  |     3
 real_type     | real_type       | unql  |     3
 type_decl     | var_decl        | chan  |     3
 type_decl     | void_type       | type  |     3
 void_type     | void_type       | unql  |     3
 array_type    | record_type     | elts  |     2
 field_decl    | real_type       | type  |     2
 field_decl    | union_type      | type  |     2
 integer_type  | identifier_node | name  |     2
 pointer_type  | real_type       | ptd   |     2
 string_cst    | array_type      | type  |     2
 union_type    | field_decl      | flds  |     2
 union_type    | integer_cst     | size  |     2
 var_decl      | string_cst      | init  |     2
 var_decl      | type_decl       | chan  |     2
 boolean_type  | integer_cst     | size  |     1
 boolean_type  | type_decl       | name  |     1
 type_decl     | boolean_type    | type  |     1
 type_decl     | union_type      | type  |     1




__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]