コード例 #1
0
 /**
  * Private contructor, use builder
  */
 public HeapAllocation(String variableName, IExpressions expression)
 {
     this.variableName = variableName;
     //        this.expressionResult = expression.eval(symbolicTable);
     this.expression = expression;
     //        pointer = heap.size();
     //        heap.put(heap.size() ,expressionResult);
     //        symbolicTable.put(variableName, pointer);
 }
コード例 #2
0
 public SwitchStatement(IExpressions expression, IExpressions case1, IExpressions case2,
                    IMyStatement statementDefault, IMyStatement statementCase1, IMyStatement statementCase2)
 {
     this.expression = expression;
     this.case1 = case1;
     this.case2 = case2;
     this.statementDefault = statementDefault;
     this.statementCase1 = statementCase1;
     this.statementCase2 = statementCase2;
 }
コード例 #3
0
        public async Task <ExpressionResponse> CalculateResult(string[] expressions, int?precision)
        {
            /*when calculations are to be implemented in this calculation engine instead of using the Maths API,
             * every expression in the chain will be either a SimpleArithmeticSingleExpression or ComplexArithmeticSingleExpression or we may create further
             * classes to handle specific expressions based on the Parser output
             * so all we have to do is call ReturnExpressionResults for every expression in the chain of expressions and it should return us the object
             * of the specific class that will handle that expression
             * For now, below are the categories
             * -> SimpleArithmeticSingleExpression is an expression involving 2 numbers and only one operator like +, -, * or /
             * -> ComplexArithmeticSingleExpression is an expression involving multiple numbers with multiple operators where BEDMAS will be applied
             * -> ComplexArithmeticSingleExpression is also an expression like sqrt(4), sin(45 deg)^2 etc but we may create separate class for this
             *
             * This is how the implementation will look like -
             * var expressionResponse = new ExpressionResponse();
             * foreach(var expression in expressions)
             * {
             *  var response = await ReturnExpressionResults(expression, precision);
             *  if(response!=null)
             *  {
             *      expressionResponse.result.Add(response.result.FirstOrDefault());
             *  }
             *  else
             *  {
             *      expressionResponse.result = null;
             *      expressionResponse.error = $"An error occurred while evaluating this expression - {expression}";
             *  }
             * }
             * return expressionResponse; */

            //Until then we use the below to resolve the chain of expressions -
            if (expressions.Length == 1)
            {
                return(await ReturnExpressionResults(expressions, precision));
            }
            else //This class ChainOfExpressions will not be required after we implement as described above.
                 //for now, create this class and call Maths API within.
            {
                _expressions = new ChainOfExpressions(_callMathsAPIService);
                return(await _expressions.CalculateResult(expressions, precision));
            }
        }
コード例 #4
0
 public CalculateResultService(IParseExpressions parseExpressions, ICallMathsAPIService callMathsAPIService, IExpressions expressions)
 {
     _parseExpressions    = parseExpressions;
     _callMathsAPIService = callMathsAPIService;
     _expressions         = expressions;
 }
コード例 #5
0
 /**
  * The constructor
  * @param expression The expression
  * @param thenStatement The correct statement
  * @param elseStatement The false statement
  */
 public IfStatement(IExpressions expression, IMyStatement thenStatement, IMyStatement elseStatement)
 {
     this.Expression = expression;
     this.thenStatement = thenStatement;
     this.elseStatement = elseStatement;
 }
コード例 #6
0
 public void setExpression(IExpressions expression)
 {
     this.Expression = expression;
 }
コード例 #7
0
 public SleepStatement(IExpressions time)
 {
     this.time = time;
 }
コード例 #8
0
 /**
  * The constructor
  * @param variableName The var name
  * @param expression the expression
  */
 public WriteHeapStatement(String variableName, IExpressions expression)
 {
     this.variableName = variableName;
     this.expression = expression;
 }
コード例 #9
0
 public void setExpression(IExpressions mExpression)
 {
     this.expression = mExpression;
 }
コード例 #10
0
 /**
  * The constructor
  * @param expression Expression
  */
 public PrintStatement(IExpressions expression)
 {
     this.expression = expression;
 }
コード例 #11
0
 public WhileStatement(IMyStatement statement, IExpressions expression)
 {
     this.statement = statement;
     this.expression = expression;
 }
コード例 #12
0
 public LogicExpression(String theOperator, IExpressions expression1, IExpressions expression2)
 {
     this.operatorType = getOperatorType(theOperator);
     this.firstExpression = expression1;
     this.secondExpression = expression2;
 }
コード例 #13
0
 /**
  * The constructor
  * @param variableName The name of variable
  * @param expression The expression
  */
 public AssignStatement(String variableName, IExpressions expression)
 {
     this.variableName = variableName;
     this.expression = expression;
 }
コード例 #14
0
 public BooleanExpression(string myOperator, IExpressions expression1, IExpressions expression2)
 {
     this.operatorType = getOperatorType(myOperator);
     this.firstExpression = expression1;
     this.secondExpression = expression2;
 }
コード例 #15
0
 /**
  * The constructor
  * @param operatorType The type of the operator for current arithmetic expression
  * @param firstExpression The first expression
  * @param secondExpression The second expression
  */
 public ArithmeticExpression(string operatorType, IExpressions firstExpression, IExpressions secondExpression)
 {
     this.operatorType = getOperatorType(operatorType);
     this.firstExpression = firstExpression;
     this.secondExpression = secondExpression;
 }