示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProgramInterpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="program">The <see cref="BaZicProgram"/> to interpret.</param>
 /// <param name="executionFlowId">A GUID that defines in which callstack is linked.</param>
 internal ProgramInterpreter(BaZicInterpreterCore baZicInterpreter, BaZicProgram program, Guid executionFlowId)
     : base(baZicInterpreter, null, executionFlowId)
 {
     Requires.NotNull(program, nameof(program));
     _program   = program;
     _uiProgram = program as BaZicUiProgram;
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodInterpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="parentInterpreter">The parent interpreter.</param>
 /// <param name="methodDeclaration">The declaration of the method to interpret.</param>
 /// <param name="invokeMethod">The expression that performs the invocation.</param>
 /// <param name="executionFlowId">A GUID that defines in which callstack is linked.</param>
 internal MethodInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, MethodDeclaration methodDeclaration, InvokeMethodExpression invokeMethod, Guid executionFlowId)
     : base(baZicInterpreter, parentInterpreter, executionFlowId)
 {
     Requires.NotNull(methodDeclaration, nameof(methodDeclaration));
     Requires.NotNull(invokeMethod, nameof(invokeMethod));
     _methodDeclaration = methodDeclaration;
     _invokeMethod      = invokeMethod;
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlockInterpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="parentInterpreter">The parent interpreter.</param>
 /// <param name="executionFlowId">A GUID that defines in which callstack is linked.</param>
 /// <param name="isInIteration">Defines whether the current block of statement is executed inside of a iteration statement.</param>
 /// <param name="caughtException">Defines the caught exception.</param>
 /// <param name="statements">The list of statements to interpret.</param>
 internal BlockInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, Guid executionFlowId, bool isInIteration, Exception caughtException, IReadOnlyList <Code.AbstractSyntaxTree.Statement> statements)
     : base(baZicInterpreter, parentInterpreter, executionFlowId)
 {
     CaughtException = caughtException;
     State           = new BlockState(isInIteration);
     _statements     = statements;
     FillLabelRegistry();
 }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExpressionInterpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="parentInterpreter">The parent interpreter.</param>
 /// <param name="expression">The expression to interpret.</param>
 protected ExpressionInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, T expression)
 {
     Requires.NotNull(baZicInterpreter, nameof(baZicInterpreter));
     Requires.NotNull(parentInterpreter, nameof(parentInterpreter));
     Requires.NotNull(expression, nameof(expression));
     BaZicInterpreter  = baZicInterpreter;
     ParentInterpreter = parentInterpreter;
     Expression        = expression;
 }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StatementInterpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="parentInterpreter">The parent interpreter.</param>
 /// <param name="executionFlowId">A GUID that defines in which callstack is linked.</param>
 /// <param name="statement">The statement to interpret.</param>
 protected StatementInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, T statement)
 {
     Requires.NotNull(baZicInterpreter, nameof(baZicInterpreter));
     Requires.NotNull(parentInterpreter, nameof(parentInterpreter));
     Requires.NotNull(statement, nameof(statement));
     BaZicInterpreter  = baZicInterpreter;
     ParentInterpreter = parentInterpreter;
     Statement         = statement;
     ExecutionFlowId   = executionFlowId;
 }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlAccessor"/> class.
        /// </summary>
        /// <param name="controlAccessorDeclaration">The <see cref="ControlAccessorDeclaration"/> used to create the new variable in memory at runtime.</param>
        /// <param name="control">The UI component where the binding must be performed.</param>
        /// <param name="baZicInterpreter">The main BaZic interpreter.</param>
        internal ControlAccessor(ControlAccessorDeclaration controlAccessorDeclaration, object control, BaZicInterpreterCore baZicInterpreter)
            : base(controlAccessorDeclaration.Variable)
        {
            Requires.NotNull(control, nameof(control));
            Requires.NotNull(baZicInterpreter, nameof(baZicInterpreter));

            ControlName       = controlAccessorDeclaration.ControlName;
            _control          = control;
            _baZicInterpreter = baZicInterpreter;

            SetValue(control);
        }
