public override IExpression Visit(IExpression expression) { Pop pop = expression as Pop; if (pop != null) { if (this.numberOfPopsToIgnore-- > 0) { return(expression); } PushStatement push = (PushStatement)this.statements[this.i++]; if (pop is PopAsUnsigned) { return(new ConvertToUnsigned(push.ValueToPush)); } else { return(push.ValueToPush); } } return(base.Visit(expression)); }
public override IExpression Visit(IExpression expression) { Pop /*?*/ pop = expression as Pop; if (pop != null) { if (this.operandStack.Count > 0) { var local = this.operandStack.Pop(); if (pop.Type.TypeCode == PrimitiveTypeCode.Boolean && !(local.Type is Dummy)) { return(new NotEquality() { LeftOperand = new BoundExpression() { Definition = local }, RightOperand = new DefaultValue() { DefaultValueType = local.Type }, Type = pop.Type }); } if (!(pop.Type is Dummy)) { local.Type = pop.Type; } this.body.numberOfReferences[local]++; IExpression result; if (local.turnIntoPopValueExpression) { result = new PopValue() { Type = local.Type } } ; else { result = new BoundExpression() { Definition = local, Type = local.Type } }; if (pop is PopAsUnsigned) { result = new ConvertToUnsigned(result); } return(result); } else { // popping the unnamed exception in a catch block. return(pop); } } Dup /*?*/ dup = expression as Dup; if (dup != null) { if (this.operandStack.Count > 0) { var local = this.operandStack.Peek(); this.body.numberOfReferences[local]++; IExpression result; if (local.turnIntoPopValueExpression) { result = new DupValue() { Type = local.Type } } ; else { result = new BoundExpression() { Definition = local, Type = local.Type } }; //TODO: what about unsigned dup? return(result); } return(CodeDummy.Expression); } return(base.Visit(expression)); }