// When an operator is clicked, it sends what is in the textbox into the num1 // variable and sends it to the label above the textbox along with the operator that was clicked private void btnOperator_Click(object sender, EventArgs e) { num1 = txtConsole.Text; txtConsole.Text = ""; switch (((Button) sender).Name) { case "btnAdd": this.operand = Operands.Add; label1.Text = num1 + CharPlus; break; case "btnSub": this.operand = Operands.Subtract; label1.Text = num1 + CharMinus; break; case "btnMult": this.operand = Operands.Multiply; label1.Text = num1 + CharMult; break; case "btnDiv": this.operand = Operands.Divide; label1.Text = num1 + CharDiv; break; } btnEnter.Focus(); }
private static string getOperandString(Operands operand) { if (operand.Equals(Operands.Equal)) { return "="; } else if (operand.Equals(Operands.GreaterEqual)) { return ">="; } else if (operand.Equals(Operands.LesserEqual)) { return "<="; } else if (operand.Equals(Operands.Greater)) { return ">"; } else if (operand.Equals(Operands.Lesser)) { return "<"; } else if (operand.Equals(Operands.Like)) { return "like"; } else if (operand.Equals(Operands.Between)) { return "between"; } else { return "="; } }
//-------------------------------------------------------------------------------------------------- protected void RemoveOperand(int operandIndex) { var oldOp = Operands[operandIndex]; oldOp?.RemoveDependent(this); Operands.RemoveAt(operandIndex); RaisePropertyChanged("ChildCount"); Invalidate(); }
public virtual T GetValue() { if (!Operators.Any() && Operands.Any()) { return(Operands[0].Value); } else { return(default(T)); } }
public OrExpression(Expression expression, Expression[] rightExpressions) { if (rightExpressions == null || rightExpressions.Any()) { throw new ArgumentException("Or Expression Create Arg Error!", "rightExpressions"); } Operands.Add(expression); Operands.AddRange(rightExpressions); ReturnType = typeof(bool); }
/// <inheritdoc /> public override string ToString() { var arguments = string.Join(" ", Operands.Select(x => x.ToString("N"))); if (PatternName != null) { arguments += $" {PatternName}"; } return($"{arguments} {Symbol}"); }
public override object EvalValue(Func <string, object> context) { var input = Operands.Select(item => (decimal)Convert.ChangeType(item.EvalValue(context), typeof(decimal))).ToArray(); if (input.Length == 1) { return(Math.Ceiling(input[0])); } throw new UnexpectedTypeException(); }
public override ushort Calculate() { ushort op1 = Operands.Pop(); ushort op2 = Operands.Pop(); if (op2 == 0) { throw new Z80AssemblerException("Nullával történő osztás a matematikai kifejezésben!"); } return((ushort)(op1 / op2)); }
private Operands GetOperands(string methodName, IDependencyResolver dependencyResolver = null) { var appRunner = new AppRunner <App>(); if (dependencyResolver != null) { appRunner.UseDependencyResolver(dependencyResolver); } return(appRunner.GetFromContext(methodName.SplitArgs(), ctx => Operands.FromCommand(ctx.ParseResult.TargetCommand), middlewareStage: MiddlewareStages.PostParseInputPreBindValues)); }
public void ParseEquationAdv(string equation) { string eq = equation.Replace("(", "( "); eq = eq.Replace(")", " )"); var parts = eq.Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (var part in parts) { if (int.TryParse(part, out int ival)) { // number push Operands.Add(part); } else { if (part == "+" || part == "*") { if (Operators.Count > 0 && Operators.Peek() != "(") { if (part == "*" && Operators.Peek() == "+") { Operands.Add(Operators.Pop()); } else if (part == Operators.Peek()) { Operands.Add(Operators.Pop()); } } Operators.Push(part); } else if (part == "(") { Operators.Push(part); } else if (part == ")") { // find the match string op; while (Operators.Count > 0 && (op = Operators.Pop()) != "(") { Operands.Add(op); } } } } while (Operators.Count > 0) { Operands.Add(Operators.Pop()); } }
public SearchOperator(Operator op, List <ISearch> operands) { if (op == Operator.Invalid) { op = Operator.And; // set to be the default search type. } Op = op; foreach (var item in operands) { Operands.Add(item); } }
}//End of Operand class //Actual tree construction from the expression private OperandClass BuildTreeOperand() { OperandClass tree = null; string expression = AnsBox.Text; if (!char.IsNumber(expression.Last())) { expression = expression.Substring(0, expression.Length - 1); } string numberStr = string.Empty; foreach (char c in expression.ToCharArray()) { if (char.IsNumber(c) || c == '.' || numberStr == string.Empty && c == '-') { numberStr += c; } else { AddOperandToTree(ref tree, new OperandClass() { value = double.Parse(numberStr) }); numberStr = string.Empty; Operands op = Operands.MINUS; //Set default case switch (c) { case '-': op = Operands.MINUS; break; case '+': op = Operands.PLUS; break; case '/': op = Operands.DIV; break; case 'x': op = Operands.TIMES; break; } AddOperandToTree(ref tree, new OperandClass() { opp = op }); } } //Last number AddOperandToTree(ref tree, new OperandClass { value = double.Parse(numberStr) }); return(tree); }
public void AddOperand(Node operand) { if (Type == ConnectorType.IMPLY && Operands.Count > 0) { throw new Exception("An imply connection must only have one operand"); } Operands.Add(operand); if (IsRoot || Type == ConnectorType.IMPLY || operand.OperandParents.Contains(this)) { return; } operand.OperandParents.Add(this); }
private bool ReadTwoOperands(byte[] buffer) { int op1 = GetByte(buffer, PC++); int op2 = GetByte(buffer, PC++); Operands.Add((Opcode & 0x040) == 0 ? new Operand(OperandType.SmallConst, op1) : new Operand(OperandType.Variable, op1)); Operands.Add((Opcode & 0x020) == 0 ? new Operand(OperandType.SmallConst, op2) : new Operand(OperandType.Variable, op2)); return(false); }
public override object EvalValue(Func <string, object> context) { object value = Operands.First().EvalValue(context); if (value is DateTime) { return(value); } else { return(DateTime.Parse(Convert.ToString(value))); } }
private int?getOperandIndex(string field) { var fieldOperand = Operands.SingleOrDefault(op => op.ToLower() == field.ToLower()); if (fieldOperand == null) { return(null); } else { return(Operands.IndexOf(fieldOperand)); } }
//-------------------------------------------------------------------------------------------------- #endregion #region Topology public override void Remove() { Operands.ForEach(operand => { if (operand != null) { operand.RemoveDependent(this); operand.Remove(); } }); Operands.Clear(); base.Remove(); }
public Calculator() { UpdatedDisplay = "0"; Operands = new Operands(); OperationMap = new Dictionary <char, Operation>() { { '+', new Addition() }, { '-', new Subtraction() }, { 'x', new Multiplication() }, { 'X', new Multiplication() }, { '/', new Division() }, }; }
public override ushort Calculate() { if (IsUnary) { ushort op = Operands.Pop(); return(op); } ushort op1 = Operands.Pop(); ushort op2 = Operands.Pop(); return((ushort)(op1 + op2)); }
public CallExpression(Function context, Dictionary <string, object> data) : base(context) { Function = ((Token)data["Name_0"]).Text; Operands = ((List <object>)data["<argument-list>_0"]) .Select(o => (Dictionary <string, object>)o) .Select(o => Expression.ParseExpression(context, (Dictionary <string, object>)o["<expression>_0"])) .ToList(); if (Function == "printd") { Operands.Insert(0, new ConstExpression(context, "fmt")); } }
public MemberExpress(Expression parameter, string memberName, Type ofType = null) { if (ofType != null) { ReturnType = ofType; } else { ReturnType = typeof(object); } Operands.Add(parameter); MemberName = memberName; }
public string ToIntelSyntax(X86FormatOptions formatOptions) { var instrName = Operation.ToString(); instrName = formatOptions.AllUpperCase ? instrName.ToUpper() : instrName.ToLower(); var instr = $"{instrName} {string.Join(", ", Operands.Select(o => o.ToIntelSyntax(formatOptions)))}"; if (Comment == null) { return(instr); } return(formatOptions.CommentAbove ? $"; {Comment}\n {instr}" : $"{instr} ; {Comment}"); }
// SortEquation Method - Sorts each subequation's character's into its respective list public void SortEquation() { foreach (var c in subEquation.Split(' ')) { if (HasNumber(c) || IsX(c)) { Operands.Add(c); } else if (IsOperator(c)) { Operators.Add(c); } } }
/// <summary> /// Tests if the expression will evaluate False with any combination of remaining inputs /// </summary> /// <returns>true if all possible combinations result in a False evaluation</returns> /// <remarks> /// This determines if the search for operands may be halted before the end of the list. /// For example, the expression 'a AND b' can be halted if 'a' is false because it does not /// matter what 'b' is. Conversely, the expression 'a OR b' cannot be halted if 'a' is false /// since 'b' can be true. Even if the expression is known to be True before evaluating all /// the operands, processing operands should continue to find all the matches in the remaining /// operands. /// </remarks> public bool IsShortCircuitFalse() { var savedState = Operands.Select(o => o.EvaluatedResult).ToList(); List <List <bool> > values = new List <List <bool> >(); for (int idx = 0; idx < Math.Pow(2, Operands.Count); idx++) { values.Add(new List <bool>()); string binary = Convert.ToString(idx, 2).PadLeft(Operands.Count(), '0'); for (int jdx = 0; jdx < Operands.Count; jdx++) { var b = binary[jdx]; values[idx].Add(b != '0'); } } EvaluationResult result = EvaluationResult.Undetermined; foreach (var row in values) { for (int col = 0; col < row.Count; col++) { if (!Operands[col].EvaluatedResult.HasValue) { Operands[col].EvaluatedResult = row[col]; } } EvaluationResult rowResult = EvaluateExpression(false) ? EvaluationResult.True : EvaluationResult.False; // restore original state for (int col = 0; col < Operands.Count; col++) { Operands[col].EvaluatedResult = savedState[col]; } if (result == EvaluationResult.Undetermined) { result = rowResult; } else if (result != rowResult) { return(false); } } return(result == EvaluationResult.False); }
static async Task Main(string[] args) { var channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure); var operands = new Operands() { Operand1 = 1, Operand2 = 2 }; var client = new Calculator.CalculatorClient(channel); var result = await client.AddAsync(operands); Console.WriteLine(result.Number_); }
internal override unsafe void ParseDetails(CsDetailBase *detail) { var ad = (CsArm64Detail *)&detail->ArchSpecificPlaceholder; Condition = (ConditionCode)ad->CC; var ops = (CsArm64Op *)&ad->OpsPlaceholder; for (var i = 0; i < ad->OpCount; ++i) { var op = ops[i]; switch (op.OpType) { case 1: Operands.Add(new RegOperand(*(Reg *)&op.Placeholder0)); break; case 2: Operands.Add(new ImmOperand(*(ulong *)&op.Placeholder0)); break; case 3: Operands.Add(new MemOperand( *(Reg *)&op.Placeholder0, *(Reg *)&op.Placeholder1, *(int *)&op.Placeholder2 )); break; case 4: Operands.Add(new FpOperand(*(double *)&op.Placeholder0)); break; case 65: case 66: case 67: case 68: case 69: Operands.Add(null); break; case 70: Operands.Add(new BarrierOperand(*(Barrier *)&op.Placeholder0)); break; default: throw new NotImplementedException($"Operand type {op.OpType} not supported"); } } }
public override void FindMaxTop(float[] height) { float h = nameSize.Height / 2; if (Operands.Length > 0) { h = !isMultiLine?Operands.Max(i => i.FindMaxTop()) : nameSize.Height / 2; } if (height[0] < h) { height[0] = h; } }
public override void FindMaxBottom(float[] height) { float h = DesiredHeight - nameSize.Height / 2; if (Operands.Length > 0) { h = !isMultiLine?Operands.Max(i => i.FindMaxBottom()) : DesiredHeight - nameSize.Height / 2; } if (height[0] < h) { height[0] = h; } }
public void Write(BytecodeWriter writer) { if (Operands.Count == 0) { return; } Operands[0].Write(writer); foreach (var operand in Operands.Skip(1)) { writer.Write(operand.FirstValue); operand.Write(writer); } }
public static String ConvertOperandToString(Operands operand) { switch (operand) { case Operands.Add: return "+"; case Operands.Minus: return "-"; case Operands.Times: return "X"; case Operands.Divide: return "/"; } throw new Exception("Invalid operand"); }
private bool InMemoryOperandsReady(Program program) { var operandInMemory = Operands.FirstOrDefault(x => x.OperandType == OperandType.Memory); if (operandInMemory != null && !program.Labels.ContainsKey(operandInMemory.Value)) { if (program.RunNumber > 1) { throw new ArgumentException(); } return(false); } return(true); }
public override object EvalValue(Func <string, object> context) { var input = Operands.Select(item => (int)Convert.ChangeType(item.EvalValue(context), typeof(int))).ToArray(); if (input.Length == 1) { return((double)new Random().Next(input[0])); } else if (input.Length == 2) { return((double)new Random().Next(input[0], input[1])); } return((double)new Random().Next()); }
public override string ToString(IDictionary <Type, ExpressionAction> map) { var value = base.ToString(map); if (value == null) { var ops = new List <LiteralExpression>(2); ops.AddRange(Operands.Cast <LiteralExpression>()); // default to infix notation value = string.Format(@"({1} {0} {2})", Operator, ops[0].ToString(map), ops[1].ToString(map)); } return(value); }
private void addToIssuedCommands(HipChat.Entities.Message message) { var op = new Operands(); op.userId = message.From.Id; op.command = message.Text; op.date = message.Date; OperationsList.Add(op); }
private bool checkIfCommandIssued(HipChat.Entities.Message message) { //cast a temp struct with the message var op = new Operands(); op.userId = message.From.Id; op.command = message.Text; op.date = message.Date; foreach (var completeOperation in OperationsList) { if (op.userId == completeOperation.userId && op.date == completeOperation.date && op.command == completeOperation.command) { return true; } } return false; }
public List<SystemProcess> GetSystemProcessByKeyValue(string Key,string Value,Operands operand,string SelectClause=null) { string sql=string.IsNullOrEmpty(SelectClause)?GetSystemProcessSelectClause():(string.Format("Select {0} ",SelectClause)); sql+= string.Format("from SystemProcess with (nolock) where {0} {1} '{2}' ",Key,operand.ToOperandString(),Value); DataSet ds=SqlHelper.ExecuteDataset(this.ConnectionString,CommandType.Text,sql); if (ds == null || ds.Tables.Count != 1 || ds.Tables[0].Rows.Count == 0) return null; return CollectionFromDataSet<SystemProcess>(ds,SystemProcessFromDataRow); }
public void addCall(Operand lambda_reference, Lvalues lvalues, Operands arguments) { Call call = new Call(lvalues, lambda_reference, arguments); m_lambda.addStatement(call); }
public TheCalculator() { _operands = new Operands(); show(0); }
public Lambda getLambda(Operands return_values) { return m_lambda; }
public void addMove(Lvalues lvalues, Operands rvalues) { Move m = new Move(lvalues, rvalues); m_lambda.addStatement(m); }
public void addLambda(Lambda lambda, Lvalues lvalues, Operands arguments) { DoLambda lambda_stamp = new DoLambda(lvalues, lambda, arguments); m_lambda.addStatement(lambda_stamp); }
public void addDo(Operator op, Lvalues lvalues, Operands arguments) { Do op_stamp = new Do(lvalues, op, arguments); m_lambda.addStatement(op_stamp); }
public OperatorBall(Operands value, Vector2 initialPosition, int xVelocityMultiplier) : base(initialPosition, xVelocityMultiplier) { this.ballType = BallType.Operand; text = OperandHelper.ConvertOperandToString(value); }
public void AddOperand(Operands op) { isDirty = true; userResponse.Operands.Add(op); }