Merge pull request #467 from ikrima/fix-addrspace-section
fix: ast.lasttoken() does not handle addrspace section
This commit is contained in:
		
						commit
						4e6564d7da
					
				
							
								
								
									
										20
									
								
								src/ast.zig
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/ast.zig
									
									
									
									
									
								
							@ -744,7 +744,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        .fn_proto_one => {
 | 
					        .fn_proto_one => {
 | 
				
			||||||
            const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne);
 | 
					            const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne);
 | 
				
			||||||
            // linksection, callconv, align can appear in any order, so we
 | 
					            // addrspace, linksection, callconv, align can appear in any order, so we
 | 
				
			||||||
            // find the last one here.
 | 
					            // find the last one here.
 | 
				
			||||||
            // rhs can be zero if no return type is provided
 | 
					            // rhs can be zero if no return type is provided
 | 
				
			||||||
            var max_node: Node.Index = 0;
 | 
					            var max_node: Node.Index = 0;
 | 
				
			||||||
@ -763,6 +763,14 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
 | 
				
			|||||||
                    max_offset = 1; // for the rparen
 | 
					                    max_offset = 1; // for the rparen
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (extra.addrspace_expr != 0) {
 | 
				
			||||||
 | 
					                const start = token_starts[main_tokens[extra.addrspace_expr]];
 | 
				
			||||||
 | 
					                if (start > max_start) {
 | 
				
			||||||
 | 
					                    max_node = extra.addrspace_expr;
 | 
				
			||||||
 | 
					                    max_start = start;
 | 
				
			||||||
 | 
					                    max_offset = 1; // for the rparen
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (extra.section_expr != 0) {
 | 
					            if (extra.section_expr != 0) {
 | 
				
			||||||
                const start = token_starts[main_tokens[extra.section_expr]];
 | 
					                const start = token_starts[main_tokens[extra.section_expr]];
 | 
				
			||||||
                if (start > max_start) {
 | 
					                if (start > max_start) {
 | 
				
			||||||
@ -797,7 +805,7 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        .fn_proto => {
 | 
					        .fn_proto => {
 | 
				
			||||||
            const extra = tree.extraData(datas[n].lhs, Node.FnProto);
 | 
					            const extra = tree.extraData(datas[n].lhs, Node.FnProto);
 | 
				
			||||||
            // linksection, callconv, align can appear in any order, so we
 | 
					            // addrspace, linksection, callconv, align can appear in any order, so we
 | 
				
			||||||
            // find the last one here.
 | 
					            // find the last one here.
 | 
				
			||||||
            // rhs can be zero if no return type is provided
 | 
					            // rhs can be zero if no return type is provided
 | 
				
			||||||
            var max_node: Node.Index = 0;
 | 
					            var max_node: Node.Index = 0;
 | 
				
			||||||
@ -816,6 +824,14 @@ pub fn lastToken(tree: Ast, node: Ast.Node.Index) Ast.TokenIndex {
 | 
				
			|||||||
                    max_offset = 1; // for the rparen
 | 
					                    max_offset = 1; // for the rparen
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            if (extra.addrspace_expr != 0) {
 | 
				
			||||||
 | 
					                const start = token_starts[main_tokens[extra.addrspace_expr]];
 | 
				
			||||||
 | 
					                if (start > max_start) {
 | 
				
			||||||
 | 
					                    max_node = extra.addrspace_expr;
 | 
				
			||||||
 | 
					                    max_start = start;
 | 
				
			||||||
 | 
					                    max_offset = 1; // for the rparen
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            if (extra.section_expr != 0) {
 | 
					            if (extra.section_expr != 0) {
 | 
				
			||||||
                const start = token_starts[main_tokens[extra.section_expr]];
 | 
					                const start = token_starts[main_tokens[extra.section_expr]];
 | 
				
			||||||
                if (start > max_start) {
 | 
					                if (start > max_start) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user