ExpressionType TranslateExpression(SequenceExpression e) { Types.Type type = Types.Type._void; ExpressionType et; ExpList el = null, ptr = null; for (ExpressionList h = e.Exps; h != null; h = h.Tail) { et = TranslateExpression(h.Head); type = et.Type; if (el == null) { el = ptr = new ExpList(et.Exp, null); } else { ptr = ptr.Tail = new ExpList(et.Exp, null); } } return(new ExpressionType(Translate.TranslateSeqExp(el, type.CoerceTo(Types.Type._void)), type)); }
ExpressionType TranslateExpression(OperatorExpression e) { ExpressionType eLeft = TranslateExpression(e.Left); ExpressionType eRight = TranslateExpression(e.Right); if (e.Op == Operator.Plus || e.Op == Operator.Minus || e.Op == Operator.Times || e.Op == Operator.Divide) { CheckInteger(e.Left.Pos, eLeft); CheckInteger(e.Right.Pos, eRight); return(new ExpressionType(Translate.TranslateCalculateExp((Tree.BINOP.Op)e.Op, eLeft.Exp, eRight.Exp), Types.Type._int)); } else if (e.Op == Operator.Equal || e.Op == Operator.NotEqual) { Types.Type ty = checkEqualType(e.Pos, eLeft, eRight); if (ty.CoerceTo(Types.Type._string)) { return(new ExpressionType(Translate.TranslateStringRelExp(ConvertOp(e.Op), eLeft.Exp, eRight.Exp), Types.Type._int)); } else { return(new ExpressionType(Translate.TranslateRelExp(ConvertOp(e.Op), eLeft.Exp, eRight.Exp), Types.Type._int)); } } else { Types.Type ty = CheckCmpType(e.Pos, eLeft, eRight); if (ty.CoerceTo(Types.Type._string)) { return(new ExpressionType(Translate.TranslateStringRelExp(ConvertOp(e.Op), eLeft.Exp, eRight.Exp), Types.Type._int)); } else { return(new ExpressionType(Translate.TranslateRelExp(ConvertOp(e.Op), eLeft.Exp, eRight.Exp), Types.Type._int)); } } }