Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bool instead of int for the new parameter in Expression::optimize() #1299

Merged
merged 1 commit into from
Nov 18, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ struct Expression : Object

Expression *toDelegate(Scope *sc, Type *t);

virtual Expression *optimize(int result, int keepLvalue = 0);
virtual Expression *optimize(int result, bool keepLvalue = false);
#define WANTflags 1
#define WANTvalue 2
// A compile-time result is required. Give an error if not possible
Expand Down Expand Up @@ -424,7 +424,7 @@ struct TupleExp : Expression
Expression *semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void checkEscape();
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expression *castTo(Scope *sc, Type *t);
elem *toElem(IRState *irs);
Expand All @@ -449,7 +449,7 @@ struct ArrayLiteralExp : Expression
StringExp *toString();
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toMangleBuffer(OutBuffer *buf);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
MATCH implicitConvTo(Type *t);
Expression *castTo(Scope *sc, Type *t);
Expand All @@ -475,7 +475,7 @@ struct AssocArrayLiteralExp : Expression
elem *toElem(IRState *irs);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toMangleBuffer(OutBuffer *buf);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
MATCH implicitConvTo(Type *t);
Expression *castTo(Scope *sc, Type *t);
Expand Down Expand Up @@ -509,7 +509,7 @@ struct StructLiteralExp : Expression
elem *toElem(IRState *irs);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void toMangleBuffer(OutBuffer *buf);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
dt_t **toDt(dt_t **pdt);
MATCH implicitConvTo(Type *t);
Expand All @@ -528,7 +528,7 @@ struct TypeExp : Expression
Expression *semantic(Scope *sc);
int rvalue();
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
elem *toElem(IRState *irs);
};

Expand Down Expand Up @@ -571,7 +571,7 @@ struct NewExp : Expression
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
MATCH implicitConvTo(Type *t);
elem *toElem(IRState *irs);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expand Down Expand Up @@ -637,7 +637,7 @@ struct VarExp : SymbolExp
VarExp(Loc loc, Declaration *var, int hasOverloads = 0);
int equals(Object *o);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void dump(int indent);
char *toChars();
Expand Down Expand Up @@ -775,7 +775,7 @@ struct UnaExp : Expression
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
void dump(int indent);
Expression *interpretCommon(InterState *istate, CtfeGoal goal,
Expression *(*fp)(Type *, Expression *));
Expand All @@ -801,7 +801,7 @@ struct BinExp : Expression
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *scaleFactor(Scope *sc);
Expression *typeCombine(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
int isunsigned();
Expression *incompatibleTypes();
void dump(int indent);
Expand Down Expand Up @@ -904,7 +904,7 @@ struct DotVarExp : UnaExp
int isLvalue();
Expression *toLvalue(Scope *sc, Expression *e);
Expression *modifiableLvalue(Scope *sc, Expression *e);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void dump(int indent);
Expand Down Expand Up @@ -965,7 +965,7 @@ struct CallExp : UnaExp
int apply(apply_fp_t fp, void *param);
Expression *resolveUFCS(Scope *sc);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void dump(int indent);
Expand All @@ -988,7 +988,7 @@ struct AddrExp : UnaExp
elem *toElem(IRState *irs);
MATCH implicitConvTo(Type *t);
Expression *castTo(Scope *sc, Type *t);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
};

Expand All @@ -1004,7 +1004,7 @@ struct PtrExp : UnaExp
Expression *modifiableLvalue(Scope *sc, Expression *e);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
elem *toElem(IRState *irs);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);

