/// <summary>
        /// start uniroutine interator
        /// </summary>
        /// <param name="enumerator">target enumerator</param>
        /// <param name="routineType">routine type</param>
        /// <param name="scope">routine execution scope</param>
        /// <param name="moveNextImmediately"></param>
        /// <returns>cancelation handle</returns>
        public static RoutineHandle RunUniRoutine(
            IEnumerator enumerator,
            RoutineType routineType,
            RoutineScope scope,
            bool moveNextImmediately = true)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return(new RoutineHandle());
            }
#endif

            var routineObject = GetRoutineObject(scope);
            //get routine
            var routine = routineObject.GetRoutine(routineType);
            //add enumerator to routines
            var routineTask = routine.AddRoutine(enumerator, moveNextImmediately);
            if (routineTask == null)
            {
                return(new RoutineHandle(0, routineType, scope));
            }

            var routineValue = new RoutineHandle(routineTask.Id, routineType, scope);
            return(routineValue);
        }
Beispiel #2
0
        public AD7Property(string name, AD7ProgramNode node, RoutineScope rs, bool readOnly)
        {
            Debug.WriteLine("AD7Property ctor (string,AD7ProgramNode,RoutineScope,bool)");
            Name      = name;
            _node     = node;
            _rs       = rs;
            _readOnly = readOnly;
            TypeName  = null;
            StoreType st;

            if (_node.Debugger.Debugger.ScopeVariables.TryGetValue(name, out st))
            {
                TypeName = _node.Debugger.Debugger.ScopeVariables[name].Type;
                if (numberTypeMax.ContainsKey(TypeName) && st.Unsigned)
                {
                    TypeName += " unsigned";
                }
            }
            Value = GetValue(name);
            if (TypeName == null)
            {
                // an heuristic to find out an expression type.
                TypeName = StoreType.InferTypeExpression(Value);
            }
        }
 public static RoutineHandle Execute(
     this IEnumerator enumerator,
     RoutineType routineType  = RoutineType.Update,
     bool moveNextImmediately = false,
     RoutineScope scope       = RoutineScope.Global)
 {
     return(UniRoutineManager.RunUniRoutine(enumerator, routineType, scope, moveNextImmediately));
 }
 public static IDisposableItem ExecuteRoutine(
     this IEnumerator enumerator,
     RoutineType routineType  = RoutineType.Update,
     bool moveNextImmediately = false,
     RoutineScope scope       = RoutineScope.Global)
 {
     return(Execute(enumerator, routineType, moveNextImmediately, scope).AsDisposable());
 }
 public AD7DocumentContext(string fileName, int lineNumber, TEXT_POSITION beginPosition, TEXT_POSITION endPosition, RoutineScope rs)
 {
     Debug.WriteLine("AD7DocumentContext: ctor");
     _fileName      = fileName;
     _beginPosition = beginPosition;
     _endPosition   = endPosition;
     _lineNumber    = lineNumber;
     _rs            = rs;
 }
 public AD7DocumentContext(string fileName, int lineNumber, TEXT_POSITION beginPosition, TEXT_POSITION endPosition, RoutineScope rs)
 {
   Debug.WriteLine("AD7DocumentContext: ctor");
   _fileName = fileName;
   _beginPosition = beginPosition;
   _endPosition = endPosition;
   _lineNumber = lineNumber;
   _rs = rs;
 }
        private static UniRoutinObject CreateRoutineScopeObject(RoutineScope routineScope)
        {
            //create routine object and mark as immortal
            var gameObject        = new GameObject("UniRoutineManager");
            var routineGameObject = gameObject.AddComponent <UniRoutinObject>();

            if (routineScope == RoutineScope.Global)
            {
                UnityEngine.Object.DontDestroyOnLoad(gameObject);
            }
            return(routineGameObject);
        }
        private static UniRoutinObject GetRoutineObject(RoutineScope scope)
        {
            var index       = (int)scope;
            var scopeObject = _routineObjects[index];

            if (scopeObject && scopeObject.gameObject)
            {
                return(scopeObject);
            }

            scopeObject            = CreateRoutineScopeObject(scope);
            _routineObjects[index] = scopeObject;
            return(scopeObject);
        }
Beispiel #9
0
        public AD7PropertyCollection(AD7ProgramNode node, RoutineScope rs)
        {
            Debug.WriteLine("AD7PropertyCollection ctor( AD7ProgramNode, RoutineScope )");
            _node = node;
            _rs   = rs;
            Debugger dbg = DebuggerManager.Instance.Debugger;

            foreach (StoreType st in _rs.Variables.Values)
            {
                if (st.VarKind == VarKindEnum.Internal)
                {
                    continue;
                }
                this.Add(new AD7Property(st.Name, node, _rs));
            }
        }
Beispiel #10
0
        public AD7StackFrame(AD7ProgramNode node, RoutineScope rs)
        {
            Debug.WriteLine("AD7StackFrame: ctor");
            _rs   = rs;
            _node = node;
            //Breakpoint bp = DebuggerManager.Instance.CurrentBreakpoint.CoreBreakpoint;
            Breakpoint    bp  = rs.CurrentPosition;
            TEXT_POSITION pos = new TEXT_POSITION()
            {
                dwLine = (uint)(bp.StartLine - 1), dwColumn = ( uint )(bp.StartColumn)
            };
            TEXT_POSITION endPos = new TEXT_POSITION();

            endPos.dwLine   = ( uint )(bp.EndLine - 1);
            endPos.dwColumn = ( uint )(bp.EndColumn);
            _docContext     = new AD7DocumentContext(_rs.GetFileName(), -1, pos, endPos, rs);
            _node.FileName  = _node.Debugger.Debugger.CurrentScope.FileName;
        }
Beispiel #11
0
 public AD7Property(string name, AD7ProgramNode node, RoutineScope rs) : this(name, node, rs, false)
 {
 }
Beispiel #12
0
 public RoutineHandle(int id, RoutineType routineType, RoutineScope scope)
 {
     Id    = id;
     Type  = routineType;
     Scope = scope;
 }