Extend devblock mode to dev mode
This commit is contained in:
parent
b3f47d640d
commit
7de550c18b
@ -59,7 +59,7 @@ RGX_DEFAULT (.|\n)
|
|||||||
<COMMENT_BLOCK_STATE>\n { loc.lines(yyleng); loc.step(); }
|
<COMMENT_BLOCK_STATE>\n { loc.lines(yyleng); loc.step(); }
|
||||||
<COMMENT_BLOCK_STATE>"*/" { BEGIN(INITIAL); }
|
<COMMENT_BLOCK_STATE>"*/" { BEGIN(INITIAL); }
|
||||||
|
|
||||||
"/#" { BEGIN(devblock_mode == xsk::gsc::dev_blocks::on ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
"/#" { BEGIN(comp_mode == xsk::gsc::compilation_mode::dev ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
||||||
/* ignore everything if we're in devblock-off state */
|
/* ignore everything if we're in devblock-off state */
|
||||||
<DEVBLOCK_OFF_STATE>.
|
<DEVBLOCK_OFF_STATE>.
|
||||||
<DEVBLOCK_OFF_STATE>\n { loc.lines(yyleng); loc.step(); }
|
<DEVBLOCK_OFF_STATE>\n { loc.lines(yyleng); loc.step(); }
|
||||||
|
@ -24,18 +24,18 @@
|
|||||||
|
|
||||||
%lex-param { yyscan_t yyscanner }
|
%lex-param { yyscan_t yyscanner }
|
||||||
%lex-param { xsk::gsc::location& loc }
|
%lex-param { xsk::gsc::location& loc }
|
||||||
%lex-param { xsk::gsc::dev_blocks devblock_mode }
|
%lex-param { xsk::gsc::compilation_mode comp_mode }
|
||||||
|
|
||||||
%parse-param { yyscan_t yyscanner }
|
%parse-param { yyscan_t yyscanner }
|
||||||
%parse-param { xsk::gsc::location& loc }
|
%parse-param { xsk::gsc::location& loc }
|
||||||
%parse-param { xsk::gsc::program_ptr& ast }
|
%parse-param { xsk::gsc::program_ptr& ast }
|
||||||
%parse-param { xsk::gsc::dev_blocks devblock_mode }
|
%parse-param { xsk::gsc::compilation_mode comp_mode }
|
||||||
|
|
||||||
%code requires
|
%code requires
|
||||||
{
|
{
|
||||||
#include "iw5.hpp"
|
#include "iw5.hpp"
|
||||||
typedef void *yyscan_t;
|
typedef void *yyscan_t;
|
||||||
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode)
|
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::compilation_mode comp_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
%code top
|
%code top
|
||||||
@ -44,7 +44,7 @@ typedef void *yyscan_t;
|
|||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
#include "lexer.hpp"
|
#include "lexer.hpp"
|
||||||
using namespace xsk::gsc;
|
using namespace xsk::gsc;
|
||||||
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode);
|
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::compilation_mode comp_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
%token BREAKPOINT "breakpoint"
|
%token BREAKPOINT "breakpoint"
|
||||||
|
@ -46,7 +46,7 @@ auto compiler::parse_buffer(const std::string& file, std::vector<std::uint8_t>&
|
|||||||
|
|
||||||
YY_BUFFER_STATE yybuffer = iw5__scan_buffer(reinterpret_cast<char*>(data.data()), data.size(), scanner);
|
YY_BUFFER_STATE yybuffer = iw5__scan_buffer(reinterpret_cast<char*>(data.data()), data.size(), scanner);
|
||||||
|
|
||||||
parser parser(scanner, loc, result, m_devblocks);
|
parser parser(scanner, loc, result, m_mode);
|
||||||
|
|
||||||
if(parser.parse() || result == nullptr)
|
if(parser.parse() || result == nullptr)
|
||||||
{
|
{
|
||||||
@ -240,7 +240,11 @@ void compiler::emit_stmt_call(const gsc::context_ptr& ctx, const gsc::stmt_call_
|
|||||||
{
|
{
|
||||||
const auto& name = stmt->expr->func.as_func->name->value;
|
const auto& name = stmt->expr->func.as_func->name->value;
|
||||||
|
|
||||||
if(name == "assert" || name == "assertex" || name == "assertmsg") return;
|
const bool is_dev_func = name == "assert" || name == "assertex" || name == "assertmsg";
|
||||||
|
if (is_dev_func && m_mode != compilation_mode::dev)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_expr_call(ctx, stmt->expr);
|
emit_expr_call(ctx, stmt->expr);
|
||||||
|
@ -30,7 +30,7 @@ class compiler : public gsc::compiler
|
|||||||
bool can_continue_;
|
bool can_continue_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
compiler(gsc::dev_blocks devblocks);
|
compiler(gsc::compilation_mode mode) : m_mode(mode) {}
|
||||||
|
|
||||||
auto output() -> std::vector<gsc::function_ptr>;
|
auto output() -> std::vector<gsc::function_ptr>;
|
||||||
void compile(const std::string& file, std::vector<std::uint8_t>& data);
|
void compile(const std::string& file, std::vector<std::uint8_t>& data);
|
||||||
@ -157,7 +157,7 @@ private:
|
|||||||
void print_instruction(const gsc::instruction_ptr& inst);
|
void print_instruction(const gsc::instruction_ptr& inst);
|
||||||
void print_label(const std::string& label);
|
void print_label(const std::string& label);
|
||||||
|
|
||||||
gsc::dev_blocks m_devblocks;
|
gsc::compilation_mode m_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace xsk::gsc::iw5
|
} // namespace xsk::gsc::iw5
|
||||||
|
@ -1287,7 +1287,7 @@ YY_RULE_SETUP
|
|||||||
case 8:
|
case 8:
|
||||||
YY_RULE_SETUP
|
YY_RULE_SETUP
|
||||||
#line 63 "lexer.lpp"
|
#line 63 "lexer.lpp"
|
||||||
{ BEGIN(devblock_mode == xsk::gsc::dev_blocks::on ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
{ BEGIN(comp_mode == xsk::gsc::compilation_mode::dev ? DEVBLOCK_ON_STATE : DEVBLOCK_OFF_STATE); }
|
||||||
YY_BREAK
|
YY_BREAK
|
||||||
/* ignore everything if we're in devblock-off state */
|
/* ignore everything if we're in devblock-off state */
|
||||||
case 9:
|
case 9:
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
#include "lexer.hpp"
|
#include "lexer.hpp"
|
||||||
using namespace xsk::gsc;
|
using namespace xsk::gsc;
|
||||||
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode);
|
xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::compilation_mode comp_mode);
|
||||||
|
|
||||||
#line 47 "parser.cpp"
|
#line 47 "parser.cpp"
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ namespace xsk { namespace gsc { namespace iw5 {
|
|||||||
#line 149 "parser.cpp"
|
#line 149 "parser.cpp"
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::location& loc_yyarg, xsk::gsc::program_ptr& ast_yyarg, xsk::gsc::dev_blocks devblock_mode_yyarg)
|
parser::parser (yyscan_t yyscanner_yyarg, xsk::gsc::location& loc_yyarg, xsk::gsc::program_ptr& ast_yyarg, xsk::gsc::compilation_mode comp_mode_yyarg)
|
||||||
#if IW5DEBUG
|
#if IW5DEBUG
|
||||||
: yydebug_ (false),
|
: yydebug_ (false),
|
||||||
yycdebug_ (&std::cerr),
|
yycdebug_ (&std::cerr),
|
||||||
@ -159,7 +159,7 @@ namespace xsk { namespace gsc { namespace iw5 {
|
|||||||
yyscanner (yyscanner_yyarg),
|
yyscanner (yyscanner_yyarg),
|
||||||
loc (loc_yyarg),
|
loc (loc_yyarg),
|
||||||
ast (ast_yyarg),
|
ast (ast_yyarg),
|
||||||
devblock_mode (devblock_mode_yyarg)
|
comp_mode (comp_mode_yyarg)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
parser::~parser ()
|
parser::~parser ()
|
||||||
@ -1466,7 +1466,7 @@ namespace xsk { namespace gsc { namespace iw5 {
|
|||||||
try
|
try
|
||||||
#endif // YY_EXCEPTIONS
|
#endif // YY_EXCEPTIONS
|
||||||
{
|
{
|
||||||
symbol_type yylookahead (yylex (yyscanner, loc, devblock_mode));
|
symbol_type yylookahead (yylex (yyscanner, loc, comp_mode));
|
||||||
yyla.move (yylookahead);
|
yyla.move (yylookahead);
|
||||||
}
|
}
|
||||||
#if YY_EXCEPTIONS
|
#if YY_EXCEPTIONS
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#include "iw5.hpp"
|
#include "iw5.hpp"
|
||||||
typedef void *yyscan_t;
|
typedef void *yyscan_t;
|
||||||
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::dev_blocks devblock_mode)
|
#define YY_DECL xsk::gsc::iw5::parser::symbol_type IW5lex(yyscan_t yyscanner, xsk::gsc::location& loc, xsk::gsc::compilation_mode comp_mode)
|
||||||
|
|
||||||
#line 55 "parser.hpp"
|
#line 55 "parser.hpp"
|
||||||
|
|
||||||
@ -2469,7 +2469,7 @@ switch (yykind)
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Build a parser object.
|
/// Build a parser object.
|
||||||
parser (yyscan_t yyscanner_yyarg, xsk::gsc::location& loc_yyarg, xsk::gsc::program_ptr& ast_yyarg, xsk::gsc::dev_blocks devblock_mode_yyarg);
|
parser (yyscan_t yyscanner_yyarg, xsk::gsc::location& loc_yyarg, xsk::gsc::program_ptr& ast_yyarg, xsk::gsc::compilation_mode comp_mode_yyarg);
|
||||||
virtual ~parser ();
|
virtual ~parser ();
|
||||||
|
|
||||||
#if 201103L <= YY_CPLUSPLUS
|
#if 201103L <= YY_CPLUSPLUS
|
||||||
@ -4413,7 +4413,7 @@ switch (yykind)
|
|||||||
yyscan_t yyscanner;
|
yyscan_t yyscanner;
|
||||||
xsk::gsc::location& loc;
|
xsk::gsc::location& loc;
|
||||||
xsk::gsc::program_ptr& ast;
|
xsk::gsc::program_ptr& ast;
|
||||||
xsk::gsc::dev_blocks devblock_mode;
|
xsk::gsc::compilation_mode comp_mode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ std::uint32_t main(std::uint32_t argc, char** argv)
|
|||||||
if (game == game::IW5)
|
if (game == game::IW5)
|
||||||
{
|
{
|
||||||
gsc::iw5::assembler assembler;
|
gsc::iw5::assembler assembler;
|
||||||
gsc::iw5::compiler compiler(gsc::dev_blocks::off);
|
gsc::iw5::compiler compiler(gsc::compilation_mode::release);
|
||||||
compile_file(assembler, compiler, file ,zonetool);
|
compile_file(assembler, compiler, file ,zonetool);
|
||||||
}
|
}
|
||||||
else if (game == game::IW6)
|
else if (game == game::IW6)
|
||||||
|
10
src/utils/xsk/gsc/compilation_mode.hpp
Normal file
10
src/utils/xsk/gsc/compilation_mode.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace xsk::gsc
|
||||||
|
{
|
||||||
|
enum class compilation_mode
|
||||||
|
{
|
||||||
|
dev,
|
||||||
|
release,
|
||||||
|
};
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace xsk::gsc
|
|
||||||
{
|
|
||||||
enum class dev_blocks
|
|
||||||
{
|
|
||||||
on,
|
|
||||||
off
|
|
||||||
};
|
|
||||||
}
|
|
@ -12,7 +12,7 @@
|
|||||||
#include "compression.hpp"
|
#include "compression.hpp"
|
||||||
|
|
||||||
// GSC Types
|
// GSC Types
|
||||||
#include "gsc/devblocks.hpp"
|
#include "gsc/compilation_mode.hpp"
|
||||||
#include "gsc/pair.hpp"
|
#include "gsc/pair.hpp"
|
||||||
#include "gsc/asset.hpp"
|
#include "gsc/asset.hpp"
|
||||||
#include "gsc/assembly.hpp"
|
#include "gsc/assembly.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user