// For operator overloading
Expand All @@ -1015,7 +1015,7 @@ struct NegExp : UnaExp
{
NegExp(Loc loc, Expression *e);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1040,7 +1040,7 @@ struct ComExp : UnaExp
{
ComExp(Loc loc, Expression *e);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1056,7 +1056,7 @@ struct NotExp : UnaExp
{
NotExp(Loc loc, Expression *e);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
int isBit();
elem *toElem(IRState *irs);
Expand All @@ -1066,7 +1066,7 @@ struct BoolExp : UnaExp
{
BoolExp(Loc loc, Expression *e, Type *type);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
int isBit();
elem *toElem(IRState *irs);
Expand All @@ -1093,7 +1093,7 @@ struct CastExp : UnaExp
Expression *semantic(Scope *sc);
MATCH implicitConvTo(Type *t);
IntRange getIntRange();
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void checkEscape();
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expand Down Expand Up @@ -1137,7 +1137,7 @@ struct SliceExp : UnaExp
Expression *modifiableLvalue(Scope *sc, Expression *e);
int isBool(int result);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void dump(int indent);
elem *toElem(IRState *irs);
Expand All @@ -1152,7 +1152,7 @@ struct ArrayLengthExp : UnaExp
{
ArrayLengthExp(Loc loc, Expression *e1);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
elem *toElem(IRState *irs);
Expand Down Expand Up @@ -1208,7 +1208,7 @@ struct CommaExp : BinExp
MATCH implicitConvTo(Type *t);
Expression *addDtorHook(Scope *sc);
Expression *castTo(Scope *sc, Type *t);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
elem *toElem(IRState *irs);
};
Expand All @@ -1226,7 +1226,7 @@ struct IndexExp : BinExp
Expression *toLvalue(Scope *sc, Expression *e);
Expression *modifiableLvalue(Scope *sc, Expression *e);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
Expression *doInline(InlineDoState *ids);

Expand Down Expand Up @@ -1326,7 +1326,7 @@ struct AddExp : BinExp
{
AddExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1344,7 +1344,7 @@ struct MinExp : BinExp
{
MinExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1361,7 +1361,7 @@ struct CatExp : BinExp
{
CatExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);

// For operator overloading
Expand All @@ -1375,7 +1375,7 @@ struct MulExp : BinExp
{
MulExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1393,7 +1393,7 @@ struct DivExp : BinExp
{
DivExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1410,7 +1410,7 @@ struct ModExp : BinExp
{
ModExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1428,7 +1428,7 @@ struct PowExp : BinExp
{
PowExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1445,7 +1445,7 @@ struct ShlExp : BinExp
{
ShlExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
IntRange getIntRange();

Expand All @@ -1460,7 +1460,7 @@ struct ShrExp : BinExp
{
ShrExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
IntRange getIntRange();

Expand All @@ -1475,7 +1475,7 @@ struct UshrExp : BinExp
{
UshrExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
IntRange getIntRange();

Expand All @@ -1490,7 +1490,7 @@ struct AndExp : BinExp
{
AndExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1508,7 +1508,7 @@ struct OrExp : BinExp
{
OrExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1527,7 +1527,7 @@ struct XorExp : BinExp
{
XorExp(Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
Expression *buildArrayLoop(Parameters *fparams);
Expand All @@ -1548,7 +1548,7 @@ struct OrOrExp : BinExp
Expression *semantic(Scope *sc);
Expression *checkToBoolean(Scope *sc);
int isBit();
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
elem *toElem(IRState *irs);
};
Expand All @@ -1559,7 +1559,7 @@ struct AndAndExp : BinExp
Expression *semantic(Scope *sc);
Expression *checkToBoolean(Scope *sc);
int isBit();
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
elem *toElem(IRState *irs);
};
Expand All @@ -1568,7 +1568,7 @@ struct CmpExp : BinExp
{
CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
int isBit();

Expand Down Expand Up @@ -1608,7 +1608,7 @@ struct EqualExp : BinExp
{
EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
int isBit();

Expand All @@ -1627,7 +1627,7 @@ struct IdentityExp : BinExp
IdentityExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
Expression *semantic(Scope *sc);
int isBit();
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
elem *toElem(IRState *irs);
};
Expand All @@ -1642,7 +1642,7 @@ struct CondExp : BinExp
Expression *syntaxCopy();
int apply(apply_fp_t fp, void *param);
Expression *semantic(Scope *sc);
Expression *optimize(int result, int keepLvalue = 0);
Expression *optimize(int result, bool keepLvalue = false);
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
void checkEscape();
void checkEscapeRef();
Expand Down