From f04f127680fff6f1a04e26f776d1f7d0ec87ece8 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Tue, 9 Apr 2019 22:21:20 +0300 Subject: Fix `as` operator generating opcode 38 errors Closes #27489 Fixup of 466a76ac2c7c6634ed1d78fde4ac011e2e70b710 Additionally, update `GDScriptCompiler` test to use Ref and to include `as` expressions. --- main/tests/test_gdscript.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'main/tests/test_gdscript.cpp') diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 8c60b79200..87bd640001 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -288,6 +288,11 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } } + } break; + case GDScriptParser::Node::TYPE_CAST: { + const GDScriptParser::CastNode *cast_node = static_cast(p_expr); + txt = _parser_expr(cast_node->source_node) + " as " + cast_node->cast_type.to_string(); + } break; case GDScriptParser::Node::TYPE_NEWLINE: { @@ -668,6 +673,17 @@ static void _disassemble_class(const Ref &p_class, const Vector gds; + gds.instance(); GDScriptCompiler gdc; - err = gdc.compile(&parser, script); + err = gdc.compile(&parser, gds.ptr()); if (err) { print_line("Compile Error:\n" + itos(gdc.get_error_line()) + ":" + itos(gdc.get_error_column()) + ":" + gdc.get_error()); - memdelete(script); return NULL; } - Ref gds = Ref(script); - Ref current = gds; while (current.is_valid()) { -- cgit v1.2.3