Ignore:
Timestamp:
Jul 30, 2015, 3:56:18 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
093f1a0
Parents:
51b986f
Message:

asm statement, memory leaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r51b986f r7f5566b  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 16 16:25:12 2015
    13 // Update Count     : 1267
     12// Last Modified On : Thu Jul 30 15:29:19 2015
     13// Update Count     : 1327
    1414//
    1515
     
    115115        StatementNode *sn;
    116116        ConstantNode *constant;
     117        LabelNode *label;
    117118        InitializerNode *in;
     119        bool flag;
    118120}
    119121
     
    134136%type<en> argument_expression_list              argument_expression                     for_control_expression          assignment_opt
    135137%type<en> subrange
     138%type<en> asm_operands_opt asm_operands_list asm_operand
     139%type<label> label_list
     140%type<constant> asm_clobbers_list_opt
     141%type<flag> asm_volatile_opt
    136142
    137143// statements
     
    378384        | assignment_expression
    379385        | no_attr_identifier ':' assignment_expression
    380                 { $$ = $3->set_asArgName( $1 ); }
     386                { $$ = $3->set_argName( $1 ); }
    381387                // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient
    382388                // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used
    383389                // with an appropriate semantic check.
    384390        | '[' push assignment_expression pop ']' ':' assignment_expression
    385                 { $$ = $7->set_asArgName( $3 ); }
     391                { $$ = $7->set_argName( $3 ); }
    386392        | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression
    387                 { $$ = $9->set_asArgName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
     393                { $$ = $9->set_argName( new CompositeExprNode( new OperatorNode( OperatorNode::TupleC ), (ExpressionNode *)$3->set_link( flattenCommas( $5 )))); }
    388394        ;
    389395
     
    754760
    755761fall_through:                                                                                   // CFA
    756         FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
    757         | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru, 0, 0 ); }
     762        FALLTHRU                                                                        { $$ = new StatementNode( StatementNode::Fallthru ); }
     763        | FALLTHRU ';'                                                          { $$ = new StatementNode( StatementNode::Fallthru ); }
    758764        ;
    759765
     
    783789        | CONTINUE ';'
    784790                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    785                 { $$ = new StatementNode( StatementNode::Continue, 0, 0 ); }
     791                { $$ = new StatementNode( StatementNode::Continue ); }
    786792        | CONTINUE no_attr_identifier ';'                                       // CFA, multi-level continue
    787793                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    790796        | BREAK ';'
    791797                // A semantic check is required to ensure this statement appears only in the body of an iteration statement.
    792                 { $$ = new StatementNode( StatementNode::Break, 0, 0 ); }
     798                { $$ = new StatementNode( StatementNode::Break ); }
    793799        | BREAK no_attr_identifier ';'                                          // CFA, multi-level exit
    794800                // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and
     
    800806                { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); }
    801807        | THROW ';'
    802                 { $$ = new StatementNode( StatementNode::Throw, 0, 0 ); }
     808                { $$ = new StatementNode( StatementNode::Throw ); }
    803809        ;
    804810
     
    863869
    864870asm_statement:
    865         ASM type_qualifier_list_opt '(' constant_expression ')' ';'
    866                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    867         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ')' ';' // remaining GCC
    868                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    869         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ')' ';'
    870                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
    871         | ASM type_qualifier_list_opt '(' constant_expression ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list ')' ';'
    872                 { $$ = new StatementNode( StatementNode::Asm, 0, 0 ); }
     871        ASM asm_volatile_opt '(' string_literal_list ')' ';'
     872                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0 ); }
     873        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC
     874                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6 ); }
     875        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';'
     876                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8 ); }
     877        | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';'
     878                { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10 ); }
     879        | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';'
     880        { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12 ); }
     881        ;
     882
     883asm_volatile_opt:                                                                               // GCC
     884        // empty
     885                { $$ = false; }
     886        | VOLATILE
     887                { $$ = true; }
    873888        ;
    874889
    875890asm_operands_opt:                                                                               // GCC
    876891        // empty
     892                { $$ = 0; }                                                                             // use default argument
    877893        | asm_operands_list
    878894        ;
     
    881897        asm_operand
    882898        | asm_operands_list ',' asm_operand
     899                { $$ = (ExpressionNode *)$1->set_link( $3 ); }
    883900        ;
    884901
    885902asm_operand:                                                                                    // GCC
    886         STRINGliteral '(' constant_expression ')'       {}
    887         ;
    888 
    889 asm_clobbers_list:                                                                              // GCC
    890         STRINGliteral                                                           {}
    891         | asm_clobbers_list ',' STRINGliteral
     903        string_literal_list '(' constant_expression ')'
     904                { $$ = new AsmExprNode( 0, $1, $3 ); }
     905        | '[' constant_expression ']' string_literal_list '(' constant_expression ')'
     906                { $$ = new AsmExprNode( $2, $4, $6 ); }
     907        ;
     908
     909asm_clobbers_list_opt:                                                                          // GCC
     910        // empty
     911                { $$ = 0; }                                                                             // use default argument
     912        | string_literal_list
     913                { $$ = $1; }
     914        | asm_clobbers_list_opt ',' string_literal_list
     915                { $$ = (ConstantNode *)$1->set_link( $3 ); }
     916        ;
     917
     918label_list:
     919        no_attr_identifier
     920                { $$ = new LabelNode(); $$->append_label( $1 ); }
     921        | label_list ',' no_attr_identifier
     922                { $$ = $1; $1->append_label( $3 ); }
    892923        ;
    893924
     
    929960
    930961label_list:                                                                                             // GCC, local label
    931         no_attr_identifier_or_type_name                 {}
     962        no_attr_identifier_or_type_name                         {}
    932963        | label_list ',' no_attr_identifier_or_type_name {}
    933964        ;
Note: See TracChangeset for help on using the changeset viewer.