2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-21 15:02:19 +00:00

Remove public function STACK access.

In preparation to clean up the Jam function global stack move the
definition of the STACK and related functions inside the function.cpp
source file only.
This commit is contained in:
Rene Rivera
2022-03-22 23:02:51 -04:00
parent 02c076e14a
commit 266c664fd9
6 changed files with 30 additions and 40 deletions

30
.vscode/launch.json vendored
View File

@@ -5,25 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "(lldb) Launch",
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/src/engine/b2",
"args": ["-sBOOST_BUILD_PATH=${workspaceFolder}", "toolset=clang"],
"stopAtEntry": true,
"cwd": "${workspaceFolder}/test",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
},
{
"name": "(gdb) Launch: example/hello",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/.build/clang-linux-10.0.0/debug/cxxstd-11-iso/b2",
"args": ["-n", "toolset=clang"],
"program": "${workspaceFolder}/.build/gcc-11/debug/cxxstd-11-iso/b2",
"args": ["-na"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/example/hello",
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
@@ -36,13 +24,13 @@
]
},
{
"name": "(gdb) Launch: home/tmp/prebuild",
"name": "(gdb) Launch: ASAN",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/.build/gcc-10.1.0/debug/cxxstd-11-iso/b2",
"args": ["-n","-sBOOST_BUILD_PATH=/home/grafik/Sync/DevRoots/B2/mainline/test/..","debug","release","-j1","-d2","toolset=gcc"],
"program": "${workspaceFolder}/.build/gcc-11/debug/address-sanitizer-on/cxxstd-11-iso/b2",
"args": ["-na", "toolset=gcc"],
"stopAtEntry": false,
"cwd": "/home/grafik/tmp/prebuilt-1",
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
@@ -53,6 +41,6 @@
"ignoreFailures": true
}
]
},
}
]
}

View File

@@ -5,6 +5,7 @@
*/
/* This file is ALSO:
* Copyright 2022 René Ferdinand Rivera Morell
* Copyright 2001-2004 David Abrahams.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
@@ -83,8 +84,7 @@ CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell )
lol_init( frame->args );
lol_add( frame->args, list_copy( targets ) );
lol_add( frame->args, list_copy( sources ) );
function_run_actions( rule->actions->command, frame, stack_global(),
cmd->buf );
function_run_actions( rule->actions->command, frame, cmd->buf );
frame_free( frame );
return cmd;

View File

@@ -146,7 +146,7 @@ LIST * evaluate_rule( RULE * rule, OBJECT * rulename, FRAME * frame )
if ( rule->procedure )
{
auto function = b2::jam::make_unique_bare_jptr( rule->procedure, function_refer, function_free );
result = function_run( function.get(), frame, stack_global() );
result = function_run( function.get(), frame );
}
if ( DEBUG_PROFILE && rule->procedure )

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2016-2022 Rene Rivera
* Copyright 2011 Steven Watanabe
* Copyright 2016 Rene Rivera
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE.txt or copy at
* https://www.bfgroup.xyz/b2/LICENSE.txt)
@@ -222,6 +222,13 @@ static LIST * call_python_function( PYTHON_FUNCTION *, FRAME * );
#endif
typedef struct _stack STACK;
typedef STACK* stack_ptr;
STACK * stack_global( void );
void stack_push( STACK * s, LIST * l );
LIST * stack_pop( STACK * s );
struct _stack
{
void * data;
@@ -4003,12 +4010,11 @@ static_assert(
static_assert( sizeof(LIST *) <= sizeof(void *), "sizeof(LIST *) <= sizeof(void *)" );
static_assert( sizeof(char *) <= sizeof(void *), "sizeof(char *) <= sizeof(void *)" );
void function_run_actions( FUNCTION * function, FRAME * frame, STACK * s,
string * out )
void function_run_actions( FUNCTION * function, FRAME * frame, string * out )
{
*(string * *)stack_allocate( s, sizeof( string * ) ) = out;
list_free( function_run( function, frame, s ) );
stack_deallocate( s, sizeof( string * ) );
*(string * *)stack_allocate( stack_global(), sizeof( string * ) ) = out;
list_free( function_run( function, frame ) );
stack_deallocate( stack_global(), sizeof( string * ) );
}
// Result is either the filename or contents depending on:
@@ -4162,8 +4168,9 @@ LIST * function_execute_write_file(
* especially careful about stack push/pop.
*/
LIST * function_run( FUNCTION * function_, FRAME * frame, STACK * s )
LIST * function_run( FUNCTION * function_, FRAME * frame )
{
STACK * s = stack_global();
JAM_FUNCTION * function;
instruction * code;
LIST * l;

View File

@@ -16,14 +16,8 @@
#include "jam_strings.h"
typedef struct _function FUNCTION;
typedef struct _stack STACK;
typedef FUNCTION* function_ptr;
typedef STACK* stack_ptr;
STACK * stack_global( void );
void stack_push( STACK * s, LIST * l );
LIST * stack_pop( STACK * s );
FUNCTION * function_compile( PARSE * parse );
FUNCTION * function_builtin( LIST * ( * func )( FRAME * frame, int32_t flags ), int32_t flags, const char * * args );
@@ -32,10 +26,10 @@ void function_free( FUNCTION * );
OBJECT * function_rulename( FUNCTION * );
void function_set_rulename( FUNCTION *, OBJECT * );
void function_location( FUNCTION *, OBJECT * *, int32_t * );
LIST * function_run( FUNCTION * function, FRAME * frame, STACK * s );
LIST * function_run( FUNCTION * function, FRAME * frame );
FUNCTION * function_compile_actions( const char * actions, OBJECT * file, int32_t line );
void function_run_actions( FUNCTION * function, FRAME * frame, STACK * s, string * out );
void function_run_actions( FUNCTION * function, FRAME * frame, string * out );
FUNCTION * function_bind_variables( FUNCTION * f, module_t * module, int32_t * counter );
FUNCTION * function_unbind_variables( FUNCTION * f );

View File

@@ -5,6 +5,7 @@
*/
/* This file is ALSO:
* Copyright 2022 René Ferdinand Rivera Morell
* Copyright 2001-2004 David Abrahams.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
@@ -52,7 +53,7 @@ static void parse_impl( FRAME * frame )
/* Run the parse tree. */
auto func = b2::jam::make_unique_bare_jptr( function_compile( p ), function_free );
parse_free( p );
list_free( function_run( func.get(), frame, stack_global() ) );
list_free( function_run( func.get(), frame ) );
}
yyfdone();