@@ -12,6 +12,7 @@ import { type Layout, Memory } from "#evmgen/analysis";
1212import type { Error as EvmgenError } from "#evmgen/errors" ;
1313
1414import * as Block from "./block.js" ;
15+ import { preludeVariables } from "../debug/local-variables.js" ;
1516import { serialize } from "../serialize.js" ;
1617import { type Transition } from "../operations.js" ;
1718
@@ -67,8 +68,15 @@ function generatePrologue<S extends Stack>(
6768 } ) ,
6869 } ,
6970 } ;
71+ // Until the prologue has stored the arguments in the frame, the
72+ // parameters are listed without a pointer (the invoke's
73+ // `arguments` point at them on the stack)
74+ const variables = preludeVariables ( func ) ;
7075 const entryDebug = {
71- context : entryInvoke as Format . Program . Context ,
76+ context : {
77+ ...entryInvoke ,
78+ ...( variables . length > 0 ? { variables } : { } ) ,
79+ } as Format . Program . Context ,
7280 } ;
7381 currentState = {
7482 ...currentState ,
@@ -78,7 +86,7 @@ function generatePrologue<S extends Stack>(
7886 ] ,
7987 } ;
8088
81- const d = makePrologueDebug ( func ) ;
89+ const d = makePrologueDebug ( func , variables ) ;
8290 const frameSize = currentState . memory . frameSize ;
8391
8492 if ( frameSize !== undefined ) {
@@ -264,21 +272,23 @@ function emitFpRelativeStore<S extends Stack>(
264272 ) ;
265273}
266274
267- function makePrologueDebug ( func : Ir . Function ) : Debug {
268- return func . sourceId && func . loc
269- ? {
270- context : {
271- code : {
272- source : { id : func . sourceId } ,
273- range : func . loc ,
274- } ,
275- } as Format . Program . Context ,
276- }
277- : {
278- context : {
279- remark : "prologue: allocate call frame" ,
280- } as Format . Program . Context ,
281- } ;
275+ function makePrologueDebug (
276+ func : Ir . Function ,
277+ variables : Format . Program . Context . Variables [ "variables" ] ,
278+ ) : Debug {
279+ return {
280+ context : {
281+ ...( func . sourceId && func . loc
282+ ? {
283+ code : {
284+ source : { id : func . sourceId } ,
285+ range : func . loc ,
286+ } ,
287+ }
288+ : { remark : "prologue: allocate call frame" } ) ,
289+ ...( variables . length > 0 ? { variables } : { } ) ,
290+ } as Format . Program . Context ,
291+ } ;
282292}
283293
284294/**
0 commit comments