/// <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; }
/// <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; }
/// <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(); }
/// <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; }
/// <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; }
/// <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); }
/// <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) { }
internal ExceptionInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ExceptionReferenceExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
/// <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; }
internal PropertyReferenceInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, PropertyReferenceExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal InstantiateInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InstantiateExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal PrimitiveInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, PrimitiveExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal TryCatchInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, TryCatchStatement statement) : base(baZicInterpreter, parentInterpreter, executionFlowId, statement) { }
internal LabelConditionInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, LabelConditionStatement statement) : base(baZicInterpreter, parentInterpreter, executionFlowId, statement) { }
internal InvokeMethodInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InvokeMethodExpression expression, Guid executionFlowId, bool failIfNotExtern = false) : base(baZicInterpreter, parentInterpreter, expression) { _executionFlowId = executionFlowId; _failIfNotExtern = failIfNotExtern; }
internal ClassReferenceInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ClassReferenceExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal InvokeCoreMethodInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, InvokeCoreMethodExpression expression, Guid executionFlowId) : base(baZicInterpreter, parentInterpreter, expression) { _executionFlowId = executionFlowId; }
/// <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) { }
internal ArrayIndexerInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ArrayIndexerExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal NotOperatorInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, NotOperatorExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }
internal ExpressionStatementInterpreter(BaZicInterpreterCore baZicInterpreter, BlockInterpreter parentInterpreter, Guid executionFlowId, ExpressionStatement statement) : base(baZicInterpreter, parentInterpreter, executionFlowId, statement) { }
internal ArrayCreationInterpreter(BaZicInterpreterCore baZicInterpreter, Interpreter parentInterpreter, ArrayCreationExpression expression) : base(baZicInterpreter, parentInterpreter, expression) { }