public Operation.UnaryOperationDelegate GetUnaryOperation(Token.Type op, Type t0) { Dictionary <ulong, Operation.UnaryOperationDelegate> operatorMap = null; if (_unaryOperators.TryGetValue(op, out operatorMap)) { Operation.UnaryOperationDelegate del = null; if (operatorMap.TryGetValue((ulong)(uint)t0.GetHashCode(), out del)) { return(del); } } return(null); }
protected virtual object CompileUnary() { if (MatchToken(Token.Type.Not, Token.Type.Subtraction)) { Token op = previous; object right = CompileUnary(); Type rightType = CompilerUtility.GetReturnType(right); Operation.UnaryOperationDelegate del = _assembly.GetUnaryOperation(op.type, rightType); if (del == null) { throw new Exception("Cannot perform the operation " + op.text + " on " + rightType.Name); } return(del.Invoke(right, _cdata)); } return(CompileCast()); }
protected virtual object CompilePostUnary() { object left = CompileFunctionCall(); object output = null; if (MatchToken(Token.Type.Increment, Token.Type.Decrement)) { Token op = previous; Type leftType = CompilerUtility.GetReturnType(left); Operation.UnaryOperationDelegate del = _assembly.GetUnaryOperation(op.type, leftType); if (del == null) { throw new Exception("Cannot perform the operation " + op.text + " on " + leftType.Name); } return(del.Invoke(left, _cdata)); } return((output != null) ? (object)output : left); }