示例#7
0
        /// <summary>
        /// Execute the condition
        /// </summary>
        /// <param name="baZicInterpreter">The <see cref="BaZicInterpreterCore"/>.</param>
        /// <param name="parentInterpreter">The parent block interpreter</param>
        /// <param name="condition">The condition expression</param>
        /// <returns>Return true, false, or null in case of error</returns>
        internal static bool?RunCondition(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Code.AbstractSyntaxTree.Expression condition)
        {
            if (condition == null)
            {
                baZicInterpreter.ChangeState(parentInterpreter, new NullValueException(L.BaZic.Runtime.Interpreters.Statements.ConditionInterpreter.MissingCondition));
                return(null);
            }

            var conditionResult = parentInterpreter.RunExpression(condition);

            if (parentInterpreter.IsAborted)
            {
                return(null);
            }

            var boolResult = conditionResult as bool?;

            if (boolResult != null)
            {
                return(boolResult.Value);
            }

            var intResult = conditionResult as int?;

            if (intResult != null)
            {
                switch (intResult.Value)
                {
                case 1:
                    return(true);

                case 0:
                    return(false);

                default:
                    baZicInterpreter.ChangeState(parentInterpreter, new OutOfRangeException(L.BaZic.Runtime.Interpreters.Statements.ConditionInterpreter.CastToBool), condition);
                    return(null);
                }
            }

            baZicInterpreter.ChangeState(parentInterpreter, new OutOfRangeException(L.BaZic.Runtime.Interpreters.Statements.ConditionInterpreter.BooleanExpected), condition);
            return(null);
        }
 internal VariableReferenceInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, VariableReferenceExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#9
0
 internal ExceptionInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ExceptionReferenceExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Interpreter"/> class.
 /// </summary>
 /// <param name="baZicInterpreter">The main interpreter.</param>
 /// <param name="parentInterpreter">The parent interpreter.</param>
 /// <param name="executionFlowId">A GUID that defines in which callstack is linked.</param>
 protected Interpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, Guid executionFlowId)
 {
     BaZicInterpreter  = baZicInterpreter;
     ParentInterpreter = parentInterpreter;
     ExecutionFlowId   = executionFlowId;
 }
示例#11
0
 internal PropertyReferenceInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, PropertyReferenceExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#12
0
 internal InstantiateInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InstantiateExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#13
0
 internal PrimitiveInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, PrimitiveExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#14
0
 internal TryCatchInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, TryCatchStatement statement)
     : base(baZicInterpreter, parentInterpreter, executionFlowId, statement)
 {
 }
示例#15
0
 internal LabelConditionInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, LabelConditionStatement statement)
     : base(baZicInterpreter, parentInterpreter, executionFlowId, statement)
 {
 }
示例#16
0
 internal InvokeMethodInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InvokeMethodExpression expression, Guid executionFlowId, bool failIfNotExtern = false)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
     _executionFlowId = executionFlowId;
     _failIfNotExtern = failIfNotExtern;
 }
示例#17
0
 internal ClassReferenceInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ClassReferenceExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#18
0
 internal InvokeCoreMethodInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InvokeCoreMethodExpression expression, Guid executionFlowId)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
     _executionFlowId = executionFlowId;
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaZicInterpreterCore"/> class.
 /// </summary>
 /// <param name="baZicInterpreterCore">The parent <see cref="BaZicInterpreterCore"/></param>
 internal RunningStateManager(BaZicInterpreterCore baZicInterpreterCore)
 {
     _baZicInterpreterCore = baZicInterpreterCore;
 }
 internal VariableDeclarationInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, VariableDeclaration statement)
     : base(baZicInterpreter, parentInterpreter, executionFlowId, statement)
 {
 }
示例#21
0
 internal ArrayIndexerInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ArrayIndexerExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#22
0
 internal NotOperatorInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, NotOperatorExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }
示例#23
0
 internal ExpressionStatementInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, ExpressionStatement statement)
     : base(baZicInterpreter, parentInterpreter, executionFlowId, statement)
 {
 }
示例#24
0
 internal ArrayCreationInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ArrayCreationExpression expression)
     : base(baZicInterpreter, parentInterpreter, expression)
 {
 }