-add breakpoint statement to ease with debugging, closes #3165
This commit is contained in:
parent
99736e63e4
commit
7d2d1442f8
|
@ -1156,6 +1156,10 @@ Error GDCompiler::_parse_block(CodeGen& codegen,const GDParser::BlockNode *p_blo
|
||||||
codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT);
|
codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT);
|
||||||
codegen.opcodes.push_back(ret);
|
codegen.opcodes.push_back(ret);
|
||||||
} break;
|
} break;
|
||||||
|
case GDParser::Node::TYPE_BREAKPOINT: {
|
||||||
|
// try subblocks
|
||||||
|
codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT);
|
||||||
|
} break;
|
||||||
case GDParser::Node::TYPE_LOCAL_VAR: {
|
case GDParser::Node::TYPE_LOCAL_VAR: {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1862,6 +1862,17 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case GDTokenizer::TK_PR_BREAKPOINT: {
|
||||||
|
|
||||||
|
tokenizer->advance();
|
||||||
|
BreakpointNode *bn = alloc_node<BreakpointNode>();
|
||||||
|
p_block->statements.push_back(bn);
|
||||||
|
|
||||||
|
if (!_end_statement()) {
|
||||||
|
_set_error("Expected end of statement after breakpoint.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
Node *expression = _parse_and_reduce_expression(p_block,p_static,false,true);
|
Node *expression = _parse_and_reduce_expression(p_block,p_static,false,true);
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
TYPE_CONTROL_FLOW,
|
TYPE_CONTROL_FLOW,
|
||||||
TYPE_LOCAL_VAR,
|
TYPE_LOCAL_VAR,
|
||||||
TYPE_ASSERT,
|
TYPE_ASSERT,
|
||||||
|
TYPE_BREAKPOINT,
|
||||||
TYPE_NEWLINE,
|
TYPE_NEWLINE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -276,6 +277,10 @@ public:
|
||||||
AssertNode() { type=TYPE_ASSERT; }
|
AssertNode() { type=TYPE_ASSERT; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BreakpointNode : public Node {
|
||||||
|
BreakpointNode() { type=TYPE_BREAKPOINT; }
|
||||||
|
};
|
||||||
|
|
||||||
struct NewLineNode : public Node {
|
struct NewLineNode : public Node {
|
||||||
NewLineNode() { type=TYPE_NEWLINE; }
|
NewLineNode() { type=TYPE_NEWLINE; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -1077,6 +1077,14 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
|
||||||
|
|
||||||
ip+=2;
|
ip+=2;
|
||||||
} continue;
|
} continue;
|
||||||
|
case OPCODE_BREAKPOINT: {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
if (ScriptDebugger::get_singleton()) {
|
||||||
|
GDScriptLanguage::get_singleton()->debug_break("Breakpoint Statement",true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ip+=1;
|
||||||
|
} continue;
|
||||||
case OPCODE_LINE: {
|
case OPCODE_LINE: {
|
||||||
CHECK_SPACE(2);
|
CHECK_SPACE(2);
|
||||||
|
|
||||||
|
@ -2672,6 +2680,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
|
||||||
"or",
|
"or",
|
||||||
"export",
|
"export",
|
||||||
"assert",
|
"assert",
|
||||||
|
"breakpoint",
|
||||||
"yield",
|
"yield",
|
||||||
"static",
|
"static",
|
||||||
"float",
|
"float",
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
OPCODE_ITERATE_BEGIN,
|
OPCODE_ITERATE_BEGIN,
|
||||||
OPCODE_ITERATE,
|
OPCODE_ITERATE,
|
||||||
OPCODE_ASSERT,
|
OPCODE_ASSERT,
|
||||||
|
OPCODE_BREAKPOINT,
|
||||||
OPCODE_LINE,
|
OPCODE_LINE,
|
||||||
OPCODE_END
|
OPCODE_END
|
||||||
};
|
};
|
||||||
|
|
|
@ -98,6 +98,7 @@ const char* GDTokenizer::token_names[TK_MAX]={
|
||||||
"assert",
|
"assert",
|
||||||
"yield",
|
"yield",
|
||||||
"signal",
|
"signal",
|
||||||
|
"breakpoint",
|
||||||
"'['",
|
"'['",
|
||||||
"']'",
|
"']'",
|
||||||
"'{'",
|
"'{'",
|
||||||
|
@ -861,6 +862,7 @@ void GDTokenizerText::_advance() {
|
||||||
{TK_PR_ASSERT,"assert"},
|
{TK_PR_ASSERT,"assert"},
|
||||||
{TK_PR_YIELD,"yield"},
|
{TK_PR_YIELD,"yield"},
|
||||||
{TK_PR_SIGNAL,"signal"},
|
{TK_PR_SIGNAL,"signal"},
|
||||||
|
{TK_PR_BREAKPOINT,"breakpoint"},
|
||||||
{TK_PR_CONST,"const"},
|
{TK_PR_CONST,"const"},
|
||||||
//controlflow
|
//controlflow
|
||||||
{TK_CF_IF,"if"},
|
{TK_CF_IF,"if"},
|
||||||
|
@ -1041,7 +1043,7 @@ void GDTokenizerText::advance(int p_amount) {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define BYTECODE_VERSION 6
|
#define BYTECODE_VERSION 7
|
||||||
|
|
||||||
Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) {
|
Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) {
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
TK_PR_ASSERT,
|
TK_PR_ASSERT,
|
||||||
TK_PR_YIELD,
|
TK_PR_YIELD,
|
||||||
TK_PR_SIGNAL,
|
TK_PR_SIGNAL,
|
||||||
|
TK_PR_BREAKPOINT,
|
||||||
TK_BRACKET_OPEN,
|
TK_BRACKET_OPEN,
|
||||||
TK_BRACKET_CLOSE,
|
TK_BRACKET_CLOSE,
|
||||||
TK_CURLY_BRACKET_OPEN,
|
TK_CURLY_BRACKET_OPEN,
|
||||||
|
|
Loading…
Reference in a new issue