Skip to content
  • yui-knk's avatar
    74c67811
    Change RNode structure from union to struct · 74c67811
    yui-knk authored
    All kind of AST nodes use same struct RNode, which has u1, u2, u3 union members
    for holding different kind of data.
    This has two problems.
    
    1. Low flexibility of data structure
    
    Some nodes, for example NODE_TRUE, don’t use u1, u2, u3. On the other hand,
    NODE_OP_ASGN2 needs more than three union members. However they use same
    structure definition, need to allocate three union members for NODE_TRUE and
    need to separate NODE_OP_ASGN2 into another node.
    This change removes the restriction so make it possible to
    change data structure by each node type.
    
    2. No compile time check for union member access
    
    It’s developer’s responsibility for using correct member for each node type when it’s union.
    This change clarifies which node has which type of fields and enables compile time check.
    
    This commit also changes node_buffer_elem_struct buf management to handle
    different size data with alignment.
    74c67811
    Change RNode structure from union to struct
    yui-knk authored
    All kind of AST nodes use same struct RNode, which has u1, u2, u3 union members
    for holding different kind of data.
    This has two problems.
    
    1. Low flexibility of data structure
    
    Some nodes, for example NODE_TRUE, don’t use u1, u2, u3. On the other hand,
    NODE_OP_ASGN2 needs more than three union members. However they use same
    structure definition, need to allocate three union members for NODE_TRUE and
    need to separate NODE_OP_ASGN2 into another node.
    This change removes the restriction so make it possible to
    change data structure by each node type.
    
    2. No compile time check for union member access
    
    It’s developer’s responsibility for using correct member for each node type when it’s union.
    This change clarifies which node has which type of fields and enables compile time check.
    
    This commit also changes node_buffer_elem_struct buf management to handle
    different size data with alignment.
Loading