Пример #1
0
 private void CodeUnary(UnaryExpression unary, List<LocalVariable> locals, List<GlobalVariable> globals, FuncParam[] parameters, ILGenerator il, List<Function> allFuncs, LocalBuilder tmpVar)
 {
     CodeExpression(unary.Expression, locals, globals, parameters, il, allFuncs, tmpVar);
     if (unary.Operator == Terminals.Minus)
         il.Emit(OpCodes.Neg);
     else
     {
         il.Emit(OpCodes.Ldc_I4_0);
         il.Emit(OpCodes.Ceq);
     }
 }
Пример #2
0
 private Expression SimExpr()
 {
     Expression ex = null;
     if (_la == Terminals.Minus || _la == Terminals.Inv)
     {
         var op = UnaryOp();
         var e = Expr();
         ex = new UnaryExpression(op, e);
     }
     else if (_la == Terminals.LPar)
     {
         Get();
         ex = Expr();
         Expect(Terminals.RPar);
     }
     else if (_la == Terminals.Num)
     {
         var num = _la as Num;
         Get();
         ex = new NumberExpression(num);
     }
     else if (_la == Terminals.Id)
     {
         if (IsAssign())
         {
             ex = Assign();
         }
         else
         {
             ex = Access();
         }
     }
     else SynErr(38);
     return ex;
 }