public static string OperatorToString(UnaryOperator @operator) { string operatorString; if (!PrefixUnaryOperatorMapping.TryGetValue(@operator, out operatorString) && !PostUnaryOperatorMapping.TryGetValue(@operator, out operatorString)) throw new ArgumentException("Operator does not exist in the C# language."); return operatorString; }
public UnaryExpression(IExpression theExpression, UnaryOperator unaryOperator) { if ((object)theExpression == null) throw new ArgumentNullException(nameof(theExpression)); this.theExpression = theExpression; this.unaryOperator = unaryOperator; }
/// <summary> /// Initializes a new instance of the <see cref="UnaryFormula" /> class. /// </summary> /// <param name="operand">The operand of the unary formula.</param> /// <param name="unaryOperator">The operator of the unary formula.</param> internal UnaryFormula(Formula operand, UnaryOperator unaryOperator) { Requires.NotNull(operand, nameof(operand)); Requires.InRange(unaryOperator, nameof(unaryOperator)); Operand = operand; Operator = unaryOperator; }
public void ExtractMethodName() { var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, ""); CriteriaOperatorExtractor binaryOperatorExtractor = GetBinaryOperatorExtractor(unaryOperator); Assert.AreEqual(unaryOperator, binaryOperatorExtractor.UnaryOperators[0]); }
public AstUnaryOperator(ISourcePosition position, UnaryOperator op, AstExpr operand) : base(position) { if (operand == null) throw new ArgumentNullException("operand"); _operator = op; _operand = operand; }
public object Visit(UnaryOperator theOperator) { switch (theOperator.OperatorType) { case UnaryOperatorType.IsNull: UpdatePropertyName(theOperator.Operand); break; case UnaryOperatorType.Not: theOperator.Operand.Accept(this); break; } return theOperator; }
public virtual bool VisitUnaryOperator(UnaryOperator stmt) { if (!VisitExpr(stmt)) { return(false); } return(true); }
public static object Operate(UnaryOperator @operator, object x) { if (!unaryOperatorHandlers.ContainsKey(@operator)) { throw new UnexpectedEnumValueException <UnaryOperator>(@operator); } return(unaryOperatorHandlers[@operator].Operate(x)); }
public static UnaryOperatorHandler GetHandler(UnaryOperator @operator) { if (unaryOperatorHandlers.ContainsKey(@operator)) { return(unaryOperatorHandlers[@operator]); } throw new UnexpectedEnumValueException <UnaryOperator>(@operator); }
public override IType UnaryOperation(UnaryOperator op, SourceRange source, DiagnosticsReport diagnostics) { if (op is UnaryOperator.Negate) { return(new VectorType(source)); } return(base.UnaryOperation(op, source, diagnostics)); }
public virtual CriteriaOperator Visit(UnaryOperator theOperator) { CriteriaOperator operand = theOperator.Operand.Accept <CriteriaOperator>(this); if (object.ReferenceEquals(operand, null)) { return(null); } return(new UnaryOperator(theOperator.OperatorType, operand)); }
public override void ExitUnaryExpression([NotNull] PigeonParser.UnaryExpressionContext context) { var operandType = Types.Get(context.expr()); if (!UnaryOperator.TryGetResType(context.op.Text, operandType, out var type)) { errorBag.ReportInvalidTypeUnaryOperator(context.op.GetTextSpan(), context.op.Text, type); } Types.Put(context, type); }
public UnaryBooleanExpression(UnaryOperator operatorKind, Expression operand) { this.SetSourceContext(operand); if ((int)operatorKind != 0) { throw new Exception($"{operatorKind} is not logical."); } this.OperatorKind = operatorKind; this.AddNode(operand); }
public static bool IsUnary(Expression exp, out UnaryOperator op, out Expression arg, Decoder decoder) { VisitorForIsUnaryExpression visitor = decoder.visitorForIsUnaryExpression; bool result = Decode(exp, visitor, decoder); op = visitor.Operator; arg = visitor.Argument; return(result); }
public void RemoveRootOperator() { CriteriaOperator unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2"); var binaryOperatorExtractor = new CriteriaOperatorExtractor(); binaryOperatorExtractor.Remove(ref unaryOperator, unaryOperator.ToString()); Assert.IsNull(unaryOperator); }
public override void VisitUnaryExpression(UnaryExpression node) { if (this.methodInvocationsStackCount == 0 && node.get_Operand() as ArgumentReferenceExpression == null && node.get_Operator() == 8 || node.get_Operator() == 7 || node.get_Operator() == 9) { this.IsAddressUnaryOperatorFound = true; this.FoundUnaryOperator = node.get_Operator(); } this.VisitUnaryExpression(node); return; }
public AbcMethod Build(UnaryOperator op, IType type) { var method = Find(op, type); if (method == null) { throw new InvalidOperationException(); } return(BuildUnary(method)); }
public UnaryExpression(List <Token> tokens) { Type = SyntaxNodeType.UnaryExpression; Operator = new Dictionary <TokenForm, UnaryOperator>() { { TokenForm.Not, UnaryOperator.Not }, { TokenForm.Address, UnaryOperator.Address } }[tokens[0].Form]; Expression = Expression.ParseExpression(tokens.GetRange(1, tokens.Count - 1)); }
public UnaryArithExpression(UnaryOperator prefixOperatorKind, Expression operand) { this.SetSourceContext(operand); if ((int)prefixOperatorKind < 1 && (int)prefixOperatorKind > 3) { throw new Exception($"{prefixOperatorKind} is not prefix or arithmetical."); } this.OperatorKind = prefixOperatorKind; this.AddNode(operand); }
public virtual void Visit(UnaryOperator node) { if (node != null) { if (node.Operand != null) { node.Operand.Accept(this); } } }
public UnaryArithExpression(Expression operand, UnaryOperator postfixOperatorKind, bool postfix = true) { this.SetSourceContext(operand); if ((int)postfixOperatorKind < 4) { throw new Exception($"{postfixOperatorKind} is not postfix or arithmetical."); } this.OperatorKind = postfixOperatorKind; this.AddNode(operand); }
public ReadOnlyUnaryOperator(UnaryOperator unaryOperator) { this.unaryOperator = unaryOperator; body = new ReadOnlyMethodBody(unaryOperator.Body); parameters = new ReadOnlyOperatorParameter[] { new ReadOnlyOperatorParameter(unaryOperator.ParameterName, unaryOperator.ParameterType) }; returnType = new ReadOnlyTypeReference(unaryOperator.ReturnType); }
static string ToString(UnaryOperator op) { switch (op) { case UnaryOperator.BitwiseComplement: return("~"); case UnaryOperator.Not: return("!"); } throw new ArgumentException(op.ToString(), "op"); }
protected virtual CriteriaOperator VisitUnary(UnaryOperator theOperator) { CriteriaOperator operand = this.AcceptOperator(theOperator.Operand); if (object.ReferenceEquals(theOperator.Operand, operand)) { return(theOperator); } return(new UnaryOperator(theOperator.OperatorType, operand)); }
public override void VisitUnaryExpression(UnaryExpression node) { if ((this.methodInvocationsStackCount == 0 && !(node.Operand is ArgumentReferenceExpression)) && (node.Operator == UnaryOperator.AddressDereference || node.Operator == UnaryOperator.AddressReference || node.Operator == UnaryOperator.AddressOf)) { this.IsAddressUnaryOperatorFound = true; this.FoundUnaryOperator = node.Operator; } base.VisitUnaryExpression(node); }
//----------------------------------------------------------------------- /// <summary> /// Obtains a {@code TemporalAdjuster} that wraps a date adjuster. /// <para> /// The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface. /// This method allows an adjustment from {@code LocalDate} to {@code LocalDate} /// to be wrapped to match the temporal-based interface. /// This is provided for convenience to make user-written adjusters simpler. /// </para> /// <para> /// In general, user-written adjusters should be static constants: /// <pre>{@code /// static TemporalAdjuster TWO_DAYS_LATER = /// TemporalAdjusters.ofDateAdjuster(date -> date.plusDays(2)); /// }</pre> /// /// </para> /// </summary> /// <param name="dateBasedAdjuster"> the date-based adjuster, not null </param> /// <returns> the temporal adjuster wrapping on the date adjuster, not null </returns> public static TemporalAdjuster OfDateAdjuster(UnaryOperator <LocalDate> dateBasedAdjuster) { Objects.RequireNonNull(dateBasedAdjuster, "dateBasedAdjuster"); //JAVA TO C# CONVERTER TODO TASK: Java lambdas satisfy functional interfaces, while .NET lambdas satisfy delegates - change the appropriate interface to a delegate: return((temporal) => { LocalDate input = LocalDate.From(temporal); LocalDate output = dateBasedAdjuster.Apply(input); return temporal.with(output); }); }
/// <summary> /// Atomically updates the field of the given object managed by this updater /// with the results of applying the given function, returning the updated /// value. The function should be side-effect-free, since it may be /// re-applied when attempted updates fail due to contention among threads. /// </summary> /// <param name="obj"> An object whose field to get and set </param> /// <param name="updateFunction"> a side-effect-free function </param> /// <returns> the updated value /// @since 1.8 </returns> public V UpdateAndGet(T obj, UnaryOperator <V> updateFunction) { V prev, next; do { prev = Get(obj); next = updateFunction.Apply(prev); } while (!CompareAndSet(obj, prev, next)); return(next); }
/// <summary> /// Atomically updates the current value with the results of /// applying the given function, returning the previous value. The /// function should be side-effect-free, since it may be re-applied /// when attempted updates fail due to contention among threads. /// </summary> /// <param name="updateFunction"> a side-effect-free function </param> /// <returns> the previous value /// @since 1.8 </returns> public V GetAndUpdate(UnaryOperator <V> updateFunction) { V prev, next; do { prev = Get(); next = updateFunction.Apply(prev); } while (!CompareAndSet(prev, next)); return(prev); }
public static object SerializeUnaryOperator(UnaryOperator op) { string s = ""; if (op == UnaryOperator.Negation) { s = "-"; } return(s); }
public static UnaryOperator GetPostfixOperator(string symbol, OperatorPosition position) { if (position == OperatorPosition.Above || position == OperatorPosition.Surrounding) { throw new System.Exception(nameof(position)); } var newOperator = new UnaryOperator(null, symbol, null, position); return(newOperator); }
public UnaryExpressionGenerator(GeneratorFactory factory, BlockGenerator block, UnaryExpressionSyntaxNode expr) : base(factory) { _operand = factory.CreateExpression(block, expr.Operand); _operator = expr.Operator; _type = expr.SpecializationType.GetVMSpecializationType(); if (!_operand.TryGetFromStack(out _)) { _tmpSlot = block.TempAllocator.Allocate(_operand.GetSingleType()); } }
internal static string OperatorToString(UnaryOperator op) { switch (op) { case UnaryOperator.Not: return("NOT"); default: throw new InvalidEnumArgumentException("op", (int)op, typeof(UnaryOperator)); } }
private void RewriteUnaryOp(UnaryOperator op) { var opDst = this.Operand(Dst); var opSrc = this.Operand(Src1); ConditionalAssign(opDst, new UnaryExpression(op, PrimitiveType.Word32, opSrc)); if (instr.ArchitectureDetail.UpdateFlags) { ConditionalAssign(frame.EnsureFlagGroup(A32Registers.cpsr, 0x1111, "SZCO", PrimitiveType.Byte), emitter.Cond(opDst)); } }
public void RemoveNestedOperator() { var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2"); CriteriaOperator groupOperator = new GroupOperator(new BinaryOperator("pro1", 1), unaryOperator); var binaryOperatorExtractor = new CriteriaOperatorExtractor(); binaryOperatorExtractor.Remove(ref groupOperator, unaryOperator.ToString()); Assert.AreEqual(new BinaryOperator("pro1", 1).ToString(), groupOperator.ToString()); }
public UnaryOperatorExpressionSyntax( TextSpan span, UnaryOperatorFixity fixity, UnaryOperator @operator, IExpressionSyntax operand) : base(span, ExpressionSemantics.Copy) { Operator = @operator; this.operand = operand; Fixity = fixity; }
public void ReplaceRootOperator() { CriteriaOperator unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2"); var binaryOperatorExtractor = new CriteriaOperatorExtractor(); var replaceOperator = new BinaryOperator("pr", 1); binaryOperatorExtractor.Replace(ref unaryOperator, unaryOperator.ToString(), replaceOperator); Assert.AreEqual(unaryOperator, replaceOperator); }
public UnaryExpression(UnaryOperator @operator, Expression operand, IEnumerable<Instruction> instructions) :base(instructions) { this.Operator = @operator; this.Operand = operand; if (operand is UnaryExpression && @operator == UnaryOperator.None) { // flatten it this.Operand = (operand as UnaryExpression).Operand; this.Operator = (operand as UnaryExpression).Operator; this.instructions.AddRange((operand as UnaryExpression).instructions); } }
private string convertOperatorToString(UnaryOperator operation) { string result = ""; switch (operation) { case UnaryOperator.PLUS: { result = "+"; break; } case UnaryOperator.MINUS: { result = "-"; break; } case UnaryOperator.BINARY_NOT: { result = "~"; break; } } return result; }
// The following methods are used to insert methods to the bottom of the AST and convert operator to these method calls // to support replication on operators private static void InsertUnaryOperationMethod(Core core, CodeBlockNode root, UnaryOperator op, PrimitiveType r, PrimitiveType operand) { FunctionDefinitionNode funcDefNode = new FunctionDefinitionNode(); funcDefNode.Access = CompilerDefinitions.AccessModifier.Public; funcDefNode.IsAssocOperator = true; funcDefNode.IsBuiltIn = true; funcDefNode.Name = Op.GetUnaryOpFunction(op); funcDefNode.ReturnType = new Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r }; ArgumentSignatureNode args = new ArgumentSignatureNode(); args.AddArgument(new VarDeclNode() { Access = CompilerDefinitions.AccessModifier.Public, NameNode = AstFactory.BuildIdentifier("%param"), ArgumentType = new Type { Name = core.TypeSystem.GetType((int)operand), UID = (int)operand } }); funcDefNode.Signature = args; CodeBlockNode body = new CodeBlockNode(); IdentifierNode param = AstFactory.BuildIdentifier("%param"); body.Body.Add(AstFactory.BuildReturnStatement(new UnaryExpressionNode() { Expression = param, Operator = op })); funcDefNode.FunctionBody = body; root.Body.Add(funcDefNode); }
public override Object Visit(UnaryOperator theOperator) { return base.Visit(theOperator); }
void Imperative_negop(out UnaryOperator op) { Expect(15); op = UnaryOperator.Neg; }
protected abstract string ToString(UnaryOperator op);
public void ReplaceNestedOperator() { var unaryOperator = new UnaryOperator(UnaryOperatorType.BitwiseNot, "pro"); CriteriaOperator criteriaOperator = new GroupOperator(new BinaryOperator(), unaryOperator); var binaryOperatorExtractor = new CriteriaOperatorExtractor(); var notOperator = new NotOperator(); binaryOperatorExtractor.Replace(ref criteriaOperator, unaryOperator.ToString(), notOperator); Assert.AreEqual(((GroupOperator) criteriaOperator).Operands[1], notOperator); }
void Imperative_unaryop(out UnaryOperator op) { op = UnaryOperator.None; if (la.kind == 14) { Get(); op = UnaryOperator.Not; #if ENABLE_BIT_OP } else if (la.kind == 63) { Get(); op = UnaryOperator.Negate; #endif } else SynErr(116); }
ICodeNode BuildUnaryExpression (UnaryOperator @operator, Expression expression) { return new UnaryExpression (@operator, (Expression) Visit (expression)); }
private AssociativeNode GenerateUnaryOperatorMethodCallNode(UnaryOperator op, ProtoCore.AST.AssociativeAST.AssociativeNode operand) { FunctionCallNode funCallNode = new FunctionCallNode(); IdentifierNode funcName = new IdentifierNode { Value = ProtoCore.DSASM.Op.GetUnaryOpFunction(op), Name = ProtoCore.DSASM.Op.GetUnaryOpFunction(op) }; funCallNode.Function = funcName; funCallNode.Name = ProtoCore.DSASM.Op.GetUnaryOpFunction(op); funCallNode.FormalArguments.Add(operand); NodeUtils.CopyNodeLocation(funCallNode, operand); return funCallNode; }
ICodeNode BuildUnaryExpression(UnaryOperator @operator, Expression expression, IEnumerable<Instruction> instructions) { return new UnaryExpression(@operator, (Expression)codeTransformer.Visit(expression), instructions); }
static string ToString (UnaryOperator op) { switch (op) { case UnaryOperator.BitwiseNot: return "~"; case UnaryOperator.LogicalNot: return "!"; case UnaryOperator.Negate: return "-"; case UnaryOperator.PostDecrement: case UnaryOperator.PreDecrement: return "--"; case UnaryOperator.PostIncrement: case UnaryOperator.PreIncrement: return "++"; default: throw new ArgumentException (); } }
Object yyparse (yyInput yyLex) { if (yyMax <= 0) yyMax = 256; int yyState = 0; int [] yyStates = new int[yyMax]; Object yyVal = null; Object [] yyVals = new Object[yyMax]; int yyToken = -1; int yyErrorFlag = 0; int yyTop = 0; goto skip; yyLoop: yyTop++; skip: for(;; ++yyTop) { if(yyTop >= yyStates.Length) { int[] i = new int[yyStates.Length + yyMax]; yyStates.CopyTo(i, 0); yyStates = i; Object[] o = new Object[yyVals.Length + yyMax]; yyVals.CopyTo(o, 0); yyVals = o; } yyStates[yyTop] = yyState; yyVals[yyTop] = yyVal; yyDiscarded: for(;;) { int yyN; if ((yyN = yyDefRed[yyState]) == 0) { if(yyToken < 0) yyToken = yyLex.advance() ? yyLex.token() : 0; if((yyN = yySindex[yyState]) != 0 && ((yyN += yyToken) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyToken)) { yyState = yyTable[yyN]; yyVal = yyLex.value(); yyToken = -1; if (yyErrorFlag > 0) -- yyErrorFlag; goto yyLoop; } if((yyN = yyRindex[yyState]) != 0 && (yyN += yyToken) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == yyToken) yyN = yyTable[yyN]; else switch(yyErrorFlag) { case 0: yyerror("syntax error"); goto case 1; case 1: case 2: yyErrorFlag = 3; do { if((yyN = yySindex[yyStates[yyTop]]) != 0 && (yyN += Token.yyErrorCode) >= 0 && yyN < yyTable.Length && yyCheck[yyN] == Token.yyErrorCode) { yyState = yyTable[yyN]; yyVal = yyLex.value(); goto yyLoop; } } while (--yyTop >= 0); yyerror("irrecoverable syntax error"); goto yyDiscarded; case 3: if (yyToken == 0) yyerror("irrecoverable syntax error at end-of-file"); yyToken = -1; goto yyDiscarded; } } int yyV = yyTop + 1 - yyLen[yyN]; yyVal = yyV > yyTop ? null : yyVals[yyV]; switch(yyN) { case 1: #line 54 "grammar.y" { result = new CriteriaOperator[0]; } break; case 2: #line 55 "grammar.y" { result = ((List<CriteriaOperator>)yyVals[-1+yyTop]).ToArray(); } break; case 3: #line 59 "grammar.y" { yyVal = new List<CriteriaOperator>(new CriteriaOperator[] {(CriteriaOperator)yyVals[0+yyTop]}); } break; case 4: #line 60 "grammar.y" { yyVal = yyVals[-2+yyTop]; ((List<CriteriaOperator>)yyVal).Add((CriteriaOperator)yyVals[0+yyTop]); } break; case 5: #line 64 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 6: #line 65 "grammar.y" { OperandProperty prop2 = (OperandProperty)yyVals[-2+yyTop]; OperandProperty prop4 = (OperandProperty)yyVals[0+yyTop]; prop2.PropertyName = '<' + prop2.PropertyName + '>' + prop4.PropertyName; yyVal = prop2; } break; case 7: #line 74 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 8: #line 75 "grammar.y" { yyVal = new OperandProperty("^"); } break; case 9: #line 79 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 10: #line 80 "grammar.y" { OperandProperty prop1 = (OperandProperty)yyVals[-2+yyTop]; OperandProperty prop3 = (OperandProperty)yyVals[0+yyTop]; prop1.PropertyName += '.' + prop3.PropertyName; yyVal = prop1; } break; case 11: #line 89 "grammar.y" { AggregateOperand agg = (AggregateOperand)yyVals[0+yyTop]; yyVal = JoinOperand.JoinOrAggreagate((OperandProperty)yyVals[-2+yyTop], null, agg.AggregateType, agg.AggregatedExpression); } break; case 12: #line 93 "grammar.y" { AggregateOperand agg = (AggregateOperand)yyVals[0+yyTop]; yyVal = JoinOperand.JoinOrAggreagate((OperandProperty)yyVals[-5+yyTop], (CriteriaOperator)yyVals[-3+yyTop], agg.AggregateType, agg.AggregatedExpression); } break; case 13: #line 97 "grammar.y" { AggregateOperand agg = (AggregateOperand)yyVals[0+yyTop]; yyVal = JoinOperand.JoinOrAggreagate((OperandProperty)yyVals[-4+yyTop], null, agg.AggregateType, agg.AggregatedExpression); } break; case 14: #line 101 "grammar.y" { yyVal = JoinOperand.JoinOrAggreagate((OperandProperty)yyVals[-3+yyTop], (CriteriaOperator)yyVals[-1+yyTop], Aggregate.Exists, null); } break; case 15: #line 102 "grammar.y" { yyVal = JoinOperand.JoinOrAggreagate((OperandProperty)yyVals[-2+yyTop], null, Aggregate.Exists, null); } break; case 18: #line 110 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)null, Aggregate.Count, null); } break; case 19: #line 111 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)null, Aggregate.Exists, null); } break; case 20: #line 112 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)null, Aggregate.Count, null); } break; case 21: #line 113 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)null, Aggregate.Exists, null); } break; case 22: #line 114 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)yyVals[-1+yyTop], Aggregate.Min, null); } break; case 23: #line 115 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)yyVals[-1+yyTop], Aggregate.Max, null); } break; case 24: #line 116 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)yyVals[-1+yyTop], Aggregate.Avg, null); } break; case 25: #line 117 "grammar.y" { yyVal = new AggregateOperand((OperandProperty)null, (CriteriaOperator)yyVals[-1+yyTop], Aggregate.Sum, null); } break; case 26: #line 121 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 27: #line 122 "grammar.y" { string paramName = (string)yyVals[0+yyTop]; if(string.IsNullOrEmpty(paramName)) { OperandValue param = new OperandValue(); resultParameters.Add(param); yyVal = param; } else { bool paramNotFound = true; foreach(OperandValue v in resultParameters) { OperandParameter p = v as OperandParameter; if(ReferenceEquals(p, null)) continue; if(p.ParameterName != paramName) continue; paramNotFound = false; resultParameters.Add(p); yyVal = p; break; } if(paramNotFound) { OperandParameter param = new OperandParameter(paramName); resultParameters.Add(param); yyVal = param; } } } break; case 28: #line 148 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 29: #line 149 "grammar.y" { yyVal = yyVals[0+yyTop]; } break; case 30: #line 150 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Multiply ); } break; case 31: #line 151 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Divide ); } break; case 32: #line 152 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Plus ); } break; case 33: #line 153 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Minus ); } break; case 34: #line 154 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Modulo ); } break; case 35: #line 155 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.BitwiseOr ); } break; case 36: #line 156 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.BitwiseAnd ); } break; case 37: #line 157 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.BitwiseXor ); } break; case 38: #line 158 "grammar.y" { yyVal = new UnaryOperator( UnaryOperatorType.Minus, (CriteriaOperator)yyVals[0+yyTop] ); try { if(yyVals[0+yyTop] is OperandValue) { OperandValue operand = (OperandValue)yyVals[0+yyTop]; if(operand.Value is Int32) { operand.Value = -(Int32)operand.Value; yyVal = operand; break; } else if(operand.Value is Int64) { operand.Value = -(Int64)operand.Value; yyVal = operand; break; } else if(operand.Value is Double) { operand.Value = -(Double)operand.Value; yyVal = operand; break; } else if(operand.Value is Decimal) { operand.Value = -(Decimal)operand.Value; yyVal = operand; break; } else if(operand.Value is Int16) { operand.Value = -(Int16)operand.Value; yyVal = operand; break; } else if(operand.Value is SByte) { operand.Value = -(SByte)operand.Value; yyVal = operand; break; } } } catch {} } break; case 39: #line 191 "grammar.y" { yyVal = new UnaryOperator( UnaryOperatorType.Plus, (CriteriaOperator)yyVals[0+yyTop] ); } break; case 40: #line 192 "grammar.y" { yyVal = new UnaryOperator( UnaryOperatorType.BitwiseNot, (CriteriaOperator)yyVals[0+yyTop] ); } break; case 41: #line 193 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Equal); } break; case 42: #line 194 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.NotEqual); } break; case 43: #line 195 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Greater); } break; case 44: #line 196 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Less); } break; case 45: #line 197 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.GreaterOrEqual); } break; case 46: #line 198 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.LessOrEqual); } break; case 47: #line 199 "grammar.y" { yyVal = new BinaryOperator( (CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Like); } break; case 48: #line 200 "grammar.y" { yyVal = new UnaryOperator(UnaryOperatorType.Not, new BinaryOperator( (CriteriaOperator)yyVals[-3+yyTop], (CriteriaOperator)yyVals[0+yyTop], BinaryOperatorType.Like)); } break; case 49: #line 201 "grammar.y" { yyVal = new UnaryOperator(UnaryOperatorType.Not, (CriteriaOperator)yyVals[0+yyTop]); } break; case 50: #line 202 "grammar.y" { yyVal = GroupOperator.And((CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop]); } break; case 51: #line 203 "grammar.y" { yyVal = GroupOperator.Or((CriteriaOperator)yyVals[-2+yyTop], (CriteriaOperator)yyVals[0+yyTop]); } break; case 52: #line 204 "grammar.y" { yyVal = yyVals[-1+yyTop]; } break; case 53: #line 205 "grammar.y" { yyVal = new UnaryOperator(UnaryOperatorType.IsNull, (CriteriaOperator)yyVals[-2+yyTop]); } break; case 54: #line 206 "grammar.y" { yyVal = new UnaryOperator(UnaryOperatorType.Not, new UnaryOperator(UnaryOperatorType.IsNull, (CriteriaOperator)yyVals[-3+yyTop])); } break; case 55: #line 207 "grammar.y" { yyVal = new InOperator((CriteriaOperator)yyVals[-2+yyTop], (IEnumerable<CriteriaOperator>)yyVals[0+yyTop]); } break; case 56: #line 208 "grammar.y" { yyVal = new BetweenOperator((CriteriaOperator)yyVals[-6+yyTop], (CriteriaOperator)yyVals[-3+yyTop], (CriteriaOperator)yyVals[-1+yyTop]); } break; case 57: #line 209 "grammar.y" { yyVal = new UnaryOperator(UnaryOperatorType.IsNull, (CriteriaOperator)yyVals[-1+yyTop]); } break; case 58: #line 210 "grammar.y" { yyVal = new FunctionOperator(FunctionOperatorType.IsNull, (CriteriaOperator)yyVals[-3+yyTop], (CriteriaOperator)yyVals[-1+yyTop]); } break; case 59: #line 211 "grammar.y" { FunctionOperator fo = new FunctionOperator((FunctionOperatorType)yyVals[-1+yyTop], (IEnumerable<CriteriaOperator>)yyVals[0+yyTop]); lexer.CheckFunctionArgumentsCount(fo.OperatorType, fo.Operands.Count); yyVal = fo; } break; case 60: #line 212 "grammar.y" { yyVal = null; } break; case 61: #line 216 "grammar.y" { yyVal = yyVals[-1+yyTop]; } break; case 62: #line 217 "grammar.y" { yyVal = new List<CriteriaOperator>(); } break; case 63: #line 221 "grammar.y" { List<CriteriaOperator> lst = new List<CriteriaOperator>(); lst.Add((CriteriaOperator)yyVals[0+yyTop]); yyVal = lst; } break; case 64: #line 226 "grammar.y" { List<CriteriaOperator> lst = (List<CriteriaOperator>)yyVals[-2+yyTop]; lst.Add((CriteriaOperator)yyVals[0+yyTop]); yyVal = lst; } break; #line default } yyTop -= yyLen[yyN]; yyState = yyStates[yyTop]; int yyM = yyLhs[yyN]; if(yyState == 0 && yyM == 0) { yyState = yyFinal; if(yyToken < 0) yyToken = yyLex.advance() ? yyLex.token() : 0; if(yyToken == 0) return yyVal; goto yyLoop; } if(((yyN = yyGindex[yyM]) != 0) && ((yyN += yyState) >= 0) && (yyN < yyTable.Length) && (yyCheck[yyN] == yyState)) yyState = yyTable[yyN]; else yyState = yyDgoto[yyM]; goto yyLoop; } } }
public virtual object Visit(UnaryOperator theOperator) { Validate(theOperator.Operand); return null; }
/// <summary>Default constructor with nagivated unary operator.</summary> /// <param name="unaryOperator">Nagivated unary operator.</param> internal UnaryOperatorNavigator(UnaryOperator unaryOperator) : base(unaryOperator) { }
protected bool IsPostUnaryOperator(UnaryOperator op) { switch (op) { case UnaryOperator.PostIncrement: case UnaryOperator.PostDecrement: return true; default: return false; } }
void PushUnaryExpression (UnaryOperator op, Expression expression) { Push (new UnaryExpression (op, expression)); }
void Associative_negop(out UnaryOperator op) { op = UnaryOperator.None; if (la.kind == 1 || la.kind == 12 || la.kind == 45) { } else if (la.kind == 15) { Get(); op = UnaryOperator.Neg; } else SynErr(96); }
// The following methods are used to insert methods to the bottom of the AST and convert operator to these method calls // to support replication on operators private static void InsertUnaryOperationMethod(Core core, ProtoCore.AST.Node root, UnaryOperator op, PrimitiveType r, PrimitiveType operand) { ProtoCore.AST.AssociativeAST.FunctionDefinitionNode funcDefNode = new ProtoCore.AST.AssociativeAST.FunctionDefinitionNode(); funcDefNode.access = ProtoCore.DSASM.AccessSpecifier.kPublic; funcDefNode.IsAssocOperator = true; funcDefNode.IsBuiltIn = true; funcDefNode.Name = Op.GetUnaryOpFunction(op); funcDefNode.ReturnType = new ProtoCore.Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r }; ProtoCore.AST.AssociativeAST.ArgumentSignatureNode args = new ProtoCore.AST.AssociativeAST.ArgumentSignatureNode(); args.AddArgument(new ProtoCore.AST.AssociativeAST.VarDeclNode() { memregion = ProtoCore.DSASM.MemoryRegion.kMemStack, access = ProtoCore.DSASM.AccessSpecifier.kPublic, NameNode = BuildAssocIdentifier(core, "%param"), ArgumentType = new ProtoCore.Type { Name = core.TypeSystem.GetType((int)operand), UID = (int)operand } }); funcDefNode.Signature = args; ProtoCore.AST.AssociativeAST.CodeBlockNode body = new ProtoCore.AST.AssociativeAST.CodeBlockNode(); ProtoCore.AST.AssociativeAST.IdentifierNode _return = BuildAssocIdentifier(core, ProtoCore.DSDefinitions.Keyword.Return, ProtoCore.PrimitiveType.kTypeReturn); ProtoCore.AST.AssociativeAST.IdentifierNode param = BuildAssocIdentifier(core, "%param"); body.Body.Add(new ProtoCore.AST.AssociativeAST.BinaryExpressionNode() { LeftNode = _return, Optr = ProtoCore.DSASM.Operator.assign, RightNode = new ProtoCore.AST.AssociativeAST.UnaryExpressionNode() { Expression = param, Operator = op } }); funcDefNode.FunctionBody = body; (root as ProtoCore.AST.AssociativeAST.CodeBlockNode).Body.Add(funcDefNode); }
public object Visit(UnaryOperator theOperator) { if (theOperator.OperatorType == UnaryOperatorType.Not) { return BooleanCriteriaStateObject.Logical; } if(theOperator.OperatorType == UnaryOperatorType.IsNull) return BooleanCriteriaStateObject.Logical; return BooleanCriteriaStateObject.Value; }