Move Variant::evaluate() switch to computed goto

In an effort to make GDScript a little faster replace the double
switch() with a computed goto on compilers that set __GNUC__. For
compilers that don't support computed goto it will fall back to regular
switch/case statements.

In addition disable using boolean values in a mathematical context. Now
boolean values can only be compared with other booleans. Booleans will
also no longer be coerced to integers.

This PR replaces #11308 and fixes #11291
This commit is contained in:
Hein-Pieter van Braam
2017-09-17 02:32:05 +02:00
parent 7655587efb
commit 137f8a58a8
8 changed files with 1001 additions and 722 deletions

View File

@ -70,6 +70,7 @@ typedef PoolVector<Color> PoolColorArray;
class Variant {
public:
// If this changes the table in variant_op must be updated
enum Type {
NIL,
@ -288,6 +289,7 @@ public:
Variant(const IP_Address &p_address);
// If this changes the table in variant_op must be updated
enum Operator {
//comparation
@ -299,7 +301,7 @@ public:
OP_GREATER_EQUAL,
//mathematic
OP_ADD,
OP_SUBSTRACT,
OP_SUBTRACT,
OP_MULTIPLY,
OP_DIVIDE,
OP_NEGATE,