Beispiel #1
0
        public override void Execute(Runner.State state)
        {
            if (funcName[0] == '$')
            {
                var variable = state.TopScope.Get(funcName) ?? throw new InternalNSLExcpetion($"Failed to find invoked variable '{funcName}'");

                var argumentValues = arguments.Select(v => state.TopScope.Get(v) ?? throw new InternalNSLExcpetion($"Failed to find variable '{v}'"));
                if (argumentValues.Count() == 1)
                {
                    variable.Value = argumentValues.First().Value;
                }

                if (retVarName != null)
                {
                    state.TopScope.Replace(retVarName, variable);
                }
            }
            else
            {
                var argumentValues = arguments.Select(v => state.TopScope.Get(v) ?? throw new InternalNSLExcpetion($"Failed to find variable '{v}'"));
                var function       = state.FunctionRegistry.FindSpecific(funcName);
                if (function != null)
                {
                    var returnValue = function.Invoke(argumentValues, state);
                    if (retVarName != null)
                    {
                        state.TopScope.Replace(retVarName, returnValue);
                    }
                }
                else
                {
                    throw new InternalNSLExcpetion($"Failed to find function '{funcName}'");
                }
            }
        }
Beispiel #2
0
        public override void Execute(Runner.State state)
        {
            var scope          = state.TopScope;
            var actionVariable = scope.Get(actionVarName);

            if (actionVariable == null)
            {
                throw new InternalNSLExcpetion($"Failed to find action variable {actionVarName}");
            }
            if (actionVariable.Value is NSLAction action)
            {
                var arrayVariable = scope.Get(arrayVarName);
                if (arrayVariable == null)
                {
                    throw new InternalNSLExcpetion($"Failed to find array variable {arrayVarName}");
                }
                var arrayObject = arrayVariable.Value;
                if (arrayObject is IEnumerable arrayEnum)
                {
                    var argumentVariable = action.ArgumentVariables.ElementAt(0).type.Instantiate(null);
                    action.Scope.Set(action.ArgumentVariables.ElementAt(0).varName, argumentVariable);
                    foreach (var element in arrayEnum)
                    {
                        argumentVariable.Value = element;
                        state.Runner.RunAction(action);
                    }
                }
                else
                {
                    throw new InternalNSLExcpetion($"Supposed array typed ({arrayVariable.TypeSymbol}) variable's object is not IEnumerable {arrayObject?.GetType().Name ?? "null"}");
                }
            }
            else
            {
                throw new InternalNSLExcpetion($"Supposed action typed ({actionVariable.TypeSymbol}) variable's object is not an NSLAction {actionVariable.Value?.GetType().Name ?? "null"}");
            }
        }
Beispiel #3
0
 public abstract void Execute(Runner.State state);
Beispiel #4
0
 public override void Execute(Runner.State state)
 {
     state.PopScope();
 }
Beispiel #5
0
 public override void Execute(Runner.State state)
 {
     throw new System.NotImplementedException();
 }
Beispiel #6
0
 public override void Execute(Runner.State state)
 {
     state.PushScope(id, parentId);
 }