script optimization fixes:

new initialization model for standalone C++ scripts
 type coercion fix
 ZAM fix for compiling using C++ optimizer
 disambiguate empty constructors
This commit is contained in:
Vern Paxson 2022-11-20 12:16:25 -08:00
parent dbb2aa88a6
commit 134f8f2ef5
14 changed files with 80 additions and 96 deletions

View file

@ -869,7 +869,13 @@ string CPPCompile::GenUnary(const Expr* e, GenType gt, const char* op, const cha
if ( e->GetType()->Tag() == TYPE_VECTOR )
return GenVectorOp(e, GenExpr(e->GetOp1(), GEN_NATIVE), vec_op);
return NativeToGT(string(op) + "(" + GenExpr(e->GetOp1(), GEN_NATIVE) + ")", e->GetType(), gt);
// Look for coercions that the interpreter does implicitly.
auto op1 = e->GetOp1();
if ( op1->GetType()->Tag() == TYPE_COUNT &&
(e->Tag() == EXPR_POSITIVE || e->Tag() == EXPR_NEGATE) )
op1 = make_intrusive<ArithCoerceExpr>(op1, TYPE_INT);
return NativeToGT(string(op) + "(" + GenExpr(op1, GEN_NATIVE) + ")", e->GetType(), gt);
}
string CPPCompile::GenBinary(const Expr* e, GenType gt, const char* op, const char* vec_op)