uniblab

example operator: add

Dec 4th, 2020
792
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static Icod.Collections.Immutable.IStack<Type> Add( Icod.Collections.Immutable.IStack<Type> stack ) {
  2.     var a = stack.Peek();
  3.     stack = stack.Pop();
  4.     var b = stack.Peek();
  5.     stack = stack.Pop();
  6.     var q = ( ( a.Value is System.Decimal ) || ( b.Value is System.Decimal ) )
  7.         ? Type.CreateDecimal( System.Convert.ToDecimal( b.Value ) + System.Convert.ToDecimal( a.Value ) )
  8.         : ( ( a.Value is System.Single ) || ( b.Value is System.Single ) )
  9.             ? Type.CreateSingle( System.Convert.ToSingle( b.Value ) + System.Convert.ToSingle( a.Value ) )
  10.             : Type.CreateInt( System.Convert.ToInt32( b.Value ) + System.Convert.ToInt32( a.Value ) )
  11.     ;
  12.     stack = stack.Push( q );
  13.     return stack;
  14. }
RAW Paste Data