|
@@ -442,6 +442,27 @@ static DataType cInvertSign(DataType dt) {
|
|
}
|
|
}
|
|
|
|
|
|
static DataType cPreUnary() {
|
|
static DataType cPreUnary() {
|
|
|
|
+ int marker = tGetMarker();
|
|
|
|
+ if(cConsumeTokenIf(T_OPEN_BRACKET)) {
|
|
|
|
+ if(cConsumeTokenIf(T_FLOAT) && cConsumeTokenIf(T_CLOSE_BRACKET)) {
|
|
|
|
+ DataType dt = cUnpack(cPreUnary());
|
|
|
|
+ if(dtCompare(dt, dtInt())) {
|
|
|
|
+ cAddOperation(OP_INT_TO_FLOAT);
|
|
|
|
+ } else {
|
|
|
|
+ cError("cannot cast %s to float", cGetName(dt));
|
|
|
|
+ }
|
|
|
|
+ return dtFloat();
|
|
|
|
+ } else if(cConsumeTokenIf(T_INT) && cConsumeTokenIf(T_CLOSE_BRACKET)) {
|
|
|
|
+ DataType dt = cUnpack(cPreUnary());
|
|
|
|
+ if(dtCompare(dt, dtFloat())) {
|
|
|
|
+ cAddOperation(OP_FLOAT_TO_INT);
|
|
|
|
+ } else {
|
|
|
|
+ cError("cannot cast %s to int", cGetName(dt));
|
|
|
|
+ }
|
|
|
|
+ return dtInt();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ tReset(marker);
|
|
if(cConsumeTokenIf(T_INCREMENT)) {
|
|
if(cConsumeTokenIf(T_INCREMENT)) {
|
|
return cPreChange(cPreUnary(), 1, "++");
|
|
return cPreChange(cPreUnary(), 1, "++");
|
|
} else if(cConsumeTokenIf(T_DECREMENT)) {
|
|
} else if(cConsumeTokenIf(T_DECREMENT)) {
|