minor fixes

This commit is contained in:
xensik 2022-02-15 19:40:05 +01:00
parent 99e830fb93
commit b30644ff9a
84 changed files with 13774 additions and 12964 deletions

View File

@ -151,9 +151,11 @@ xsk::gsc::h1::parser::symbol_type H1lex(xsk::gsc::h1::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -305,8 +307,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -333,14 +334,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -350,6 +346,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -149,9 +149,11 @@ xsk::gsc::h2::parser::symbol_type H2lex(xsk::gsc::h2::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -303,8 +305,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -331,14 +332,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -348,6 +344,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -148,9 +148,11 @@ xsk::gsc::iw5::parser::symbol_type IW5lex(xsk::gsc::iw5::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -301,8 +303,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -328,14 +329,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -345,6 +341,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -148,9 +148,11 @@ xsk::gsc::iw6::parser::symbol_type IW6lex(xsk::gsc::iw6::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -301,8 +303,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -328,14 +329,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -345,6 +341,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -148,9 +148,11 @@ xsk::gsc::iw7::parser::symbol_type IW7lex(xsk::gsc::iw7::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -301,8 +303,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -328,14 +329,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -345,6 +341,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -151,9 +151,11 @@ xsk::gsc::iw8::parser::symbol_type IW8lex(xsk::gsc::iw8::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -307,8 +309,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -335,14 +336,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -352,6 +348,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -149,9 +149,11 @@ xsk::gsc::s1::parser::symbol_type S1lex(xsk::gsc::s1::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -303,8 +305,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -331,14 +332,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -348,6 +344,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -149,9 +149,11 @@ xsk::gsc::s2::parser::symbol_type S2lex(xsk::gsc::s2::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -303,8 +305,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -331,14 +332,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -348,6 +344,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -151,9 +151,11 @@ xsk::gsc::s4::parser::symbol_type S4lex(xsk::gsc::s4::lexer& lexer);
%type <ast::decl_constant::ptr> decl_constant
%type <ast::decl_thread::ptr> decl_thread
%type <ast::stmt> stmt
%type <ast::stmt_list::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt> stmt_or_dev
%type <ast::stmt_list::ptr> stmt_list
%type <ast::stmt_list::ptr> stmt_or_dev_list
%type <ast::stmt_dev::ptr> stmt_dev
%type <ast::stmt_list::ptr> stmt_block
%type <ast::stmt_expr::ptr> stmt_expr
%type <ast::stmt_call::ptr> stmt_call
%type <ast::stmt_assign::ptr> stmt_assign
@ -307,8 +309,7 @@ decl_thread
;
stmt
: stmt_dev { $$.as_list = std::move($1); }
| stmt_block { $$.as_list = std::move($1); }
: stmt_block { $$.as_list = std::move($1); }
| stmt_call { $$.as_call = std::move($1); }
| stmt_assign { $$.as_assign = std::move($1); }
| stmt_endon { $$.as_endon = std::move($1); }
@ -335,14 +336,9 @@ stmt
| stmt_prof_end { $$.as_prof_end = std::move($1); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::move($2); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_block
: LBRACE stmt_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
stmt_or_dev
: stmt { $$ = std::move($1); }
| stmt_dev { $$.as_dev = std::move($1); }
;
stmt_list
@ -352,6 +348,23 @@ stmt_list
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_or_dev_list
: stmt_or_dev_list stmt_or_dev
{ $$ = std::move($1); $$->list.push_back(std::move($2)); }
| stmt_or_dev
{ $$ = std::make_unique<ast::stmt_list>(@$); $$->list.push_back(std::move($1)); }
;
stmt_dev
: DEVBEGIN stmt_list DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::move($2)); }
| DEVBEGIN DEVEND { $$ = std::make_unique<ast::stmt_dev>(@$, std::make_unique<ast::stmt_list>(@$)); }
;
stmt_block
: LBRACE stmt_or_dev_list RBRACE { $$ = std::move($2); }
| LBRACE RBRACE { $$ = std::make_unique<ast::stmt_list>(@$); }
;
stmt_expr
: expr_assign
{ $$ = std::make_unique<ast::stmt_expr>(@$, std::move($1)); }

View File

@ -91,7 +91,7 @@ void compiler::emit_include(const ast::include::ptr& include)
for (const auto& inc : includes_)
{
if(inc.name == path)
if (inc.name == path)
{
throw comp_error(include->loc(), "error duplicated include file '" + path + "'.");
}
@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -284,6 +287,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -580,6 +588,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -588,7 +598,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -830,7 +839,7 @@ void compiler::emit_stmt_switch(const ast::stmt_switch::ptr& stmt, const block::
if (has_default)
{
if(default_ctx->abort == abort_t::abort_none)
if (default_ctx->abort == abort_t::abort_none)
{
break_blks_.push_back(default_ctx);
}
@ -1009,9 +1018,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1324,7 +1330,7 @@ void compiler::emit_expr_call_function(const ast::expr_function::ptr& expr, cons
switch (expr->mode)
{
case ast::call::mode::normal:
if(expr->args->list.size() > 0)
if (expr->args->list.size() > 0)
emit_opcode(opcode::OP_ScriptLocalFunctionCall, expr->name->value);
else
emit_opcode(opcode::OP_ScriptLocalFunctionCall2, expr->name->value);
@ -1345,7 +1351,7 @@ void compiler::emit_expr_call_function(const ast::expr_function::ptr& expr, cons
switch (expr->mode)
{
case ast::call::mode::normal:
if(expr->args->list.size() > 0)
if (expr->args->list.size() > 0)
emit_opcode(opcode::OP_ScriptFarFunctionCall, { expr->path->value, expr->name->value });
else
emit_opcode(opcode::OP_ScriptFarFunctionCall2, { expr->path->value, expr->name->value });
@ -1557,7 +1563,7 @@ void compiler::emit_expr_reference(const ast::expr_reference::ptr& expr, const b
emit_opcode(opcode::OP_GetFarFunction, { expr->path->value, expr->name->value });
break;
case ast::call::type::builtin:
if(method)
if (method)
emit_opcode(opcode::OP_GetBuiltinMethod, expr->name->value);
else
emit_opcode(opcode::OP_GetBuiltinFunction, expr->name->value);
@ -1961,30 +1967,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2110,6 +2092,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2175,6 +2160,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -2870,7 +2860,7 @@ void compiler::insert_label(const std::string& name)
case opcode::OP_jump:
case opcode::OP_jumpback:
case opcode::OP_switch:
if(inst->data[0] == name)
if (inst->data[0] == name)
inst->data[0] = itr->second;
break;
case opcode::OP_endswitch:

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -110,7 +111,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -123,6 +123,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1856,7 +1856,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2135,7 +2135,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2144,29 +2144,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2406,7 +2406,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2507,7 +2507,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2773,7 +2773,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -73,12 +73,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -90,7 +90,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -112,7 +112,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -562,7 +562,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -537,6 +537,7 @@ namespace xsk { namespace gsc { namespace h1 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -560,64 +561,67 @@ namespace xsk { namespace gsc { namespace h1 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waitframe
char dummy62[sizeof (ast::stmt_waitframe::ptr)];
char dummy63[sizeof (ast::stmt_waitframe::ptr)];
// stmt_waittill
char dummy63[sizeof (ast::stmt_waittill::ptr)];
char dummy64[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy65[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy66[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy66[sizeof (ast::stmt_while::ptr)];
char dummy67[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -627,7 +631,7 @@ namespace xsk { namespace gsc { namespace h1 {
// "color"
// "float"
// "integer"
char dummy67[sizeof (std::string)];
char dummy68[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -932,77 +936,79 @@ namespace xsk { namespace gsc { namespace h1 {
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
S_stmt_or_dev = 124, // stmt_or_dev
S_stmt_list = 125, // stmt_list
S_stmt_or_dev_list = 126, // stmt_or_dev_list
S_stmt_dev = 127, // stmt_dev
S_stmt_block = 128, // stmt_block
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_reference = 172, // expr_reference
S_expr_array = 173, // expr_array
S_expr_field = 174, // expr_field
S_expr_size = 175, // expr_size
S_expr_paren = 176, // expr_paren
S_expr_object = 177, // expr_object
S_expr_thisthread = 178, // expr_thisthread
S_expr_empty_array = 179, // expr_empty_array
S_expr_undefined = 180, // expr_undefined
S_expr_game = 181, // expr_game
S_expr_self = 182, // expr_self
S_expr_anim = 183, // expr_anim
S_expr_level = 184, // expr_level
S_expr_animation = 185, // expr_animation
S_expr_animtree = 186, // expr_animtree
S_expr_identifier = 187, // expr_identifier
S_expr_path = 188, // expr_path
S_expr_istring = 189, // expr_istring
S_expr_string = 190, // expr_string
S_expr_color = 191, // expr_color
S_expr_vector = 192, // expr_vector
S_expr_float = 193, // expr_float
S_expr_integer = 194, // expr_integer
S_expr_false = 195, // expr_false
S_expr_true = 196 // expr_true
};
};
@ -1206,6 +1212,7 @@ namespace xsk { namespace gsc { namespace h1 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1237,6 +1244,10 @@ namespace xsk { namespace gsc { namespace h1 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1265,9 +1276,9 @@ namespace xsk { namespace gsc { namespace h1 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -2007,6 +2018,20 @@ namespace xsk { namespace gsc { namespace h1 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2476,6 +2501,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2507,6 +2533,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2535,9 +2565,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4806,8 +4836,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2291, ///< Last index in yytable_.
yynnts_ = 81, ///< Number of nonterminal symbols.
yylast_ = 2285, ///< Last index in yytable_.
yynnts_ = 83, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -5001,6 +5031,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -5032,6 +5063,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5060,9 +5095,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5317,6 +5352,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5348,6 +5384,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5376,9 +5416,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5500,7 +5540,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h1
#line 5504 "parser.hpp"
#line 5544 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -3966,7 +3966,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -3980,31 +3980,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -284,6 +287,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -580,6 +588,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -588,7 +598,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1009,9 +1018,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1961,30 +1967,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2109,6 +2091,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2174,6 +2159,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -110,7 +111,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -123,6 +123,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1856,7 +1856,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2135,7 +2135,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2144,29 +2144,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2406,7 +2406,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2507,7 +2507,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2773,7 +2773,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -73,12 +73,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -90,7 +90,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -112,7 +112,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -562,7 +562,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,7 @@ namespace xsk { namespace gsc { namespace h2 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -558,64 +559,67 @@ namespace xsk { namespace gsc { namespace h2 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waitframe
char dummy62[sizeof (ast::stmt_waitframe::ptr)];
char dummy63[sizeof (ast::stmt_waitframe::ptr)];
// stmt_waittill
char dummy63[sizeof (ast::stmt_waittill::ptr)];
char dummy64[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy65[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy66[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy66[sizeof (ast::stmt_while::ptr)];
char dummy67[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -625,7 +629,7 @@ namespace xsk { namespace gsc { namespace h2 {
// "color"
// "float"
// "integer"
char dummy67[sizeof (std::string)];
char dummy68[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -930,77 +934,79 @@ namespace xsk { namespace gsc { namespace h2 {
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
S_stmt_or_dev = 124, // stmt_or_dev
S_stmt_list = 125, // stmt_list
S_stmt_or_dev_list = 126, // stmt_or_dev_list
S_stmt_dev = 127, // stmt_dev
S_stmt_block = 128, // stmt_block
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_reference = 172, // expr_reference
S_expr_array = 173, // expr_array
S_expr_field = 174, // expr_field
S_expr_size = 175, // expr_size
S_expr_paren = 176, // expr_paren
S_expr_object = 177, // expr_object
S_expr_thisthread = 178, // expr_thisthread
S_expr_empty_array = 179, // expr_empty_array
S_expr_undefined = 180, // expr_undefined
S_expr_game = 181, // expr_game
S_expr_self = 182, // expr_self
S_expr_anim = 183, // expr_anim
S_expr_level = 184, // expr_level
S_expr_animation = 185, // expr_animation
S_expr_animtree = 186, // expr_animtree
S_expr_identifier = 187, // expr_identifier
S_expr_path = 188, // expr_path
S_expr_istring = 189, // expr_istring
S_expr_string = 190, // expr_string
S_expr_color = 191, // expr_color
S_expr_vector = 192, // expr_vector
S_expr_float = 193, // expr_float
S_expr_integer = 194, // expr_integer
S_expr_false = 195, // expr_false
S_expr_true = 196 // expr_true
};
};
@ -1204,6 +1210,7 @@ namespace xsk { namespace gsc { namespace h2 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1235,6 +1242,10 @@ namespace xsk { namespace gsc { namespace h2 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1263,9 +1274,9 @@ namespace xsk { namespace gsc { namespace h2 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -2005,6 +2016,20 @@ namespace xsk { namespace gsc { namespace h2 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2474,6 +2499,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2505,6 +2531,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2533,9 +2563,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4804,8 +4834,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2291, ///< Last index in yytable_.
yynnts_ = 81, ///< Number of nonterminal symbols.
yylast_ = 2285, ///< Last index in yytable_.
yynnts_ = 83, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -4999,6 +5029,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -5030,6 +5061,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5058,9 +5093,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5315,6 +5350,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5346,6 +5382,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5374,9 +5414,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5498,7 +5538,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::h2
#line 5502 "parser.hpp"
#line 5542 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -2711,7 +2711,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -2725,31 +2725,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -281,6 +284,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -572,6 +580,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -580,7 +590,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1001,9 +1010,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1953,30 +1959,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2101,6 +2083,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2165,6 +2150,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -109,7 +110,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -122,6 +122,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1651,7 +1651,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1850,7 +1850,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2129,7 +2129,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2138,29 +2138,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2400,7 +2400,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2501,7 +2501,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2767,7 +2767,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -72,12 +72,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -89,7 +89,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -111,7 +111,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -561,7 +561,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,7 @@ namespace xsk { namespace gsc { namespace iw5 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -558,61 +559,64 @@ namespace xsk { namespace gsc { namespace iw5 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waittill
char dummy62[sizeof (ast::stmt_waittill::ptr)];
char dummy63[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy63[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy64[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy65[sizeof (ast::stmt_while::ptr)];
char dummy66[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -622,7 +626,7 @@ namespace xsk { namespace gsc { namespace iw5 {
// "color"
// "float"
// "integer"
char dummy66[sizeof (std::string)];
char dummy67[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -925,76 +929,78 @@ namespace xsk { namespace gsc { namespace iw5 {
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
S_stmt_or_dev = 123, // stmt_or_dev
S_stmt_list = 124, // stmt_list
S_stmt_or_dev_list = 125, // stmt_or_dev_list
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_expr = 128, // stmt_expr
S_stmt_call = 129, // stmt_call
S_stmt_assign = 130, // stmt_assign
S_stmt_endon = 131, // stmt_endon
S_stmt_notify = 132, // stmt_notify
S_stmt_wait = 133, // stmt_wait
S_stmt_waittill = 134, // stmt_waittill
S_stmt_waittillmatch = 135, // stmt_waittillmatch
S_stmt_waittillframeend = 136, // stmt_waittillframeend
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -1198,6 +1204,7 @@ namespace xsk { namespace gsc { namespace iw5 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1229,6 +1236,10 @@ namespace xsk { namespace gsc { namespace iw5 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1257,9 +1268,9 @@ namespace xsk { namespace gsc { namespace iw5 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -1995,6 +2006,20 @@ namespace xsk { namespace gsc { namespace iw5 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2450,6 +2475,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2481,6 +2507,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2509,9 +2539,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4761,8 +4791,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2249, ///< Last index in yytable_.
yynnts_ = 80, ///< Number of nonterminal symbols.
yylast_ = 2262, ///< Last index in yytable_.
yynnts_ = 82, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -4956,6 +4986,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -4987,6 +5018,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5015,9 +5050,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5268,6 +5303,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5299,6 +5335,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5327,9 +5367,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5447,7 +5487,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw5
#line 5451 "parser.hpp"
#line 5491 "parser.hpp"

View File

@ -48,7 +48,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -77,7 +77,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -106,7 +106,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -135,7 +135,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -164,7 +164,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -178,7 +178,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -210,7 +210,7 @@ void resolver::add_function(const std::string& name, std::uint16_t id)
{
auto ins = string_map.insert(name);
if(ins.second)
if (ins.second)
{
function_map.insert({ id, *ins.first });
function_map_rev.insert({ *ins.first, id });
@ -238,7 +238,7 @@ void resolver::add_method(const std::string& name, std::uint16_t id)
{
auto ins = string_map.insert(name);
if(ins.second)
if (ins.second)
{
method_map.insert({ id, *ins.first });
method_map_rev.insert({ *ins.first, id });
@ -248,7 +248,7 @@ void resolver::add_method(const std::string& name, std::uint16_t id)
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -271,7 +271,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -280,7 +280,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -7933,7 +7933,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -7947,31 +7947,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ utils::string::to_lower(entry.second), entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -281,6 +284,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -572,6 +580,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -580,7 +590,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1001,9 +1010,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1953,30 +1959,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2101,6 +2083,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2165,6 +2150,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -109,7 +110,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -122,6 +122,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1651,7 +1651,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1850,7 +1850,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2129,7 +2129,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2138,29 +2138,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2400,7 +2400,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2501,7 +2501,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2767,7 +2767,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -72,12 +72,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -89,7 +89,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -111,7 +111,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -561,7 +561,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,7 @@ namespace xsk { namespace gsc { namespace iw6 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -558,61 +559,64 @@ namespace xsk { namespace gsc { namespace iw6 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waittill
char dummy62[sizeof (ast::stmt_waittill::ptr)];
char dummy63[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy63[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy64[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy65[sizeof (ast::stmt_while::ptr)];
char dummy66[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -622,7 +626,7 @@ namespace xsk { namespace gsc { namespace iw6 {
// "color"
// "float"
// "integer"
char dummy66[sizeof (std::string)];
char dummy67[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -925,76 +929,78 @@ namespace xsk { namespace gsc { namespace iw6 {
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
S_stmt_or_dev = 123, // stmt_or_dev
S_stmt_list = 124, // stmt_list
S_stmt_or_dev_list = 125, // stmt_or_dev_list
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_expr = 128, // stmt_expr
S_stmt_call = 129, // stmt_call
S_stmt_assign = 130, // stmt_assign
S_stmt_endon = 131, // stmt_endon
S_stmt_notify = 132, // stmt_notify
S_stmt_wait = 133, // stmt_wait
S_stmt_waittill = 134, // stmt_waittill
S_stmt_waittillmatch = 135, // stmt_waittillmatch
S_stmt_waittillframeend = 136, // stmt_waittillframeend
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -1198,6 +1204,7 @@ namespace xsk { namespace gsc { namespace iw6 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1229,6 +1236,10 @@ namespace xsk { namespace gsc { namespace iw6 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1257,9 +1268,9 @@ namespace xsk { namespace gsc { namespace iw6 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -1995,6 +2006,20 @@ namespace xsk { namespace gsc { namespace iw6 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2450,6 +2475,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2481,6 +2507,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2509,9 +2539,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4761,8 +4791,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2249, ///< Last index in yytable_.
yynnts_ = 80, ///< Number of nonterminal symbols.
yylast_ = 2262, ///< Last index in yytable_.
yynnts_ = 82, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -4956,6 +4986,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -4987,6 +5018,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5015,9 +5050,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5268,6 +5303,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5299,6 +5335,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5327,9 +5367,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5447,7 +5487,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw6
#line 5451 "parser.hpp"
#line 5491 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -16742,7 +16742,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -16756,31 +16756,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -281,6 +284,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -572,6 +580,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -580,7 +590,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1001,9 +1010,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1953,30 +1959,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2101,6 +2083,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2165,6 +2150,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -109,7 +110,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -122,6 +122,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1651,7 +1651,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1850,7 +1850,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2129,7 +2129,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2138,29 +2138,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2400,7 +2400,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2501,7 +2501,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2767,7 +2767,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -72,12 +72,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -89,7 +89,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -111,7 +111,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -561,7 +561,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,7 @@ namespace xsk { namespace gsc { namespace iw7 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -558,61 +559,64 @@ namespace xsk { namespace gsc { namespace iw7 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waittill
char dummy62[sizeof (ast::stmt_waittill::ptr)];
char dummy63[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy63[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy64[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy65[sizeof (ast::stmt_while::ptr)];
char dummy66[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -622,7 +626,7 @@ namespace xsk { namespace gsc { namespace iw7 {
// "color"
// "float"
// "integer"
char dummy66[sizeof (std::string)];
char dummy67[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -925,76 +929,78 @@ namespace xsk { namespace gsc { namespace iw7 {
S_decl_constant = 120, // decl_constant
S_decl_thread = 121, // decl_thread
S_stmt = 122, // stmt
S_stmt_dev = 123, // stmt_dev
S_stmt_block = 124, // stmt_block
S_stmt_list = 125, // stmt_list
S_stmt_expr = 126, // stmt_expr
S_stmt_call = 127, // stmt_call
S_stmt_assign = 128, // stmt_assign
S_stmt_endon = 129, // stmt_endon
S_stmt_notify = 130, // stmt_notify
S_stmt_wait = 131, // stmt_wait
S_stmt_waittill = 132, // stmt_waittill
S_stmt_waittillmatch = 133, // stmt_waittillmatch
S_stmt_waittillframeend = 134, // stmt_waittillframeend
S_stmt_if = 135, // stmt_if
S_stmt_ifelse = 136, // stmt_ifelse
S_stmt_while = 137, // stmt_while
S_stmt_dowhile = 138, // stmt_dowhile
S_stmt_for = 139, // stmt_for
S_stmt_foreach = 140, // stmt_foreach
S_stmt_switch = 141, // stmt_switch
S_stmt_case = 142, // stmt_case
S_stmt_default = 143, // stmt_default
S_stmt_break = 144, // stmt_break
S_stmt_continue = 145, // stmt_continue
S_stmt_return = 146, // stmt_return
S_stmt_breakpoint = 147, // stmt_breakpoint
S_stmt_prof_begin = 148, // stmt_prof_begin
S_stmt_prof_end = 149, // stmt_prof_end
S_expr = 150, // expr
S_expr_or_empty = 151, // expr_or_empty
S_expr_assign = 152, // expr_assign
S_expr_increment = 153, // expr_increment
S_expr_decrement = 154, // expr_decrement
S_expr_ternary = 155, // expr_ternary
S_expr_binary = 156, // expr_binary
S_expr_primitive = 157, // expr_primitive
S_expr_complement = 158, // expr_complement
S_expr_not = 159, // expr_not
S_expr_call = 160, // expr_call
S_expr_method = 161, // expr_method
S_expr_function = 162, // expr_function
S_expr_pointer = 163, // expr_pointer
S_expr_add_array = 164, // expr_add_array
S_expr_parameters = 165, // expr_parameters
S_expr_arguments = 166, // expr_arguments
S_expr_arguments_no_empty = 167, // expr_arguments_no_empty
S_expr_reference = 168, // expr_reference
S_expr_array = 169, // expr_array
S_expr_field = 170, // expr_field
S_expr_size = 171, // expr_size
S_expr_paren = 172, // expr_paren
S_expr_object = 173, // expr_object
S_expr_thisthread = 174, // expr_thisthread
S_expr_empty_array = 175, // expr_empty_array
S_expr_undefined = 176, // expr_undefined
S_expr_game = 177, // expr_game
S_expr_self = 178, // expr_self
S_expr_anim = 179, // expr_anim
S_expr_level = 180, // expr_level
S_expr_animation = 181, // expr_animation
S_expr_animtree = 182, // expr_animtree
S_expr_identifier = 183, // expr_identifier
S_expr_path = 184, // expr_path
S_expr_istring = 185, // expr_istring
S_expr_string = 186, // expr_string
S_expr_color = 187, // expr_color
S_expr_vector = 188, // expr_vector
S_expr_float = 189, // expr_float
S_expr_integer = 190, // expr_integer
S_expr_false = 191, // expr_false
S_expr_true = 192 // expr_true
S_stmt_or_dev = 123, // stmt_or_dev
S_stmt_list = 124, // stmt_list
S_stmt_or_dev_list = 125, // stmt_or_dev_list
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_expr = 128, // stmt_expr
S_stmt_call = 129, // stmt_call
S_stmt_assign = 130, // stmt_assign
S_stmt_endon = 131, // stmt_endon
S_stmt_notify = 132, // stmt_notify
S_stmt_wait = 133, // stmt_wait
S_stmt_waittill = 134, // stmt_waittill
S_stmt_waittillmatch = 135, // stmt_waittillmatch
S_stmt_waittillframeend = 136, // stmt_waittillframeend
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
};
};
@ -1198,6 +1204,7 @@ namespace xsk { namespace gsc { namespace iw7 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1229,6 +1236,10 @@ namespace xsk { namespace gsc { namespace iw7 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1257,9 +1268,9 @@ namespace xsk { namespace gsc { namespace iw7 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -1995,6 +2006,20 @@ namespace xsk { namespace gsc { namespace iw7 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2450,6 +2475,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2481,6 +2507,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2509,9 +2539,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4761,8 +4791,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2249, ///< Last index in yytable_.
yynnts_ = 80, ///< Number of nonterminal symbols.
yylast_ = 2262, ///< Last index in yytable_.
yynnts_ = 82, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -4956,6 +4986,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -4987,6 +5018,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5015,9 +5050,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5268,6 +5303,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5299,6 +5335,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5327,9 +5367,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5447,7 +5487,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw7
#line 5451 "parser.hpp"
#line 5491 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint32_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint32_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -2726,7 +2726,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -2740,31 +2740,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -154,7 +154,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -197,6 +197,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -286,6 +289,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -582,6 +590,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -590,7 +600,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -714,7 +723,7 @@ void compiler::emit_stmt_foreach(const ast::stmt_foreach::ptr& stmt, const block
auto begin_loc = insert_label();
emit_expr_variable(stmt->key_expr, blk);
emit_opcode(opcode::OP_CallBuiltin1, "isdefined");
emit_opcode(opcode::OP_IsDefined);
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
can_break_ = true;
@ -1017,9 +1026,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -2014,30 +2020,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2162,6 +2144,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2227,6 +2212,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -112,7 +113,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -125,6 +125,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1887,7 +1887,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2166,7 +2166,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2175,29 +2175,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2437,7 +2437,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2538,7 +2538,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2804,7 +2804,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -75,12 +75,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -92,7 +92,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -114,7 +114,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -564,7 +564,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -541,6 +541,7 @@ namespace xsk { namespace gsc { namespace iw8 {
char dummy41[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy42[sizeof (ast::stmt)];
// stmt_assign
@ -564,64 +565,67 @@ namespace xsk { namespace gsc { namespace iw8 {
// stmt_default
char dummy49[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy50[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy50[sizeof (ast::stmt_dowhile::ptr)];
char dummy51[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy51[sizeof (ast::stmt_endon::ptr)];
char dummy52[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy52[sizeof (ast::stmt_expr::ptr)];
char dummy53[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy53[sizeof (ast::stmt_for::ptr)];
char dummy54[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy54[sizeof (ast::stmt_foreach::ptr)];
char dummy55[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy55[sizeof (ast::stmt_if::ptr)];
char dummy56[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy56[sizeof (ast::stmt_ifelse::ptr)];
char dummy57[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy57[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy58[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy58[sizeof (ast::stmt_notify::ptr)];
char dummy59[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy59[sizeof (ast::stmt_prof_begin::ptr)];
char dummy60[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy60[sizeof (ast::stmt_prof_end::ptr)];
char dummy61[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy61[sizeof (ast::stmt_return::ptr)];
char dummy62[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy62[sizeof (ast::stmt_switch::ptr)];
char dummy63[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy63[sizeof (ast::stmt_wait::ptr)];
char dummy64[sizeof (ast::stmt_wait::ptr)];
// stmt_waitframe
char dummy64[sizeof (ast::stmt_waitframe::ptr)];
char dummy65[sizeof (ast::stmt_waitframe::ptr)];
// stmt_waittill
char dummy65[sizeof (ast::stmt_waittill::ptr)];
char dummy66[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy66[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy67[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy67[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy68[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy68[sizeof (ast::stmt_while::ptr)];
char dummy69[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -631,7 +635,7 @@ namespace xsk { namespace gsc { namespace iw8 {
// "color"
// "float"
// "integer"
char dummy69[sizeof (std::string)];
char dummy70[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -940,79 +944,81 @@ namespace xsk { namespace gsc { namespace iw8 {
S_decl_constant = 123, // decl_constant
S_decl_thread = 124, // decl_thread
S_stmt = 125, // stmt
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_list = 128, // stmt_list
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_isdefined = 172, // expr_isdefined
S_expr_istrue = 173, // expr_istrue
S_expr_reference = 174, // expr_reference
S_expr_array = 175, // expr_array
S_expr_field = 176, // expr_field
S_expr_size = 177, // expr_size
S_expr_paren = 178, // expr_paren
S_expr_object = 179, // expr_object
S_expr_thisthread = 180, // expr_thisthread
S_expr_empty_array = 181, // expr_empty_array
S_expr_undefined = 182, // expr_undefined
S_expr_game = 183, // expr_game
S_expr_self = 184, // expr_self
S_expr_anim = 185, // expr_anim
S_expr_level = 186, // expr_level
S_expr_animation = 187, // expr_animation
S_expr_animtree = 188, // expr_animtree
S_expr_identifier = 189, // expr_identifier
S_expr_path = 190, // expr_path
S_expr_istring = 191, // expr_istring
S_expr_string = 192, // expr_string
S_expr_color = 193, // expr_color
S_expr_vector = 194, // expr_vector
S_expr_float = 195, // expr_float
S_expr_integer = 196, // expr_integer
S_expr_false = 197, // expr_false
S_expr_true = 198 // expr_true
S_stmt_or_dev = 126, // stmt_or_dev
S_stmt_list = 127, // stmt_list
S_stmt_or_dev_list = 128, // stmt_or_dev_list
S_stmt_dev = 129, // stmt_dev
S_stmt_block = 130, // stmt_block
S_stmt_expr = 131, // stmt_expr
S_stmt_call = 132, // stmt_call
S_stmt_assign = 133, // stmt_assign
S_stmt_endon = 134, // stmt_endon
S_stmt_notify = 135, // stmt_notify
S_stmt_wait = 136, // stmt_wait
S_stmt_waittill = 137, // stmt_waittill
S_stmt_waittillmatch = 138, // stmt_waittillmatch
S_stmt_waittillframeend = 139, // stmt_waittillframeend
S_stmt_waitframe = 140, // stmt_waitframe
S_stmt_if = 141, // stmt_if
S_stmt_ifelse = 142, // stmt_ifelse
S_stmt_while = 143, // stmt_while
S_stmt_dowhile = 144, // stmt_dowhile
S_stmt_for = 145, // stmt_for
S_stmt_foreach = 146, // stmt_foreach
S_stmt_switch = 147, // stmt_switch
S_stmt_case = 148, // stmt_case
S_stmt_default = 149, // stmt_default
S_stmt_break = 150, // stmt_break
S_stmt_continue = 151, // stmt_continue
S_stmt_return = 152, // stmt_return
S_stmt_breakpoint = 153, // stmt_breakpoint
S_stmt_prof_begin = 154, // stmt_prof_begin
S_stmt_prof_end = 155, // stmt_prof_end
S_expr = 156, // expr
S_expr_or_empty = 157, // expr_or_empty
S_expr_assign = 158, // expr_assign
S_expr_increment = 159, // expr_increment
S_expr_decrement = 160, // expr_decrement
S_expr_ternary = 161, // expr_ternary
S_expr_binary = 162, // expr_binary
S_expr_primitive = 163, // expr_primitive
S_expr_complement = 164, // expr_complement
S_expr_not = 165, // expr_not
S_expr_call = 166, // expr_call
S_expr_method = 167, // expr_method
S_expr_function = 168, // expr_function
S_expr_pointer = 169, // expr_pointer
S_expr_add_array = 170, // expr_add_array
S_expr_parameters = 171, // expr_parameters
S_expr_arguments = 172, // expr_arguments
S_expr_arguments_no_empty = 173, // expr_arguments_no_empty
S_expr_isdefined = 174, // expr_isdefined
S_expr_istrue = 175, // expr_istrue
S_expr_reference = 176, // expr_reference
S_expr_array = 177, // expr_array
S_expr_field = 178, // expr_field
S_expr_size = 179, // expr_size
S_expr_paren = 180, // expr_paren
S_expr_object = 181, // expr_object
S_expr_thisthread = 182, // expr_thisthread
S_expr_empty_array = 183, // expr_empty_array
S_expr_undefined = 184, // expr_undefined
S_expr_game = 185, // expr_game
S_expr_self = 186, // expr_self
S_expr_anim = 187, // expr_anim
S_expr_level = 188, // expr_level
S_expr_animation = 189, // expr_animation
S_expr_animtree = 190, // expr_animtree
S_expr_identifier = 191, // expr_identifier
S_expr_path = 192, // expr_path
S_expr_istring = 193, // expr_istring
S_expr_string = 194, // expr_string
S_expr_color = 195, // expr_color
S_expr_vector = 196, // expr_vector
S_expr_float = 197, // expr_float
S_expr_integer = 198, // expr_integer
S_expr_false = 199, // expr_false
S_expr_true = 200 // expr_true
};
};
@ -1224,6 +1230,7 @@ namespace xsk { namespace gsc { namespace iw8 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1255,6 +1262,10 @@ namespace xsk { namespace gsc { namespace iw8 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1283,9 +1294,9 @@ namespace xsk { namespace gsc { namespace iw8 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -2053,6 +2064,20 @@ namespace xsk { namespace gsc { namespace iw8 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2530,6 +2555,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2561,6 +2587,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2589,9 +2619,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4890,8 +4920,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2425, ///< Last index in yytable_.
yynnts_ = 83, ///< Number of nonterminal symbols.
yylast_ = 2407, ///< Last index in yytable_.
yynnts_ = 85, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -5093,6 +5123,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -5124,6 +5155,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5152,9 +5187,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5417,6 +5452,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5448,6 +5484,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5476,9 +5516,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5600,7 +5640,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::iw8
#line 5604 "parser.hpp"
#line 5644 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint32_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint32_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -75564,7 +75564,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -75578,31 +75578,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -284,6 +287,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -580,6 +588,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -588,7 +598,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1009,9 +1018,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1961,30 +1967,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2109,6 +2091,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2174,6 +2159,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -110,7 +111,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -123,6 +123,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1856,7 +1856,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2135,7 +2135,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2144,29 +2144,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2406,7 +2406,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2507,7 +2507,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2773,7 +2773,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -73,12 +73,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -90,7 +90,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -112,7 +112,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -562,7 +562,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,7 @@ namespace xsk { namespace gsc { namespace s1 {
char dummy39[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy40[sizeof (ast::stmt)];
// stmt_assign
@ -558,64 +559,67 @@ namespace xsk { namespace gsc { namespace s1 {
// stmt_default
char dummy47[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy48[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy48[sizeof (ast::stmt_dowhile::ptr)];
char dummy49[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy49[sizeof (ast::stmt_endon::ptr)];
char dummy50[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy50[sizeof (ast::stmt_expr::ptr)];
char dummy51[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy51[sizeof (ast::stmt_for::ptr)];
char dummy52[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy52[sizeof (ast::stmt_foreach::ptr)];
char dummy53[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy53[sizeof (ast::stmt_if::ptr)];
char dummy54[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy54[sizeof (ast::stmt_ifelse::ptr)];
char dummy55[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy55[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy56[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy56[sizeof (ast::stmt_notify::ptr)];
char dummy57[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy57[sizeof (ast::stmt_prof_begin::ptr)];
char dummy58[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy58[sizeof (ast::stmt_prof_end::ptr)];
char dummy59[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy59[sizeof (ast::stmt_return::ptr)];
char dummy60[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy60[sizeof (ast::stmt_switch::ptr)];
char dummy61[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy61[sizeof (ast::stmt_wait::ptr)];
char dummy62[sizeof (ast::stmt_wait::ptr)];
// stmt_waitframe
char dummy62[sizeof (ast::stmt_waitframe::ptr)];
char dummy63[sizeof (ast::stmt_waitframe::ptr)];
// stmt_waittill
char dummy63[sizeof (ast::stmt_waittill::ptr)];
char dummy64[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy64[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy65[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy65[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy66[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy66[sizeof (ast::stmt_while::ptr)];
char dummy67[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -625,7 +629,7 @@ namespace xsk { namespace gsc { namespace s1 {
// "color"
// "float"
// "integer"
char dummy67[sizeof (std::string)];
char dummy68[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -930,77 +934,79 @@ namespace xsk { namespace gsc { namespace s1 {
S_decl_constant = 121, // decl_constant
S_decl_thread = 122, // decl_thread
S_stmt = 123, // stmt
S_stmt_dev = 124, // stmt_dev
S_stmt_block = 125, // stmt_block
S_stmt_list = 126, // stmt_list
S_stmt_expr = 127, // stmt_expr
S_stmt_call = 128, // stmt_call
S_stmt_assign = 129, // stmt_assign
S_stmt_endon = 130, // stmt_endon
S_stmt_notify = 131, // stmt_notify
S_stmt_wait = 132, // stmt_wait
S_stmt_waittill = 133, // stmt_waittill
S_stmt_waittillmatch = 134, // stmt_waittillmatch
S_stmt_waittillframeend = 135, // stmt_waittillframeend
S_stmt_waitframe = 136, // stmt_waitframe
S_stmt_if = 137, // stmt_if
S_stmt_ifelse = 138, // stmt_ifelse
S_stmt_while = 139, // stmt_while
S_stmt_dowhile = 140, // stmt_dowhile
S_stmt_for = 141, // stmt_for
S_stmt_foreach = 142, // stmt_foreach
S_stmt_switch = 143, // stmt_switch
S_stmt_case = 144, // stmt_case
S_stmt_default = 145, // stmt_default
S_stmt_break = 146, // stmt_break
S_stmt_continue = 147, // stmt_continue
S_stmt_return = 148, // stmt_return
S_stmt_breakpoint = 149, // stmt_breakpoint
S_stmt_prof_begin = 150, // stmt_prof_begin
S_stmt_prof_end = 151, // stmt_prof_end
S_expr = 152, // expr
S_expr_or_empty = 153, // expr_or_empty
S_expr_assign = 154, // expr_assign
S_expr_increment = 155, // expr_increment
S_expr_decrement = 156, // expr_decrement
S_expr_ternary = 157, // expr_ternary
S_expr_binary = 158, // expr_binary
S_expr_primitive = 159, // expr_primitive
S_expr_complement = 160, // expr_complement
S_expr_not = 161, // expr_not
S_expr_call = 162, // expr_call
S_expr_method = 163, // expr_method
S_expr_function = 164, // expr_function
S_expr_pointer = 165, // expr_pointer
S_expr_add_array = 166, // expr_add_array
S_expr_parameters = 167, // expr_parameters
S_expr_arguments = 168, // expr_arguments
S_expr_arguments_no_empty = 169, // expr_arguments_no_empty
S_expr_reference = 170, // expr_reference
S_expr_array = 171, // expr_array
S_expr_field = 172, // expr_field
S_expr_size = 173, // expr_size
S_expr_paren = 174, // expr_paren
S_expr_object = 175, // expr_object
S_expr_thisthread = 176, // expr_thisthread
S_expr_empty_array = 177, // expr_empty_array
S_expr_undefined = 178, // expr_undefined
S_expr_game = 179, // expr_game
S_expr_self = 180, // expr_self
S_expr_anim = 181, // expr_anim
S_expr_level = 182, // expr_level
S_expr_animation = 183, // expr_animation
S_expr_animtree = 184, // expr_animtree
S_expr_identifier = 185, // expr_identifier
S_expr_path = 186, // expr_path
S_expr_istring = 187, // expr_istring
S_expr_string = 188, // expr_string
S_expr_color = 189, // expr_color
S_expr_vector = 190, // expr_vector
S_expr_float = 191, // expr_float
S_expr_integer = 192, // expr_integer
S_expr_false = 193, // expr_false
S_expr_true = 194 // expr_true
S_stmt_or_dev = 124, // stmt_or_dev
S_stmt_list = 125, // stmt_list
S_stmt_or_dev_list = 126, // stmt_or_dev_list
S_stmt_dev = 127, // stmt_dev
S_stmt_block = 128, // stmt_block
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_reference = 172, // expr_reference
S_expr_array = 173, // expr_array
S_expr_field = 174, // expr_field
S_expr_size = 175, // expr_size
S_expr_paren = 176, // expr_paren
S_expr_object = 177, // expr_object
S_expr_thisthread = 178, // expr_thisthread
S_expr_empty_array = 179, // expr_empty_array
S_expr_undefined = 180, // expr_undefined
S_expr_game = 181, // expr_game
S_expr_self = 182, // expr_self
S_expr_anim = 183, // expr_anim
S_expr_level = 184, // expr_level
S_expr_animation = 185, // expr_animation
S_expr_animtree = 186, // expr_animtree
S_expr_identifier = 187, // expr_identifier
S_expr_path = 188, // expr_path
S_expr_istring = 189, // expr_istring
S_expr_string = 190, // expr_string
S_expr_color = 191, // expr_color
S_expr_vector = 192, // expr_vector
S_expr_float = 193, // expr_float
S_expr_integer = 194, // expr_integer
S_expr_false = 195, // expr_false
S_expr_true = 196 // expr_true
};
};
@ -1204,6 +1210,7 @@ namespace xsk { namespace gsc { namespace s1 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1235,6 +1242,10 @@ namespace xsk { namespace gsc { namespace s1 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1263,9 +1274,9 @@ namespace xsk { namespace gsc { namespace s1 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -2005,6 +2016,20 @@ namespace xsk { namespace gsc { namespace s1 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2474,6 +2499,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2505,6 +2531,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2533,9 +2563,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4804,8 +4834,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2291, ///< Last index in yytable_.
yynnts_ = 81, ///< Number of nonterminal symbols.
yylast_ = 2285, ///< Last index in yytable_.
yynnts_ = 83, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -4999,6 +5029,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -5030,6 +5061,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5058,9 +5093,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5315,6 +5350,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5346,6 +5382,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5374,9 +5414,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5498,7 +5538,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s1
#line 5502 "parser.hpp"
#line 5542 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -2583,7 +2583,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -2597,31 +2597,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -284,6 +287,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -580,6 +588,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -588,7 +598,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -1009,9 +1018,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -1961,30 +1967,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2109,6 +2091,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2174,6 +2159,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -110,7 +111,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -123,6 +123,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1863,7 +1863,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2142,7 +2142,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2151,29 +2151,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2413,7 +2413,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2514,7 +2514,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2780,7 +2780,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -73,12 +73,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -90,7 +90,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -112,7 +112,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -562,7 +562,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint16_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint16_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -3121,7 +3121,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -3135,31 +3135,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -152,7 +152,7 @@ void compiler::emit_declaration(const ast::decl& decl)
void compiler::emit_decl_usingtree(const ast::decl_usingtree::ptr& animtree)
{
if(developer_thread_)
if (developer_thread_)
throw comp_error(animtree->loc(), "cannot put #using_animtree inside /# ... #/ comment");
animtrees_.push_back({ animtree->name->value, false });
@ -195,6 +195,9 @@ void compiler::emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last
case ast::kind::stmt_list:
emit_stmt_list(stmt.as_list, blk, last);
break;
case ast::kind::stmt_dev:
emit_stmt_dev(stmt.as_dev, blk, last);
break;
case ast::kind::stmt_expr:
emit_stmt_expr(stmt.as_expr, blk);
break;
@ -284,6 +287,11 @@ void compiler::emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr&
}
}
void compiler::emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last)
{
emit_stmt_list(stmt->list, blk, last);
}
void compiler::emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())
@ -580,6 +588,8 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_stmt(stmt->stmt, stmt->blk, false);
insert_label(continue_loc);
bool const_cond = is_constant_condition(stmt->test);
if (!const_cond)
@ -588,7 +598,6 @@ void compiler::emit_stmt_dowhile(const ast::stmt_dowhile::ptr& stmt, const block
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
}
insert_label(continue_loc);
emit_opcode(opcode::OP_jumpback, begin_loc);
insert_label(break_loc);
@ -712,7 +721,7 @@ void compiler::emit_stmt_foreach(const ast::stmt_foreach::ptr& stmt, const block
auto begin_loc = insert_label();
emit_expr_variable(stmt->key_expr, blk);
emit_opcode(opcode::OP_CallBuiltin1, "isdefined");
emit_opcode(opcode::OP_IsDefined);
emit_opcode(opcode::OP_JumpOnFalse, break_loc);
can_break_ = true;
@ -1015,9 +1024,6 @@ void compiler::emit_expr(const ast::expr& expr, const block::ptr& blk)
case ast::kind::expr_string:
emit_expr_string(expr.as_string);
break;
case ast::kind::expr_color:
emit_expr_color(expr.as_color);
break;
case ast::kind::expr_vector:
emit_expr_vector(expr.as_vector, blk);
break;
@ -2012,30 +2018,6 @@ void compiler::emit_expr_string(const ast::expr_string::ptr& expr)
emit_opcode(opcode::OP_GetString, expr->value);
}
void compiler::emit_expr_color(const ast::expr_color::ptr& expr)
{
std::vector<std::string> data;
std::string x, y, z;
if (expr->value.size() == 3)
{
x = "0x" + expr->value.substr(0, 1) + expr->value.substr(0, 1);
y = "0x" + expr->value.substr(1, 1) + expr->value.substr(1, 1);
z = "0x" + expr->value.substr(2, 1) + expr->value.substr(2, 1);
}
else
{
x = "0x" + expr->value.substr(0, 2);
y = "0x" + expr->value.substr(2, 2);
z = "0x" + expr->value.substr(4, 2);
}
data.push_back(utils::string::hex_to_dec(x.data()));
data.push_back(utils::string::hex_to_dec(y.data()));
data.push_back(utils::string::hex_to_dec(z.data()));
emit_opcode(opcode::OP_GetVector, data);
}
void compiler::emit_expr_float(const ast::expr_float::ptr& expr)
{
emit_opcode(opcode::OP_GetFloat, expr->value);
@ -2160,6 +2142,9 @@ void compiler::process_stmt(const ast::stmt& stmt, const block::ptr& blk)
case ast::kind::stmt_list:
process_stmt_list(stmt.as_list, blk);
break;
case ast::kind::stmt_dev:
process_stmt_dev(stmt.as_dev, blk);
break;
case ast::kind::stmt_expr:
process_stmt_expr(stmt.as_expr, blk);
break;
@ -2225,6 +2210,11 @@ void compiler::process_stmt_list(const ast::stmt_list::ptr& stmt, const block::p
}
}
void compiler::process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk)
{
process_stmt_list(stmt->list, blk);
}
void compiler::process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk)
{
switch (stmt->expr.kind())

View File

@ -48,6 +48,7 @@ private:
void emit_decl_thread(const ast::decl_thread::ptr& thread);
void emit_stmt(const ast::stmt& stmt, const block::ptr& blk, bool last);
void emit_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk, bool last);
void emit_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void emit_stmt_call(const ast::stmt_call::ptr& stmt, const block::ptr& blk);
void emit_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
@ -112,7 +113,6 @@ private:
void emit_expr_animtree(const ast::expr_animtree::ptr& expr);
void emit_expr_istring(const ast::expr_istring::ptr& expr);
void emit_expr_string(const ast::expr_string::ptr& expr);
void emit_expr_color(const ast::expr_color::ptr& expr);
void emit_expr_float(const ast::expr_float::ptr& expr);
void emit_expr_integer(const ast::expr_integer::ptr& expr);
void emit_expr_false(const ast::expr_false::ptr& expr);
@ -125,6 +125,7 @@ private:
void process_thread(const ast::decl_thread::ptr& decl, const block::ptr& blk);
void process_stmt(const ast::stmt& stmt, const block::ptr& blk);
void process_stmt_list(const ast::stmt_list::ptr& stmt, const block::ptr& blk);
void process_stmt_dev(const ast::stmt_dev::ptr& stmt, const block::ptr& blk);
void process_stmt_expr(const ast::stmt_expr::ptr& stmt, const block::ptr& blk);
void process_stmt_assign(const ast::stmt_assign::ptr& stmt, const block::ptr& blk);
void process_stmt_waittill(const ast::stmt_waittill::ptr& stmt, const block::ptr& blk);

View File

@ -75,7 +75,7 @@ void decompiler::decompile_function(const function::ptr& func)
// hotfix empty else block at func end
if (stmt->list.size() > 0 && stmt->list.back() == ast::kind::asm_jump)
{
if(stmt->list.back().as_jump->value == blk.loc_end)
if (stmt->list.back().as_jump->value == blk.loc_end)
stmt->list.pop_back();
}
@ -255,7 +255,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
auto name = std::make_unique<ast::expr_identifier>(loc, inst->data[1]);
auto node = std::make_unique<ast::expr_reference>(loc, std::move(path), std::move(name));
stack_.push(std::move(node));
};
}
break;
case opcode::OP_CreateLocalVariable:
{
@ -1657,7 +1657,7 @@ void decompiler::decompile_instruction(const instruction::ptr& inst)
{
auto expr = std::make_unique<ast::asm_jump>(loc, inst->data[0]);
func_->stmt->list.push_back(ast::stmt(std::move(expr)));
if(stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
if (stack_.size() != 0) tern_labels_.push_back(inst->data[0]);
}
break;
case opcode::OP_jumpback:
@ -1887,7 +1887,7 @@ void decompiler::decompile_ifelses(const ast::stmt_list::ptr& stmt)
{
auto& entry = stmt->list.at(i);
if(entry == ast::kind::asm_jump_cond)
if (entry == ast::kind::asm_jump_cond)
{
auto j = (entry.as_cond->value == blocks_.back().loc_end) ? (stmt->list.size() - 1) : (find_location_index(stmt, entry.as_cond->value) - 1);
auto last_loc = blocks_.back().loc_end;
@ -2166,7 +2166,7 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
{
auto ref = block->list.at(start).loc().label();
if(!find_location_reference(block, 0, start, ref))
if (!find_location_reference(block, 0, start, ref))
{
decompile_foreach(block, start, end);
return;
@ -2175,29 +2175,29 @@ void decompiler::decompile_loop(const ast::stmt_list::ptr& block, std::uint32_t
}
}
if(start > 0) // while at func start
if (start > 0) // while at func start
{
auto index = 1;
while(block->list.at(start - index) == ast::kind::asm_create)
while (block->list.at(start - index) == ast::kind::asm_create)
{
if(start - index > 0)
if (start - index > 0)
index++;
else
break;
}
if(block->list.at(start - index) == ast::kind::stmt_assign)
if (block->list.at(start - index) == ast::kind::stmt_assign)
{
auto ref = block->list.at(end).loc().label();
auto ref2 = block->list.at(start).loc().label();
if(find_location_reference(block, start, end, ref))
if (find_location_reference(block, start, end, ref))
{
// continue is at jumpback, not post-expr
decompile_while(block, start, end);
return;
}
else if(find_location_reference(block, 0, start, ref2))
else if (find_location_reference(block, 0, start, ref2))
{
// begin is at condition, not pre-expr
decompile_while(block, start, end);
@ -2437,7 +2437,7 @@ void decompiler::decompile_switch(const ast::stmt_list::ptr& stmt, std::uint32_t
auto list = std::make_unique<ast::stmt_list>(loc);
list->is_case = true;
auto def_stmt = ast::stmt(std::make_unique<ast::stmt_default>(loc_pos, std::move(list)));
while(stmt->list.at(loc_idx) == ast::kind::stmt_case)
while (stmt->list.at(loc_idx) == ast::kind::stmt_case)
loc_idx++;
stmt->list.insert(stmt->list.begin() + loc_idx, std::move(def_stmt));
idx += 2;
@ -2538,7 +2538,7 @@ auto decompiler::find_location_index(const ast::stmt_list::ptr& stmt, const std:
for (auto& entry : stmt->list)
{
if(entry.loc().label() == location)
if (entry.loc().label() == location)
return index;
index++;
@ -2804,7 +2804,7 @@ void decompiler::process_stmt_ifelse(const ast::stmt_ifelse::ptr& stmt, const bl
{
abort = stmt->blk_if->abort;
if(abort == abort_t::abort_none)
if (abort == abort_t::abort_none)
childs.push_back(stmt->blk_if.get());
}

View File

@ -75,12 +75,12 @@ buffer::buffer() : length(0)
buffer::~buffer()
{
if(data) std::free(data);
if (data) std::free(data);
}
bool buffer::push(char c)
{
if(length >= max_buf_size)
if (length >= max_buf_size)
return false;
data[length++] = c;
@ -92,7 +92,7 @@ reader::reader() : state(reader::end), buffer_pos(0), bytes_remaining(0),
void reader::init(const char* data, size_t size)
{
if(data && size)
if (data && size)
{
state = reader::ok;
buffer_pos = data;
@ -114,7 +114,7 @@ void reader::advance()
{
++buffer_pos;
if(bytes_remaining-- == 1)
if (bytes_remaining-- == 1)
{
state = reader::end;
bytes_remaining = 0;
@ -216,7 +216,7 @@ auto lexer::lex() -> parser::symbol_type
case '\\':
throw comp_error(loc_, "invalid token ('\\')");
case '/':
if (curr != '/' && curr != '*' && curr != '#' && curr != '=')
if (curr != '=' && curr != '#' && curr != '*' && curr != '/')
return parser::make_DIV(loc_);
advance();
@ -564,7 +564,7 @@ lex_name:
advance();
}
if(state_ == state::field)
if (state_ == state::field)
{
if (path)
throw comp_error(loc_, "invalid field token '\\'");

File diff suppressed because it is too large Load Diff

View File

@ -541,6 +541,7 @@ namespace xsk { namespace gsc { namespace s4 {
char dummy41[sizeof (ast::program::ptr)];
// stmt
// stmt_or_dev
char dummy42[sizeof (ast::stmt)];
// stmt_assign
@ -564,64 +565,67 @@ namespace xsk { namespace gsc { namespace s4 {
// stmt_default
char dummy49[sizeof (ast::stmt_default::ptr)];
// stmt_dev
char dummy50[sizeof (ast::stmt_dev::ptr)];
// stmt_dowhile
char dummy50[sizeof (ast::stmt_dowhile::ptr)];
char dummy51[sizeof (ast::stmt_dowhile::ptr)];
// stmt_endon
char dummy51[sizeof (ast::stmt_endon::ptr)];
char dummy52[sizeof (ast::stmt_endon::ptr)];
// stmt_expr
char dummy52[sizeof (ast::stmt_expr::ptr)];
char dummy53[sizeof (ast::stmt_expr::ptr)];
// stmt_for
char dummy53[sizeof (ast::stmt_for::ptr)];
char dummy54[sizeof (ast::stmt_for::ptr)];
// stmt_foreach
char dummy54[sizeof (ast::stmt_foreach::ptr)];
char dummy55[sizeof (ast::stmt_foreach::ptr)];
// stmt_if
char dummy55[sizeof (ast::stmt_if::ptr)];
char dummy56[sizeof (ast::stmt_if::ptr)];
// stmt_ifelse
char dummy56[sizeof (ast::stmt_ifelse::ptr)];
char dummy57[sizeof (ast::stmt_ifelse::ptr)];
// stmt_dev
// stmt_block
// stmt_list
char dummy57[sizeof (ast::stmt_list::ptr)];
// stmt_or_dev_list
// stmt_block
char dummy58[sizeof (ast::stmt_list::ptr)];
// stmt_notify
char dummy58[sizeof (ast::stmt_notify::ptr)];
char dummy59[sizeof (ast::stmt_notify::ptr)];
// stmt_prof_begin
char dummy59[sizeof (ast::stmt_prof_begin::ptr)];
char dummy60[sizeof (ast::stmt_prof_begin::ptr)];
// stmt_prof_end
char dummy60[sizeof (ast::stmt_prof_end::ptr)];
char dummy61[sizeof (ast::stmt_prof_end::ptr)];
// stmt_return
char dummy61[sizeof (ast::stmt_return::ptr)];
char dummy62[sizeof (ast::stmt_return::ptr)];
// stmt_switch
char dummy62[sizeof (ast::stmt_switch::ptr)];
char dummy63[sizeof (ast::stmt_switch::ptr)];
// stmt_wait
char dummy63[sizeof (ast::stmt_wait::ptr)];
char dummy64[sizeof (ast::stmt_wait::ptr)];
// stmt_waitframe
char dummy64[sizeof (ast::stmt_waitframe::ptr)];
char dummy65[sizeof (ast::stmt_waitframe::ptr)];
// stmt_waittill
char dummy65[sizeof (ast::stmt_waittill::ptr)];
char dummy66[sizeof (ast::stmt_waittill::ptr)];
// stmt_waittillframeend
char dummy66[sizeof (ast::stmt_waittillframeend::ptr)];
char dummy67[sizeof (ast::stmt_waittillframeend::ptr)];
// stmt_waittillmatch
char dummy67[sizeof (ast::stmt_waittillmatch::ptr)];
char dummy68[sizeof (ast::stmt_waittillmatch::ptr)];
// stmt_while
char dummy68[sizeof (ast::stmt_while::ptr)];
char dummy69[sizeof (ast::stmt_while::ptr)];
// "field"
// "path"
@ -631,7 +635,7 @@ namespace xsk { namespace gsc { namespace s4 {
// "color"
// "float"
// "integer"
char dummy69[sizeof (std::string)];
char dummy70[sizeof (std::string)];
};
/// The size of the largest semantic type.
@ -940,79 +944,81 @@ namespace xsk { namespace gsc { namespace s4 {
S_decl_constant = 123, // decl_constant
S_decl_thread = 124, // decl_thread
S_stmt = 125, // stmt
S_stmt_dev = 126, // stmt_dev
S_stmt_block = 127, // stmt_block
S_stmt_list = 128, // stmt_list
S_stmt_expr = 129, // stmt_expr
S_stmt_call = 130, // stmt_call
S_stmt_assign = 131, // stmt_assign
S_stmt_endon = 132, // stmt_endon
S_stmt_notify = 133, // stmt_notify
S_stmt_wait = 134, // stmt_wait
S_stmt_waittill = 135, // stmt_waittill
S_stmt_waittillmatch = 136, // stmt_waittillmatch
S_stmt_waittillframeend = 137, // stmt_waittillframeend
S_stmt_waitframe = 138, // stmt_waitframe
S_stmt_if = 139, // stmt_if
S_stmt_ifelse = 140, // stmt_ifelse
S_stmt_while = 141, // stmt_while
S_stmt_dowhile = 142, // stmt_dowhile
S_stmt_for = 143, // stmt_for
S_stmt_foreach = 144, // stmt_foreach
S_stmt_switch = 145, // stmt_switch
S_stmt_case = 146, // stmt_case
S_stmt_default = 147, // stmt_default
S_stmt_break = 148, // stmt_break
S_stmt_continue = 149, // stmt_continue
S_stmt_return = 150, // stmt_return
S_stmt_breakpoint = 151, // stmt_breakpoint
S_stmt_prof_begin = 152, // stmt_prof_begin
S_stmt_prof_end = 153, // stmt_prof_end
S_expr = 154, // expr
S_expr_or_empty = 155, // expr_or_empty
S_expr_assign = 156, // expr_assign
S_expr_increment = 157, // expr_increment
S_expr_decrement = 158, // expr_decrement
S_expr_ternary = 159, // expr_ternary
S_expr_binary = 160, // expr_binary
S_expr_primitive = 161, // expr_primitive
S_expr_complement = 162, // expr_complement
S_expr_not = 163, // expr_not
S_expr_call = 164, // expr_call
S_expr_method = 165, // expr_method
S_expr_function = 166, // expr_function
S_expr_pointer = 167, // expr_pointer
S_expr_add_array = 168, // expr_add_array
S_expr_parameters = 169, // expr_parameters
S_expr_arguments = 170, // expr_arguments
S_expr_arguments_no_empty = 171, // expr_arguments_no_empty
S_expr_isdefined = 172, // expr_isdefined
S_expr_istrue = 173, // expr_istrue
S_expr_reference = 174, // expr_reference
S_expr_array = 175, // expr_array
S_expr_field = 176, // expr_field
S_expr_size = 177, // expr_size
S_expr_paren = 178, // expr_paren
S_expr_object = 179, // expr_object
S_expr_thisthread = 180, // expr_thisthread
S_expr_empty_array = 181, // expr_empty_array
S_expr_undefined = 182, // expr_undefined
S_expr_game = 183, // expr_game
S_expr_self = 184, // expr_self
S_expr_anim = 185, // expr_anim
S_expr_level = 186, // expr_level
S_expr_animation = 187, // expr_animation
S_expr_animtree = 188, // expr_animtree
S_expr_identifier = 189, // expr_identifier
S_expr_path = 190, // expr_path
S_expr_istring = 191, // expr_istring
S_expr_string = 192, // expr_string
S_expr_color = 193, // expr_color
S_expr_vector = 194, // expr_vector
S_expr_float = 195, // expr_float
S_expr_integer = 196, // expr_integer
S_expr_false = 197, // expr_false
S_expr_true = 198 // expr_true
S_stmt_or_dev = 126, // stmt_or_dev
S_stmt_list = 127, // stmt_list
S_stmt_or_dev_list = 128, // stmt_or_dev_list
S_stmt_dev = 129, // stmt_dev
S_stmt_block = 130, // stmt_block
S_stmt_expr = 131, // stmt_expr
S_stmt_call = 132, // stmt_call
S_stmt_assign = 133, // stmt_assign
S_stmt_endon = 134, // stmt_endon
S_stmt_notify = 135, // stmt_notify
S_stmt_wait = 136, // stmt_wait
S_stmt_waittill = 137, // stmt_waittill
S_stmt_waittillmatch = 138, // stmt_waittillmatch
S_stmt_waittillframeend = 139, // stmt_waittillframeend
S_stmt_waitframe = 140, // stmt_waitframe
S_stmt_if = 141, // stmt_if
S_stmt_ifelse = 142, // stmt_ifelse
S_stmt_while = 143, // stmt_while
S_stmt_dowhile = 144, // stmt_dowhile
S_stmt_for = 145, // stmt_for
S_stmt_foreach = 146, // stmt_foreach
S_stmt_switch = 147, // stmt_switch
S_stmt_case = 148, // stmt_case
S_stmt_default = 149, // stmt_default
S_stmt_break = 150, // stmt_break
S_stmt_continue = 151, // stmt_continue
S_stmt_return = 152, // stmt_return
S_stmt_breakpoint = 153, // stmt_breakpoint
S_stmt_prof_begin = 154, // stmt_prof_begin
S_stmt_prof_end = 155, // stmt_prof_end
S_expr = 156, // expr
S_expr_or_empty = 157, // expr_or_empty
S_expr_assign = 158, // expr_assign
S_expr_increment = 159, // expr_increment
S_expr_decrement = 160, // expr_decrement
S_expr_ternary = 161, // expr_ternary
S_expr_binary = 162, // expr_binary
S_expr_primitive = 163, // expr_primitive
S_expr_complement = 164, // expr_complement
S_expr_not = 165, // expr_not
S_expr_call = 166, // expr_call
S_expr_method = 167, // expr_method
S_expr_function = 168, // expr_function
S_expr_pointer = 169, // expr_pointer
S_expr_add_array = 170, // expr_add_array
S_expr_parameters = 171, // expr_parameters
S_expr_arguments = 172, // expr_arguments
S_expr_arguments_no_empty = 173, // expr_arguments_no_empty
S_expr_isdefined = 174, // expr_isdefined
S_expr_istrue = 175, // expr_istrue
S_expr_reference = 176, // expr_reference
S_expr_array = 177, // expr_array
S_expr_field = 178, // expr_field
S_expr_size = 179, // expr_size
S_expr_paren = 180, // expr_paren
S_expr_object = 181, // expr_object
S_expr_thisthread = 182, // expr_thisthread
S_expr_empty_array = 183, // expr_empty_array
S_expr_undefined = 184, // expr_undefined
S_expr_game = 185, // expr_game
S_expr_self = 186, // expr_self
S_expr_anim = 187, // expr_anim
S_expr_level = 188, // expr_level
S_expr_animation = 189, // expr_animation
S_expr_animtree = 190, // expr_animtree
S_expr_identifier = 191, // expr_identifier
S_expr_path = 192, // expr_path
S_expr_istring = 193, // expr_istring
S_expr_string = 194, // expr_string
S_expr_color = 195, // expr_color
S_expr_vector = 196, // expr_vector
S_expr_float = 197, // expr_float
S_expr_integer = 198, // expr_integer
S_expr_false = 199, // expr_false
S_expr_true = 200 // expr_true
};
};
@ -1224,6 +1230,7 @@ namespace xsk { namespace gsc { namespace s4 {
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (std::move (that.value));
break;
@ -1255,6 +1262,10 @@ namespace xsk { namespace gsc { namespace s4 {
value.move< ast::stmt_default::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (std::move (that.value));
break;
@ -1283,9 +1294,9 @@ namespace xsk { namespace gsc { namespace s4 {
value.move< ast::stmt_ifelse::ptr > (std::move (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (std::move (that.value));
break;
@ -2053,6 +2064,20 @@ namespace xsk { namespace gsc { namespace s4 {
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dev::ptr&& v, location_type&& l)
: Base (t)
, value (std::move (v))
, location (std::move (l))
{}
#else
basic_symbol (typename Base::kind_type t, const ast::stmt_dev::ptr& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ast::stmt_dowhile::ptr&& v, location_type&& l)
: Base (t)
@ -2530,6 +2555,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.template destroy< ast::stmt > ();
break;
@ -2561,6 +2587,10 @@ switch (yykind)
value.template destroy< ast::stmt_default::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.template destroy< ast::stmt_dev::ptr > ();
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.template destroy< ast::stmt_dowhile::ptr > ();
break;
@ -2589,9 +2619,9 @@ switch (yykind)
value.template destroy< ast::stmt_ifelse::ptr > ();
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.template destroy< ast::stmt_list::ptr > ();
break;
@ -4890,8 +4920,8 @@ switch (yykind)
/// Constants.
enum
{
yylast_ = 2425, ///< Last index in yytable_.
yynnts_ = 83, ///< Number of nonterminal symbols.
yylast_ = 2407, ///< Last index in yytable_.
yynnts_ = 85, ///< Number of nonterminal symbols.
yyfinal_ = 21 ///< Termination state number.
};
@ -5093,6 +5123,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.copy< ast::stmt > (YY_MOVE (that.value));
break;
@ -5124,6 +5155,10 @@ switch (yykind)
value.copy< ast::stmt_default::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.copy< ast::stmt_dev::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.copy< ast::stmt_dowhile::ptr > (YY_MOVE (that.value));
break;
@ -5152,9 +5187,9 @@ switch (yykind)
value.copy< ast::stmt_ifelse::ptr > (YY_MOVE (that.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.copy< ast::stmt_list::ptr > (YY_MOVE (that.value));
break;
@ -5417,6 +5452,7 @@ switch (yykind)
break;
case symbol_kind::S_stmt: // stmt
case symbol_kind::S_stmt_or_dev: // stmt_or_dev
value.move< ast::stmt > (YY_MOVE (s.value));
break;
@ -5448,6 +5484,10 @@ switch (yykind)
value.move< ast::stmt_default::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
value.move< ast::stmt_dev::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dowhile: // stmt_dowhile
value.move< ast::stmt_dowhile::ptr > (YY_MOVE (s.value));
break;
@ -5476,9 +5516,9 @@ switch (yykind)
value.move< ast::stmt_ifelse::ptr > (YY_MOVE (s.value));
break;
case symbol_kind::S_stmt_dev: // stmt_dev
case symbol_kind::S_stmt_block: // stmt_block
case symbol_kind::S_stmt_list: // stmt_list
case symbol_kind::S_stmt_or_dev_list: // stmt_or_dev_list
case symbol_kind::S_stmt_block: // stmt_block
value.move< ast::stmt_list::ptr > (YY_MOVE (s.value));
break;
@ -5600,7 +5640,7 @@ switch (yykind)
#line 13 "parser.ypp"
} } } // xsk::gsc::s4
#line 5604 "parser.hpp"
#line 5644 "parser.hpp"

View File

@ -46,7 +46,7 @@ auto resolver::opcode_name(std::uint8_t id) -> std::string
auto resolver::function_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_func_"))
if (name.starts_with("_func_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -75,7 +75,7 @@ auto resolver::function_name(std::uint16_t id) -> std::string
auto resolver::method_id(const std::string& name) -> std::uint16_t
{
if(name.starts_with("_meth_"))
if (name.starts_with("_meth_"))
{
return std::stoul(name.substr(6), nullptr, 16);
}
@ -104,7 +104,7 @@ auto resolver::method_name(std::uint16_t id) -> std::string
auto resolver::file_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -133,7 +133,7 @@ auto resolver::file_name(std::uint32_t id) -> std::string
auto resolver::token_id(const std::string& name) -> std::uint32_t
{
if(name.starts_with("_id_"))
if (name.starts_with("_id_"))
{
return std::stoul(name.substr(4), nullptr, 16);
}
@ -162,7 +162,7 @@ auto resolver::token_name(std::uint32_t id) -> std::string
auto resolver::find_function(const std::string& name) -> bool
{
if(name.starts_with("_func_")) return true;
if (name.starts_with("_func_")) return true;
const auto itr = function_map_rev.find(name);
@ -176,7 +176,7 @@ auto resolver::find_function(const std::string& name) -> bool
auto resolver::find_method(const std::string& name) -> bool
{
if(name.starts_with("_meth_")) return true;
if (name.starts_with("_meth_")) return true;
const auto itr = method_map_rev.find(name);
@ -190,7 +190,7 @@ auto resolver::find_method(const std::string& name) -> bool
auto resolver::make_token(std::string_view str) -> std::string
{
if(str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
if (str.starts_with("_id_") || str.starts_with("_func_") || str.starts_with("_meth_"))
{
return std::string(str);
}
@ -213,7 +213,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
{
const auto& itr = files.find(name);
if(itr != files.end())
if (itr != files.end())
{
return { &itr->first ,reinterpret_cast<char*>(itr->second.data()), itr->second.size() };
}
@ -222,7 +222,7 @@ auto resolver::file_data(const std::string& name) -> std::tuple<const std::strin
const auto& res = files.insert({ name, std::move(data)});
if(res.second)
if (res.second)
{
return { &res.first->first, reinterpret_cast<char*>(res.first->second.data()), res.first->second.size() };
}
@ -460,7 +460,7 @@ struct __init__
__init__()
{
static bool init = false;
if(init) return;
if (init) return;
init = true;
opcode_map.reserve(opcode_list.size());
@ -474,31 +474,31 @@ struct __init__
token_map.reserve(token_list.size());
token_map_rev.reserve(token_list.size());
for(const auto& entry : opcode_list)
for (const auto& entry : opcode_list)
{
opcode_map.insert({ entry.first, entry.second });
opcode_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : function_list)
for (const auto& entry : function_list)
{
function_map.insert({ entry.first, entry.second });
function_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : method_list)
for (const auto& entry : method_list)
{
method_map.insert({ entry.first, entry.second });
method_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : file_list)
for (const auto& entry : file_list)
{
file_map.insert({ entry.first, entry.second });
file_map_rev.insert({ entry.second, entry.first });
}
for(const auto& entry : token_list)
for (const auto& entry : token_list)
{
token_map.insert({ entry.first, entry.second });
token_map_rev.insert({ entry.second, entry.first });

View File

@ -98,7 +98,7 @@ void block::merge(const std::vector<block*>& childs)
{
child->local_vars.insert(child->local_vars.begin() + i, this->local_vars.at(i));
}
else if(pos > i)
else if (pos > i)
{
auto& v = child->local_vars;
std::rotate(v.rend() - pos - 1, v.rend() - pos, v.rend() - i);

View File

@ -38,6 +38,23 @@ auto node::is_special_stmt() -> bool
}
}
auto node::is_special_stmt_dev() -> bool
{
switch (kind_)
{
case kind::stmt_dev:
case kind::stmt_if:
case kind::stmt_ifelse:
case kind::stmt_while:
case kind::stmt_for:
case kind::stmt_foreach:
case kind::stmt_switch:
return true;
default:
return false;
}
}
auto node::is_special_stmt_noif() -> bool
{
switch (kind_)
@ -52,6 +69,21 @@ auto node::is_special_stmt_noif() -> bool
}
}
auto node::is_special_stmt_dev_noif() -> bool
{
switch (kind_)
{
case kind::stmt_dev:
case kind::stmt_while:
case kind::stmt_for:
case kind::stmt_foreach:
case kind::stmt_switch:
return true;
default:
return false;
}
}
auto node::is_binary() -> bool
{
switch (kind_)
@ -121,9 +153,6 @@ expr_float::expr_float(const location& loc, const std::string& value) : node(kin
expr_vector::expr_vector(expr x, expr y, expr z) : node(kind::expr_vector), x(std::move(x)), y(std::move(y)), z(std::move(z)) {}
expr_vector::expr_vector(const location& loc, expr x, expr y, expr z) : node(kind::expr_vector, loc), x(std::move(x)), y(std::move(y)), z(std::move(z)) {}
expr_color::expr_color(const std::string& value) : node(kind::expr_color), value(value) {}
expr_color::expr_color(const location& loc, const std::string& value) : node(kind::expr_color, loc), value(value) {}
expr_string::expr_string(const std::string& value) : node(kind::expr_string), value(value) {}
expr_string::expr_string(const location& loc, const std::string& value) : node(kind::expr_string, loc), value(value) {}
@ -318,6 +347,9 @@ expr_assign_bitwise_exor::expr_assign_bitwise_exor(const location& loc, expr lva
stmt_list::stmt_list() : node(kind::stmt_list) {}
stmt_list::stmt_list(const location& loc) : node(kind::stmt_list, loc) {}
stmt_dev::stmt_dev(ast::stmt_list::ptr list) : node(kind::stmt_dev), list(std::move(list)) {}
stmt_dev::stmt_dev(const location& loc, ast::stmt_list::ptr list) : node(kind::stmt_dev, loc), list(std::move(list)) {}
stmt_expr::stmt_expr(ast::expr expr) : node(kind::stmt_expr), expr(std::move(expr)) {}
stmt_expr::stmt_expr(const location& loc, ast::expr expr) : node(kind::stmt_expr, loc), expr(std::move(expr)) {}
@ -486,11 +518,6 @@ auto expr_vector::print() const -> std::string
return "( "s + x.print() + ", " + y.print() + ", " + z.print() + " )";
}
auto expr_color::print() const -> std::string
{
return "#"s += value;
}
auto expr_string::print() const -> std::string
{
return value;
@ -861,6 +888,9 @@ auto stmt_list::print() const -> std::string
if (&stmt != &list.front() && stmt.as_node->is_special_stmt() || last_special)
data += "\n";
if (stmt == kind::stmt_dev)
data += stmt.print();
else
data += stmts_pad + stmt.print();
if (&stmt != &list.back())
@ -880,6 +910,39 @@ auto stmt_list::print() const -> std::string
return data;
}
auto stmt_dev::print() const -> std::string
{
std::string data;
bool last_special = false;
auto stmts_pad = indented(indent_);
data += "/#\n";
for (const auto& stmt : list->list)
{
if (&stmt != &list->list.front() && stmt.as_node->is_special_stmt() || last_special)
data += "\n";
if (stmt == kind::stmt_dev)
data += stmt.print();
else
data += stmts_pad + stmt.print();
if (&stmt != &list->list.back())
data += "\n";
if (stmt.as_node->is_special_stmt())
last_special = true;
else
last_special = false;
}
data += "\n#/";
return data;
}
auto stmt_expr::print() const -> std::string
{
return expr.print();
@ -905,7 +968,7 @@ auto stmt_notify::print() const -> std::string
if (args->list.size() == 0)
return obj.print() + " notify( " + event.print() + " );";
else
return obj.print() + " notify( " + event.print() + ", " + args->print() + " );";
return obj.print() + " notify( " + event.print() + "," + args->print() + ");";
};
auto stmt_wait::print() const -> std::string
@ -921,7 +984,7 @@ auto stmt_waittill::print() const -> std::string
if (args->list.size() == 0)
return obj.print() + " waittill( " + event.print() + " );";
else
return obj.print() + " waittill( " + event.print() + ", " + args->print() + " );";
return obj.print() + " waittill( " + event.print() + "," + args->print() + ");";
};
auto stmt_waittillmatch::print() const -> std::string
@ -929,7 +992,7 @@ auto stmt_waittillmatch::print() const -> std::string
if (args->list.size() == 0)
return obj.print() + " waittillmatch( " + event.print() + " );";
else
return obj.print() + " waittillmatch( " + event.print() + ", " + args->print() + " );";
return obj.print() + " waittillmatch( " + event.print() + "," + args->print() + ");";
};
auto stmt_waittillframeend::print() const -> std::string
@ -1228,32 +1291,32 @@ auto asm_loc::print() const -> std::string
auto asm_jump::print() const -> std::string
{
return "jump " + value;
return "__asm_jump( " + value + " );";
}
auto asm_jump_back::print() const -> std::string
{
return "jump_back " + value;
return "__asm_jump_back( " + value + " );";
}
auto asm_jump_cond::print() const -> std::string
{
return "jump_cond( " + expr.print() + " ) " + value;
return "__asm_jump_cond( " + expr.print() + ", " + value + " );";
}
auto asm_jump_true_expr::print() const -> std::string
{
return "expr_true " + value;
return "__asm_jump_expr_true( " + value + " );";
}
auto asm_jump_false_expr::print() const -> std::string
{
return "expr_false " + value;
return "__asm_jump_expr_false( " + value + " );";
}
auto asm_switch::print() const -> std::string
{
return "switch( " + expr.print() + " ) " + value;
return "__asm_switch( " + expr.print() + ", " + value + " );";
}
auto asm_endswitch::print() const -> std::string
@ -1264,37 +1327,37 @@ auto asm_endswitch::print() const -> std::string
{
result += " " + entry;
}
return "endswitch( " + count + " )" + result;
return "__asm_endswitch( " + count + "," + result + ");";
}
auto asm_prescriptcall::print() const -> std::string
{
return "prescriptcall";
return "__asm_prescriptcall();";
}
auto asm_voidcodepos::print() const -> std::string
{
return "voidcodepos";
return "__asm_voidcodepos();";
}
auto asm_create::print() const -> std::string
{
return "var_create_" + index;
return "__asm_var_create( " + index + " );";
}
auto asm_access::print() const -> std::string
{
return "var_access_" + index;
return "__asm_var_access( " + index + " );";
}
auto asm_remove::print() const -> std::string
{
return "var_remove_" + index;
return "__asm_var_remove( " + index + " );";
}
auto asm_clear::print() const -> std::string
{
return "var_clear_" + index;
return "__asm_var_clear( " + index + " );";
}
// operators
@ -1334,11 +1397,6 @@ bool operator==(const expr_vector& lhs, const expr_vector& rhs)
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z;
}
bool operator==(const expr_color& lhs, const expr_color& rhs)
{
return lhs.value == rhs.value;
}
bool operator==(const expr_string& lhs, const expr_string& rhs)
{
return lhs.value == rhs.value;
@ -1493,7 +1551,6 @@ expr::~expr()
case kind::expr_integer: as_integer.~unique_ptr(); return;
case kind::expr_float: as_float.~unique_ptr(); return;
case kind::expr_vector: as_vector.~unique_ptr(); return;
case kind::expr_color: as_color.~unique_ptr(); return;
case kind::expr_string: as_string.~unique_ptr(); return;
case kind::expr_istring: as_istring.~unique_ptr(); return;
case kind::expr_path: as_path.~unique_ptr(); return;
@ -1571,7 +1628,7 @@ bool operator==(const expr& lhs, kind rhs)
bool operator==(const expr& lhs, const expr& rhs)
{
if(!(*lhs.as_node == *rhs.as_node)) return false;
if (!(*lhs.as_node == *rhs.as_node)) return false;
switch(lhs.as_node->kind())
{
@ -1580,7 +1637,6 @@ bool operator==(const expr& lhs, const expr& rhs)
case kind::expr_integer: return *lhs.as_integer == *rhs.as_integer;
case kind::expr_float: return *lhs.as_float == *rhs.as_float;
case kind::expr_vector: return *lhs.as_vector == *rhs.as_vector;
case kind::expr_color: return *lhs.as_color == *rhs.as_color;
case kind::expr_string: return *lhs.as_string == *rhs.as_string;
case kind::expr_istring: return *lhs.as_istring == *rhs.as_istring;
case kind::expr_path: return *lhs.as_path == *rhs.as_path;
@ -1640,6 +1696,7 @@ stmt::~stmt()
{
case kind::null: as_node.~unique_ptr(); return;
case kind::stmt_list: as_list.~unique_ptr(); return;
case kind::stmt_dev: as_dev.~unique_ptr(); return;
case kind::stmt_expr: as_expr.~unique_ptr(); return;
case kind::stmt_call: as_call.~unique_ptr(); return;
case kind::stmt_assign: as_assign.~unique_ptr(); return;
@ -1666,9 +1723,9 @@ stmt::~stmt()
case kind::stmt_prof_begin: as_prof_begin.~unique_ptr(); return;
case kind::stmt_prof_end: as_prof_end.~unique_ptr(); return;
case kind::asm_loc: as_loc.~unique_ptr(); return;
case kind::asm_jump_cond: as_cond.~unique_ptr(); return;
case kind::asm_jump: as_jump.~unique_ptr(); return;
case kind::asm_jump_back: as_jump_back.~unique_ptr(); return;
case kind::asm_jump_cond: as_cond.~unique_ptr(); return;
case kind::asm_switch: as_asm_switch.~unique_ptr(); return;
case kind::asm_endswitch: as_asm_endswitch.~unique_ptr(); return;
case kind::asm_create: as_asm_create.~unique_ptr(); return;

View File

@ -16,7 +16,6 @@ enum class kind
expr_integer,
expr_float,
expr_vector,
expr_color,
expr_string,
expr_istring,
expr_path,
@ -79,6 +78,7 @@ enum class kind
expr_assign_bitwise_and,
expr_assign_bitwise_exor,
stmt_list,
stmt_dev,
stmt_expr,
stmt_call,
stmt_assign,
@ -134,7 +134,6 @@ struct expr_false;
struct expr_integer;
struct expr_float;
struct expr_vector;
struct expr_color;
struct expr_string;
struct expr_istring;
struct expr_path;
@ -199,6 +198,7 @@ struct expr_assign_bitwise_or;
struct expr_assign_bitwise_and;
struct expr_assign_bitwise_exor;
struct stmt_list;
struct stmt_dev;
struct stmt_expr;
struct stmt_call;
struct stmt_assign;
@ -273,7 +273,6 @@ union expr
std::unique_ptr<expr_integer> as_integer;
std::unique_ptr<expr_float> as_float;
std::unique_ptr<expr_vector> as_vector;
std::unique_ptr<expr_color> as_color;
std::unique_ptr<expr_string> as_string;
std::unique_ptr<expr_istring> as_istring;
std::unique_ptr<expr_path> as_path;
@ -359,6 +358,7 @@ union stmt
{
std::unique_ptr<node> as_node;
std::unique_ptr<stmt_list> as_list;
std::unique_ptr<stmt_dev> as_dev;
std::unique_ptr<stmt_expr> as_expr;
std::unique_ptr<stmt_call> as_call;
std::unique_ptr<stmt_assign> as_assign;
@ -453,7 +453,9 @@ public:
auto loc() -> location& { return loc_; }
auto is_special_stmt() -> bool;
auto is_special_stmt_dev() -> bool;
auto is_special_stmt_noif() -> bool;
auto is_special_stmt_dev_noif() -> bool;
auto is_binary() -> bool;
auto precedence() -> std::uint8_t;
@ -521,18 +523,6 @@ struct expr_vector : public node
friend bool operator==(const expr_vector& lhs, const expr_vector& rhs);
};
struct expr_color : public node
{
using ptr = std::unique_ptr<expr_color>;
std::string value;
expr_color(const std::string& value);
expr_color(const location& loc, const std::string& value);
auto print() const -> std::string override;
friend bool operator==(const expr_color& lhs, const expr_color& rhs);
};
struct expr_string : public node
{
using ptr = std::unique_ptr<expr_string>;
@ -1199,6 +1189,17 @@ struct stmt_list : public node
auto print() const -> std::string override;
};
struct stmt_dev : public node
{
using ptr = std::unique_ptr<stmt_dev>;
stmt_list::ptr list;
stmt_dev(stmt_list::ptr list);
stmt_dev(const location& loc, stmt_list::ptr list);
auto print() const -> std::string override;
};
struct stmt_expr : public node
{
using ptr = std::unique_ptr<stmt_expr>;

View File

@ -78,14 +78,14 @@ auto byte_buffer::read_c_string() -> std::string
auto byte_buffer::print_bytes(std::size_t pos, std::size_t count) -> std::string
{
std::string shit;
std::string data {};
for (auto i = pos; i < pos + count; i++)
{
shit += utils::string::va("%s %02X", shit.data(), (*reinterpret_cast<std::uint8_t*>(data_.data() + i)));
data = utils::string::va("%s %02X", data.data(), (*reinterpret_cast<std::uint8_t*>(data_.data() + i)));
}
return shit;
return data;
}
auto byte_buffer::pos() -> std::size_t
@ -93,6 +93,23 @@ auto byte_buffer::pos() -> std::size_t
return pos_;
}
void byte_buffer::pos(std::size_t pos)
{
if (pos >= 0 && pos <= size_)
{
pos_ = pos;
}
}
auto byte_buffer::align(std::size_t size) -> std::size_t
{
auto pos = pos_;
pos_ = (pos_ + (size - 1)) & ~(size - 1);
return pos_ - pos;
}
auto byte_buffer::buffer() -> std::vector<std::uint8_t>&
{
return data_;

View File

@ -77,6 +77,8 @@ public:
auto read_c_string() -> std::string;
auto print_bytes(std::size_t pos, std::size_t count) -> std::string;
auto pos() -> std::size_t;
void pos(std::size_t pos);
auto align(std::size_t size) -> std::size_t;
auto buffer() -> std::vector<std::uint8_t>&;
};