public override Expression VisitIfAction([NotNull] IfActionContext context) { var action = VisitExpression(context.expression()); action = PredefinedObjects.GetIfAction(action); Actions.Add(action); return(null); }
public override Expression VisitDszAction([NotNull] DszActionContext context) { var index = GetIndexNumber(context.index()); var variable = Variables[index]; var action = PredefinedObjects.GetDszAction(variable); Actions.Add(action); return(null); }
public override Expression VisitPresentAction([NotNull] PresentActionContext context) { var signalIndex = GetIndexNumber(context.index()); var signal = Oc5Model.Signals[signalIndex]; var variable = Variables[signal.VarIndex]; var action = PredefinedObjects.GetPresentAction(variable); Actions.Add(action); return(null); }
public override Expression VisitConstantExpression([NotNull] ConstantExpressionContext context) { if (IsPredefined(context.index())) { var predefinedConstantIndex = GetIndexNumber(context.index()); return(PredefinedObjects.GetConstantExpression(predefinedConstantIndex)); } else { var index = GetIndexNumber(context.index()); return(Constants[index]); } }
public override Expression VisitConstant([NotNull] ConstantContext context) { if (!IsPredefined(context.index())) { throw new UnsupportedSyntaxException("User-defined constants", context.index().Start); } var predefinedTypeIndex = int.Parse(context.index().NUMBER().ToString()); var constantExpression = PredefinedObjects.GetConstantExpressionOfType(predefinedTypeIndex); Constants.Add(constantExpression); return(null); }
public override Expression VisitCallAction([NotNull] CallActionContext context) { var procedureIndex = GetIndexNumber(context.index()[0]); var variableIndex = GetIndexNumber(context.index()[1]); var variable = Variables[variableIndex]; var expression = VisitExpression(context.expression()); var action = PredefinedObjects.GetProcedure(procedureIndex, variable, expression); Actions.Add(action); return(null); }
public override Expression VisitVariable([NotNull] VariableContext context) { if (!IsPredefined(context.index())) { throw new UnsupportedSyntaxException("User-defined index", context.index().Start); } var predefinedTypeIndex = GetIndexNumber(context.index()); var variableExpression = PredefinedObjects.GetVariableExpression(predefinedTypeIndex, Oc5ModelState, Oc5StateParameterExpression); Variables.Add(variableExpression); return(null); }
public override Expression VisitFunctionCallExpression([NotNull] FunctionCallExpressionContext context) { if (!IsPredefined(context.index())) { throw new UnsupportedSyntaxException("User-defined functions", context.index().Start); } var functionIndex = GetIndexNumber(context.index()); var expressions = new List <Expression>(); foreach (var child in context.expressionList().children) { if (child is ExpressionContext) { expressions.Add(VisitExpression(child as ExpressionContext)); } } return(PredefinedObjects.GetFunctionExpression(functionIndex, expressions.ToArray())); }