1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Fix as operator generating opcode 38 errors

Closes #27489
Fixup of 466a76ac2c

Additionally, update `GDScriptCompiler` test to use Ref and to include `as` expressions.
This commit is contained in:
Bojidar Marinov
2019-04-09 22:21:20 +03:00
parent f75b9e6246
commit f04f127680
2 changed files with 37 additions and 10 deletions

View File

@@ -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<const GDScriptParser::CastNode *>(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<GDScript> &p_class, const Vector<String
txt += "= false";
incr += 2;
} break;
case GDScriptFunction::OPCODE_CAST_TO_SCRIPT: {
txt += " cast ";
txt += DADDR(3);
txt += "=";
txt += DADDR(1);
txt += " as ";
txt += DADDR(2);
incr += 4;
} break;
case GDScriptFunction::OPCODE_CONSTRUCT: {
@@ -1018,19 +1034,17 @@ MainLoop *test(TestType p_type) {
return NULL;
}
GDScript *script = memnew(GDScript);
Ref<GDScript> 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<GDScript> gds = Ref<GDScript>(script);
Ref<GDScript> current = gds;
while (current.is_valid()) {