From 90e4c21f3505febe13b50382e8b0307e53f1ef5b Mon Sep 17 00:00:00 2001 From: ychenfo Date: Fri, 22 Apr 2022 15:57:30 +0800 Subject: [PATCH] temp --- nac3core/src/codegen/expr.rs | 2 +- nac3core/src/codegen/mod.rs | 29 +++++++++++++++-------------- nac3core/src/codegen/stmt.rs | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 755849501..1ddb9c3bb 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -1029,7 +1029,7 @@ pub fn gen_expr<'ctx, 'a, G: CodeGenerator>( ctx.ctx, ctx.current_loc.row as u32, ctx.current_loc.column as u32, - ctx.debug_info.2.as_debug_info_scope(), + ctx.debug_info.2, None, ); ctx.builder.set_current_debug_location(ctx.ctx, loc); diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index bae71d458..0fa241735 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -19,7 +19,7 @@ use inkwell::{ types::{AnyType, BasicType, BasicTypeEnum}, values::{BasicValueEnum, FunctionValue, PhiValue, PointerValue}, debug_info::{ - DebugInfoBuilder, DICompileUnit, DISubprogram, AsDIScope, DIFlagsConstants, DILexicalBlock + DebugInfoBuilder, DICompileUnit, DISubprogram, AsDIScope, DIFlagsConstants, DILexicalBlock, DIScope }, }; use itertools::Itertools; @@ -55,7 +55,7 @@ pub type VarValue<'ctx> = (PointerValue<'ctx>, Option { pub ctx: &'ctx Context, pub builder: Builder<'ctx>, - pub debug_info: (DebugInfoBuilder<'ctx>, DICompileUnit<'ctx>, DILexicalBlock<'ctx>), + pub debug_info: (DebugInfoBuilder<'ctx>, DICompileUnit<'ctx>, DIScope<'ctx>), pub module: Module<'ctx>, pub top_level: &'a TopLevelContext, pub unifier: Unifier, @@ -608,28 +608,29 @@ pub fn gen_func_impl<'ctx, G: CodeGenerator, F: FnOnce(&mut G, &mut CodeGenConte &[], inkwell::debug_info::DIFlags::PUBLIC, ); + let (row, col) = + task.body.get(0).map_or_else(|| (0, 0), |b| (b.location.row, b.location.column)); let func_scope: DISubprogram<'_> = dibuilder.create_function( /* scope */ compile_unit.as_debug_info_scope(), /* func name */ symbol, /* linkage_name */ None, /* file */ compile_unit.get_file(), - /* line_no */ 0, + /* line_no */ row as u32, /* DIType */ subroutine_type, /* is_local_to_unit */ true, /* is_definition */ true, - /* scope_line */ 0, + /* scope_line */ row as u32, /* flags */ inkwell::debug_info::DIFlags::PUBLIC, /* is_optimized */ false, ); fn_val.set_subprogram(func_scope); - let (row, col) = - task.body.get(0).map_or_else(|| (0, 0), |b| (b.location.row, b.location.column)); - let lexical_block = dibuilder.create_lexical_block( - /* scope */ func_scope.as_debug_info_scope(), - /* file */ compile_unit.get_file(), - /* line_no */ row as u32, - /* column_no */ col as u32, - ); + + // let lexical_block = dibuilder.create_lexical_block( + // /* scope */ func_scope.as_debug_info_scope(), + // /* file */ compile_unit.get_file(), + // /* line_no */ row as u32, + // /* column_no */ col as u32, + // ); let mut code_gen_context = CodeGenContext { ctx: context, @@ -653,14 +654,14 @@ pub fn gen_func_impl<'ctx, G: CodeGenerator, F: FnOnce(&mut G, &mut CodeGenConte static_value_store, need_sret: has_sret, current_loc: Default::default(), - debug_info: (dibuilder, compile_unit, lexical_block), + debug_info: (dibuilder, compile_unit, func_scope.as_debug_info_scope()), }; let loc = code_gen_context.debug_info.0.create_debug_location( context, row as u32, col as u32, - lexical_block.as_debug_info_scope(), + func_scope.as_debug_info_scope(), None ); code_gen_context.builder.set_current_debug_location(context, loc); diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index aff6c42bc..ea996ec79 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -995,7 +995,7 @@ pub fn gen_stmt<'ctx, 'a, G: CodeGenerator>( ctx.ctx, ctx.current_loc.row as u32, ctx.current_loc.column as u32, - ctx.debug_info.2.as_debug_info_scope(), + ctx.debug_info.2, None, ); ctx.builder.set_current_debug_location(ctx.ctx, loc);