protected override void WalkClass(IObject classInstance, CallStack stack)
        {
            var name = GetNameOfElement(classInstance);
            Result.AppendLine($"{stack.Indentation}if(name == \"{name}\") // Looking for class");
            Result.AppendLine($"{stack.Indentation}{{");

            string fullName;
            if (stack.Level == 1)
            {
                // Removes the name of the package of the first hierarchy level
                // since it is already included into the class name
                fullName = $".__{name}";
            }
            else
            {
                fullName = $"{stack.Fullname}.__{name}";
            }

            var ifStack = stack.NextWithoutLevelIncrease;
            var ifForeachStack = ifStack.NextWithoutLevelIncrease;
            Result.AppendLine($"{ifStack.Indentation}tree{fullName} = value;");
            Result.AppendLine($"{ifStack.Indentation}isSet = value.isSet(\"ownedAttribute\");");
            Result.AppendLine(
                $"{ifStack.Indentation}collection = isSet ? (value.get(\"ownedAttribute\") as IEnumerable<object>) : EmptyList;");
            Result.AppendLine($"{ifStack.Indentation}foreach (var item{ifStack.Level} in collection)");
            Result.AppendLine($"{ifStack.Indentation}{{");
            Result.AppendLine($"{ifForeachStack.Indentation}value = item{ifStack.Level} as IElement;");
            Result.AppendLine($"{ifForeachStack.Indentation}name = GetNameOfElement(value);");

            base.WalkClass(classInstance, ifStack);

            Result.AppendLine($"{ifStack.Indentation}}}");
            Result.AppendLine($"{stack.Indentation}}}");
        }
Beispiel #2
0
 internal WorkerThread(CodeAssembly asm)
 {
     Assembly = asm;
     Module = asm.GetRootModule();
     CallStack = new CallStack();
     Context = new ExecutionContext();
 }
        public void PackageConflicts(PackageIdentifier identifier, CallStack failingCallStack)
        {
            PackageResolutionStacks existingCompatible = CompatiblePackageVersions[identifier];

            _compatiblePackageVersions.Pop();
            CompatiblePackageVersions.Remove(identifier);

            _incompatiblePackages.Pop();
            IncompatiblePackageVersions.Add(identifier, existingCompatible.Successful, existingCompatible.Failed.Concat(failingCallStack));
        }
        /// <summary>
        ///     Creates a C# class instance for all the packages and classes within the extent
        /// </summary>
        /// <param name="extent">Extent to be used</param>
        public virtual void Walk(IUriExtent extent)
        {
            var stack = new CallStack(null);

            StartNamespace(ref stack);
            foreach (var element in extent.elements())
            {
                var elementAsObject = element as IObject;
                Walk(elementAsObject, stack);
            }

            EndNamespace(ref stack);
        }
        public void PackageSucceeds(PackageIdentifier packageNode, CallStack succeedingCallstack)
        {
            // commit the new ignore list
            PackageResolveResults ignoredPackagesInBranch = _incompatiblePackages.Pop();
            _incompatiblePackages.Pop();
            _incompatiblePackages.Push(ignoredPackagesInBranch);

            // add successful package
            PackageResolveResults foundPackages = _compatiblePackageVersions.Pop();
            foundPackages.Add(packageNode, successful: new[] { succeedingCallstack });
            _compatiblePackageVersions.Pop();
            _compatiblePackageVersions.Push(foundPackages);
        }
Beispiel #6
0
        public void Init(string functionName)
        {
            Setup();

            if (!module.Functions.ContainsKey(functionName))
            {
                throw new FunctionNotFound(functionName);
            }

            var function = module.Functions[functionName];

            CallStack.Push(new Call(function));

            IsRunning = true;
        }
Beispiel #7
0
        public override DynValue Visit(UndefNode undefNode)
        {
            switch (undefNode.Type)
            {
            case UndefineType.Local:
                if (CallStack.Count == 0)
                {
                    throw new RuntimeException($"Attempt to undefine a local variable outside a function '{undefNode.Name}'.", undefNode.Line);
                }

                var callStackItem = CallStack.Peek();

                if (!callStackItem.LocalVariableScope.ContainsKey(undefNode.Name))
                {
                    throw new RuntimeException($"Attempt to undefine a non-existent local variable '{undefNode.Name}'.", undefNode.Line);
                }

                callStackItem.LocalVariableScope.Remove(undefNode.Name);
                break;

            case UndefineType.Function:
                if (Environment.BuiltIns.ContainsKey(undefNode.Name))
                {
                    throw new RuntimeException($"Attempt to undefine a built-in function '{undefNode.Name}'.", undefNode.Line);
                }

                if (!Environment.Functions.ContainsKey(undefNode.Name))
                {
                    throw new RuntimeException($"Attempt to undefine a non-existent function '{undefNode.Name}'", undefNode.Line);
                }

                Environment.Functions.Remove(undefNode.Name);
                break;

            case UndefineType.Global:
                if (!Environment.Globals.ContainsKey(undefNode.Name))
                {
                    throw new RuntimeException($"Attempt to undefine a non-existent global variable '{undefNode.Name}'.", undefNode.Line);
                }

                Environment.Globals.Remove(undefNode.Name);
                break;

            default:
                throw new RuntimeException("Internal interpreter error: unexpected UndefType value.", undefNode.Line);
            }
            return(DynValue.Zero);
        }
        private void OpMul()
        {
            CallStack.Push(nameof(OpMul));

            if (Tokens[IndexAtual].Tipo == TipoToken.OperadorMultiplicacao ||
                Tokens[IndexAtual].Tipo == TipoToken.OperadorDivisao)
            {
                if (Tokens[IndexAtual].Tipo == TipoToken.OperadorDivisao)
                {
                    IsOpDivisao = true;
                }
                IndexAtual++;
            }

            CallStack.Pop();
        }
        /// <summary>
        ///     Parses the packages
        /// </summary>
        /// <param name="classInstance">The class that shall be retrieved</param>
        protected override void WalkClass(IObject classInstance, CallStack stack)
        {
            var name = GetNameOfElement(classInstance);

            Result.AppendLine($"{stack.Indentation}public class _{name}");
            Result.AppendLine($"{stack.Indentation}{{");

            base.WalkClass(classInstance, stack);

            Result.AppendLine($"{stack.Indentation}}}");

            Result.AppendLine();
            Result.AppendLine($"{stack.Indentation}public _{name} @{name} = new _{name}();");
            Result.AppendLine($"{stack.Indentation}public IElement @__{name} = new MofElement();");
            Result.AppendLine();
        }
        private void Argumentos()
        {
            CallStack.Push(nameof(Argumentos));

            if (Tokens[IndexAtual].Tipo == TipoToken.Identificador)
            {
                IndexAtual++;
                MaisIdent();
            }
            else
            {
                ThrowCompiladorException(Tokens[IndexAtual]);
            }

            CallStack.Pop();
        }
Beispiel #11
0
        private LookAheadSet FindLookAhead(ProductionPatternElement elem,
                                           int length,
                                           CallStack stack,
                                           LookAheadSet filter)
        {
            // Find initial element look-ahead
            var first  = FindLookAhead(elem, length, 0, stack, filter);
            var result = new LookAheadSet(length);

            result.AddAll(first);
            if (filter == null || !filter.IsOverlap(result))
            {
                return(result);
            }

            // Handle element repetitions
            if (elem.MaxCount == Int32.MaxValue)
            {
                first = first.CreateRepetitive();
            }

            var max = elem.MaxCount;

            if (length < max)
            {
                max = length;
            }

            for (int i = 1; i < max; i++)
            {
                first = first.CreateOverlaps(filter);
                if (first.Size() <= 0 || first.GetMinLength() >= length)
                {
                    break;
                }

                var follow = FindLookAhead(elem,
                                           length,
                                           0,
                                           stack,
                                           filter.CreateFilter(first));
                first = first.CreateCombination(follow);
                result.AddAll(first);
            }

            return(result);
        }
Beispiel #12
0
        public async Task <DynValue> ExecuteAsync(string sourceCode, CancellationToken token)
        {
            Parser.LoadSource(sourceCode);
            var node = Parser.Parse();

            try
            {
                return(await Task.Run(async() => await VisitAsync(node, token), token));
            }
            catch (ExitStatementException)
            {
                CallStack.Clear();
                LoopStack.Clear();

                return(DynValue.Zero);
            }
        }
Beispiel #13
0
 public DebugEventInfo(DebugMessage message) : base(message.Id, EventType.Debug, message.Time)
 {
     this.BreakPoint = message.BreakPoint;
     if (message.DebugMsgType == DebugMessageType.BreakPointHitted)
     {
         this.IsDebugHit = true;
         this.WatchData  = message.WatchData;
     }
     else if (message.DebugMsgType == DebugMessageType.FreeDebugBlock)
     {
         this.IsDebugHit = false;
     }
     else
     {
         throw new ArgumentException();
     }
 }
Beispiel #14
0
        public DynValue Execute(string sourceCode)
        {
            Parser.LoadSource(sourceCode);
            var node = Parser.Parse();

            try
            {
                return(Visit(node));
            }
            catch (ExitStatementException)
            {
                CallStack.Clear();
                LoopStack.Clear();

                return(DynValue.Zero);
            }
        }
        public override DynValue Visit(CompoundAssignmentNode compoundAssignmentNode)
        {
            DynValue val;

            if (CallStack.Count > 0)
            {
                var stackTop = CallStack.Peek();
                val = Visit(compoundAssignmentNode.Right);

                if (stackTop.ParameterScope.ContainsKey(compoundAssignmentNode.Variable.Name))
                {
                    stackTop.ParameterScope[compoundAssignmentNode.Variable.Name] = HandleCompoundOperation(
                        stackTop.ParameterScope[compoundAssignmentNode.Variable.Name],
                        val,
                        compoundAssignmentNode.Operation
                        );

                    return(DynValue.Zero);
                }
                else if (stackTop.LocalVariableScope.ContainsKey(compoundAssignmentNode.Variable.Name))
                {
                    stackTop.LocalVariableScope[compoundAssignmentNode.Variable.Name] = HandleCompoundOperation(
                        stackTop.LocalVariableScope[compoundAssignmentNode.Variable.Name],
                        val,
                        compoundAssignmentNode.Operation
                        );

                    return(DynValue.Zero);
                }
            }

            if (!Environment.Globals.ContainsKey(compoundAssignmentNode.Variable.Name))
            {
                throw new RuntimeException($"Variable '{compoundAssignmentNode.Variable.Name}' was not found in current scope.", null);
            }

            val = Visit(compoundAssignmentNode.Right);

            Environment.Globals[compoundAssignmentNode.Variable.Name] = HandleCompoundOperation(
                Environment.Globals[compoundAssignmentNode.Variable.Name],
                val,
                compoundAssignmentNode.Operation
                );

            return(DynValue.Zero);
        }
        private void Variaveis()
        {
            CallStack.Push(nameof(Variaveis));

            if (Tokens[IndexAtual].Tipo == TipoToken.Identificador)
            {
                ValidarVariavel();
                IndexAtual++;
                MaisVar();
            }
            else
            {
                ThrowCompiladorException(Tokens[IndexAtual]);
            }

            CallStack.Pop();
        }
Beispiel #17
0
        /// <summary>
        /// Finds the look-ahead set for a production pattern alternative.
        /// The pattern position and maximum look-ahead length must be
        /// specified. It is also possible to specify a look-ahead set
        /// filter, which will make sure that unnecessary token sequences
        /// will be avoided.
        /// </summary>
        /// <param name="alt">The production pattern alternative</param>
        /// <param name="length">The maximum look-ahead length</param>
        /// <param name="pos">The pattern element position</param>
        /// <param name="stack">The call stack used for loop detection</param>
        /// <param name="filter">The look-ahead set filter</param>
        /// <returns>
        /// The look-ahead set for the pattern alternative
        /// </returns>
        /// <exception cref="ParserCreationException">
        /// If an infinite loop was found in the grammar
        /// </exception>
        private LookAheadSet FindLookAhead(
            ProductionPatternAlternative alt,
            int length,
            int pos,
            CallStack stack,
            LookAheadSet filter)
        {
            LookAheadSet first;
            LookAheadSet follow;
            LookAheadSet overlaps;

            // Check trivial cases
            if (length <= 0 || pos >= alt.Count)
            {
                return(new LookAheadSet(0));
            }

            // Find look-ahead for this element
            first = this.FindLookAhead(alt[pos], length, stack, filter);
            if (alt[pos].MinCount == 0)
            {
                first.AddEmpty();
            }

            // Find remaining look-ahead
            if (filter == null)
            {
                length -= first.MinLength;
                if (length > 0)
                {
                    follow = this.FindLookAhead(alt, length, pos + 1, stack, null);
                    first  = first.CreateCombination(follow);
                }
            }
            else if (filter.IsOverlap(first))
            {
                overlaps = first.CreateOverlaps(filter);
                length  -= overlaps.MinLength;
                filter   = filter.CreateFilter(overlaps);
                follow   = this.FindLookAhead(alt, length, pos + 1, stack, filter);
                first.RemoveAll(overlaps);
                first.AddAll(overlaps.CreateCombination(follow));
            }

            return(first);
        }
Beispiel #18
0
        public override DynValue Visit(PostDecrementationNode postDecrementationNode)
        {
            DynValue retVal = null;
            var      name   = postDecrementationNode.Variable.Name;

            if (CallStack.Count > 0)
            {
                var stackTop = CallStack.Peek();

                if (stackTop.ParameterScope.ContainsKey(name))
                {
                    retVal = stackTop.ParameterScope[name].Copy();
                    stackTop.ParameterScope[name] = new DynValue(retVal.Number - 1);
                }
                else if (stackTop.LocalVariableScope.ContainsKey(name))
                {
                    retVal = stackTop.LocalVariableScope[name].Copy();
                    stackTop.LocalVariableScope[name] = new DynValue(retVal.Number - 1);
                }
                else if (Environment.Globals.ContainsKey(name))
                {
                    retVal = Environment.Globals[name].Copy();
                    Environment.Globals[name] = new DynValue(retVal.Number - 1);
                }
                else
                {
                    throw new RuntimeException($"The referenced variable '{name}' was never defined.",
                                               postDecrementationNode.Line);
                }
            }
            else
            {
                if (!Environment.Globals.ContainsKey(name))
                {
                    throw new RuntimeException($"The referenced variable '{name}' was never defined.",
                                               postDecrementationNode.Line);
                }

                retVal = Environment.Globals[name].Copy();
                Environment.Globals[name] = new DynValue(retVal.Number - 1);
            }

            Debug.Assert(retVal != null, "PostDecrementation -- internal interpreter failure: retVal == null?!");
            return(retVal);
        }
Beispiel #19
0
 private void RefreshWatchData(DebugMessage message)
 {
     if (message.WatchData?.Names != null)
     {
         _watchDatas = message.WatchData;
         _hitBreakPointsLock.EnterReadLock();
         try
         {
             // 如果存在Coroutine被阻塞,则在所有的断点上发送DebugMessage以更新当前节点的值
             if (_hitBreakPoints.Count > 0)
             {
                 _watchDatas.Values.Clear();
                 foreach (string watchData in _watchDatas.Names)
                 {
                     string variableName = ModuleUtils.GetVariableNameFromParamValue(watchData);
                     _watchDatas.Values.Add(_context.VariableMapper.GetWatchDataValue(variableName, watchData));
                 }
                 foreach (StepTaskEntityBase blockStep in _hitBreakPoints.Values)
                 {
                     if (null == blockStep)
                     {
                         continue;
                     }
                     CallStack    breakPoint   = blockStep.GetStack();
                     DebugMessage debugMessage = new DebugMessage(MessageNames.BreakPointHitName, _context.SessionId,
                                                                  breakPoint, false)
                     {
                         WatchData = _watchDatas
                     };
                     _context.MessageTransceiver.SendMessage(debugMessage);
                 }
                 _context.LogSession.Print(LogLevel.Debug, _context.SessionId, "Refresh Watch data values.");
             }
         }
         finally
         {
             _hitBreakPointsLock.ExitReadLock();
         }
     }
     else
     {
         _watchDatas.Names.Clear();
         _watchDatas.Values.Clear();
     }
 }
        public override void Before()
        {
            var currentMethod = CallStack.GetCurrentMethod().GetFullName();

            const string path = @"C:\Temp";

            _filePath = Path.ChangeExtension(Path.Combine(path, currentMethod), "png");
            File.Delete(_filePath);

            var settings = new Settings
            {
                ScreenCapturePath = path
            };

            _session = new Session <InternetExplorer>(settings);
            _session.NavigateTo <CheckboxPage>(Url("Checkbox.html"));
            _returnSession = _session.CaptureScreen(_filePath);
        }
Beispiel #21
0
 /// <summary>
 /// 序列参数公共检查方法
 /// </summary>
 /// <param name="instanceVar"></param>
 protected void CommonStepDataCheck(string instanceVar)
 {
     // 判断实例方法的实例是否配置
     if (StepData?.Function != null)
     {
         FunctionType functionType = StepData.Function.Type;
         if (string.IsNullOrWhiteSpace(instanceVar) && (functionType == FunctionType.InstanceFunction ||
                                                        functionType == FunctionType.InstancePropertySetter ||
                                                        functionType == FunctionType.InstanceFieldSetter))
         {
             string currentStack = CallStack.GetStack(Context.SessionId, StepData).ToString();
             Context.LogSession.Print(LogLevel.Error, Context.SessionId,
                                      $"The instance variable of step <{currentStack}> is empty.");
             throw new TestflowDataException(ModuleErrorCode.SequenceDataError,
                                             Context.I18N.GetStr("InvalidParamVar"));
         }
     }
 }
Beispiel #22
0
        /// <summary>
        /// Return string representation of stack, that is displayed in call graph
        /// </summary>
        /// <returns>Call stack string representation</returns>
        private string getStackDescription()
        {
            var output = new StringBuilder();
            var stack  = CallStack.GetStackCopy();

            output.Append("#GLOBALCODE");

            for (int i = 1; i < stack.Length; ++i)
            {
                var ppGraph = stack[i];
                var name    = getName(ppGraph);


                output.AppendFormat("/{0}", name);
            }

            return(output.ToString());
        }
Beispiel #23
0
        public static ILispNode Now(ILispNode functor, IList <ILispNode> arguments, CallStack callStack, params object [] args)
        {
            try
            {
                var formatParam = (arguments.Count > 0)
                    ? arguments[0].Eval(callStack, true)
                    : null;
                var strFormat = (((formatParam == null) || (formatParam is LispNil))
                    ? String.Empty
                    : (formatParam as LispAtom).ValueAsString);

                return(new LispAtom(DateTime.Now.ToString(strFormat)));
            }
            catch
            {
                return(new LispNil());
            }
        }
Beispiel #24
0
        public void TestFixtureSetUp()
        {
            var currentMethod = CallStack.GetCurrentMethod().GetFullName();

            var path = Path.GetTempPath();

            _filePath = Path.ChangeExtension(Path.Combine(path, currentMethod), "png");
            File.Delete(_filePath);

            var settings = new Settings
            {
                ScreenCapturePath = path
            };

            _session = new Session <T>(settings);
            _session.NavigateTo <CheckboxPage>(GetUrl("Checkbox.html"));
            _returnSession = _session.CaptureScreen(_filePath);
        }
Beispiel #25
0
        public void FigureOutCompleted()
        {
            if (CallStack.Peek().HasNext())
            {
                return;
            }

            var lastCall = CallStack.Pop();

            if (CallStack.Count > 0)
            {
                return;
            }

            IsRunning = false;

            Result = lastCall.Result;
        }
        public void Can_Resolve_Variable_From_Local_Scope()
        {
            var callStack = new CallStack(new StackFrameHandlerFactory(), seleniumScriptLogger.Object);

            callStack.Current.AddVariable("global", ReturnType.String, "globalvalue");

            callStack.Push(StackFrameScope.Local);

            callStack.Current.AddVariable("name", ReturnType.String, "value");

            var variable = callStack.ResolveVariable("name");

            Assert.AreEqual("value", variable);

            var globalValue = callStack.ResolveVariable("global");

            Assert.AreEqual("globalvalue", globalValue);
        }
Beispiel #27
0
        public CellProcessorBase(Memory memory, CellOperators operators) : base(memory)
        {
            TestStatus          = new TestStatus();
            CallStack           = new CallStack();
            this.operators      = operators;
            operators.Processor = this;

            Memory.GetItem <Symbols>();
            Memory.GetItem <Procedures>();

            Memory.Add(new FitEnvironment()
            {
                RunTest         = new RunTestDefault(),
                DecorateElement = new DecorateElementDefault()
            });

            ApplicationUnderTest.AddNamespace("fitSharp.Fit.Fixtures");
        }
        private void ListaPar()
        {
            CallStack.Push(nameof(ListaPar));

            Variaveis();
            if (Tokens[IndexAtual].Tipo == TipoToken.SimboloDoisPontos)
            {
                IndexAtual++;
                TipoVar();
                MaisPar();
            }
            else
            {
                ThrowCompiladorException(Tokens[IndexAtual]);
            }

            CallStack.Pop();
        }
Beispiel #29
0
        public static ILispNode List(ILispNode functor, IList <ILispNode> arguments, CallStack callStack, params object[] args)
        {
#if TRACE_FLOW
            try
            {
#endif
            if (arguments.Count < 1)
            {
                return(new LispNil());
            }

            var missing = new LispMissing();
            var result  = new LispList();

            foreach (var xEval in arguments.Select(x => x.Eval(callStack, true)))
            {
                if (xEval is LispMissing)
                {
                    missing.Merge(xEval);
                }
                else
                {
                    result.Add(xEval);
                }
            }

            return((missing.Count() > 0)
                       ? missing
                       : result as ILispNode);

#if TRACE_FLOW
        }

        catch (Exception ex)
        {
            Console.WriteLine("list threw Exception: " + ex.Message);
            throw;
        }
        finally
        {
            Console.WriteLine("(list {0}) done", arguments.ToLispArgString());
        }
#endif
        }
Beispiel #30
0
        public static ILispNode Bool(ILispNode functor, IList <ILispNode> arguments, CallStack callStack, params object [] args)
        {
#if TRACE_FLOW
            try
            {
#endif
            try
            {
                var xEval = arguments[0].Eval(callStack, true);
                if (xEval is LispMissing)
                {
                    return(xEval);
                }

                if (xEval is LispAtom)
                {
                    bool result;
                    if (bool.TryParse((xEval as LispAtom).ValueAsNumber.ToString(), out result))
                    {
                        return(new LispAtom(result));
                    }
                }

                throw new Exception();
            }
            catch
            {
                return(new LispNil());
            }
#if TRACE_FLOW
        }

        catch (Exception ex)
        {
            Console.WriteLine("bool threw Exception" + ex.Message);
            throw;
        }
        finally
        {
            Console.WriteLine("(bool {0}) done", arguments.ToLispArgString());
        }
#endif
        }
Beispiel #31
0
        public static ILispNode Cdr(ILispNode functor, IList <ILispNode> arguments, CallStack callStack, params object[] args)
        {
#if TRACE_FLOW
            try
            {
#endif
            if (arguments.Count != 1)
            {
                throw new Exception("CDR requires exactly 1 argument");
            }
            try
            {
                var arg = arguments[0].Eval(callStack, true);
                if (arg is LispMissing)
                {
                    return(arg);
                }

                if ((arg is LispNil) || (arg is LispAtom))
                {
                    return(new LispNil());
                }

                return((arg as LispList).Cdr);
            }
            catch (Exception)
            {
                return(new LispNil());
            }
#if TRACE_FLOW
        }

        catch (Exception ex)
        {
            Console.WriteLine("cdr threw Exception: " + ex.Message);
            throw;
        }
        finally
        {
            Console.WriteLine("(cdr {0}) done", arguments.ToLispArgString());
        }
#endif
        }
Beispiel #32
0
        public void AddBreakPoint(int sessionId, CallStack breakPoint)
        {
            if (_breakPoints.ContainsKey(sessionId) && _breakPoints[sessionId].Contains(breakPoint))
            {
                return;
            }
            if (!_breakPoints.ContainsKey(sessionId))
            {
                _breakPoints.Add(sessionId, new List <CallStack>(Constants.DefaultRuntimeSize));
            }
            _breakPoints[sessionId].Add(breakPoint);
            RuntimeState runtimeState = _globalInfo.StateMachine.State;

            if (runtimeState == RuntimeState.Running || runtimeState == RuntimeState.Blocked ||
                runtimeState == RuntimeState.DebugBlocked)
            {
                SendAddBreakPointMessage(sessionId, breakPoint);
            }
        }
        private void DcP()
        {
            CallStack.Push(nameof(DcP));

            if (Tokens[IndexAtual].Tipo == TipoToken.ReservadoProcedure)
            {
                IndexAtual++;
                if (Tokens[IndexAtual].Tipo == TipoToken.Identificador)
                {
                    var procedure = new ItemTs
                    {
                        Cadeia     = Tokens[IndexAtual].Cadeia,
                        Escopo     = EscopoStack.Peek(),
                        Tipo       = TipoItemTs.Procedimento,
                        Linha      = Tokens[IndexAtual].Linha,
                        Parametros = new List <Parametro>()
                    };

                    EscopoStack.Push(Tokens[IndexAtual].Cadeia);

                    IndexAtual++;
                    Parametros();

                    AddParametrosNaProcedure(procedure);

                    TabelaDeSimbolos.TryAddNewItem(procedure);

                    CorpoP();

                    EscopoStack.Pop();
                }
                else
                {
                    ThrowCompiladorException(Tokens[IndexAtual]);
                }
            }
            else
            {
                ThrowCompiladorException(Tokens[IndexAtual]);
            }

            CallStack.Pop();
        }
        private void Condicao()
        {
            CallStack.Push(nameof(Condicao));

            Expressao();
            var tipoExpressao1 = TipoItensExpressao.FirstOrDefault();

            Relacao();
            Expressao();
            var tipoExpressao2 = TipoItensExpressao.FirstOrDefault();

            if (tipoExpressao1 != tipoExpressao2)
            {
                throw new CompiladorException(
                          $"Não é possível comparar expressões de tipos diferentes\nLinha: {Tokens[IndexAtual].Linha}\nOu outro erro em linha proxixa");
            }

            CallStack.Pop();
        }
        private void RestoIdent()
        {
            CallStack.Push(nameof(RestoIdent));

            if (Tokens[IndexAtual].Tipo == TipoToken.SimboloAtribuicao)
            {
                IndexAtual++;
                Expressao();
                ValidarTiposAtribuicao();
                GeradorCodigoHipo.AreaDeCodigo.Add(InstrucoesMaquinaHipo.CRCT + "0");                                       //TODO implementar método para obter valor da expressão
                GeradorCodigoHipo.AreaDeCodigo.Add(InstrucoesMaquinaHipo.ARMZ + " " + GeradorCodigoHipo.AreaDeDados.Count); //TODO implementar método para obter valor da expressão
            }
            else
            {
                ListaArg();
            }

            CallStack.Pop();
        }
Beispiel #36
0
        internal static void ConstructHeap()
        {
            PageTable.Initialize();

            MemoryManager.Initialize();
#if OS_WINCE
            UIntPtr heap_commit_size = new UIntPtr(1 << 16);
#elif SINGULARITY
            UIntPtr heap_commit_size = new UIntPtr(1 << 16);
#else
            UIntPtr heap_commit_size = new UIntPtr(1 << 20);
#endif
            UIntPtr os_commit_size = MemoryManager.OperatingSystemCommitSize;
            VTable.Assert(os_commit_size > UIntPtr.Zero);
            VTable.Assert(heap_commit_size >= os_commit_size);
            UIntPtr bootstrapSize;
            if (UIntPtr.Size == 8)
            {
                if (gcType == GCType.ConcurrentMSCollector)
                {
                    // increase bootstrap size so that
                    // the concurrent mark sweep collector will run on
                    // 64-bit Windows
                    bootstrapSize = (UIntPtr)1 << 16;
                }
                else
                {
                    bootstrapSize = (UIntPtr)1 << 15;
                }
            }
            else
            {
                bootstrapSize = (UIntPtr)1 << 14;
            }
            if (bootstrapSize < os_commit_size)
            {
                bootstrapSize = os_commit_size;
            }
            BootstrapMemory.Initialize(bootstrapSize);
            StaticData.Initialize();
            PageManager.Initialize(os_commit_size, heap_commit_size);
            CallStack.Initialize();
        }
Beispiel #37
0
        public CallStack BuildCallStack(int currentOffset, CodeFrame errModule, FileInfo moduleFile, Stack<StackPoint> callChain)
        {
            var syms = new DebugReader(errModule.Symbols);
            var frames = new List<CallFrame>();
            var lp = syms.FindLineSym(currentOffset - 1);
            var retval = new CallStack(
                    moduleFile,
                    lp != null ? lp.Line : 0,
                    lp != null ? lp.Column : 0,
                    frames
                );

            if (callChain == null || callChain.Count == 0)
                return retval;

            var mem = default(StackPoint);
            var first = true;
            var offset = 0;

            do
            {
                mem = callChain.Pop();
                var mod = Assembly.GetModuleName(mem.ModuleHandle);
                syms = new DebugReader(Assembly.GetModule(mem.ModuleHandle).Symbols);
                offset = first ? currentOffset - 1 : mem.BreakAddress - 1;
                var glob = callChain.Count == 0 || offset < 0;
                var funSym = !glob ? syms.FindFunSym(offset) : null;
                var line = syms != null && offset > 0 ? syms.FindLineSym(offset) : null;
                frames.Add(new CallFrame(glob, mod,
                    funSym != null ?
                        funSym.Name != null ? funSym.Name : String.Format(FUNC_PARS, funSym.Parameters) :
                        glob ? null : FUNC,
                    offset, line));
                first = false;
            }
            while (callChain.Count > 0 && offset > 0);

            return retval;
        }
        /**
         * Finds the look-ahead set for a production pattern element. The
         * maximum look-ahead length must be specified. This method does
         * NOT take the element repeat into consideration when creating
         * the look-ahead set. It is also possible to specify a look-ahead
         * set filter, which will make sure that unnecessary token
         * sequences will be avoided.
         *
         * @param elem           the production pattern element
         * @param length         the maximum look-ahead length
         * @param dummy          a parameter to distinguish the method
         * @param stack          the call stack used for loop detection
         * @param filter         the look-ahead set filter
         *
         * @return the look-ahead set for the pattern element
         *
         * @throws ParserCreationException if an infinite loop was found
         *             in the grammar
         */
        private LookAheadSet FindLookAhead(ProductionPatternElement elem,
                                           int length,
                                           int dummy,
                                           CallStack stack,
                                           LookAheadSet filter) {

            LookAheadSet       result;
            ProductionPattern  pattern;

            if (elem.IsToken()) {
                result = new LookAheadSet(length);
                result.Add(elem.Id);
            } else {
                pattern = GetPattern(elem.Id);
                result = FindLookAhead(pattern, length, stack, filter);
                if (stack.Contains(pattern.Name)) {
                    result = result.CreateRepetitive();
                }
            }

            return result;
        }
        /**
         * Finds the look-ahead set for a production pattern element. The
         * maximum look-ahead length must be specified. This method takes
         * the element repeats into consideration when creating the
         * look-ahead set, but does NOT include an empty sequence even if
         * the minimum count is zero (0). It is also possible to specify a
         * look-ahead set filter, which will make sure that unnecessary
         * token sequences will be avoided.
         *
         * @param elem           the production pattern element
         * @param length         the maximum look-ahead length
         * @param stack          the call stack used for loop detection
         * @param filter         the look-ahead set filter
         *
         * @return the look-ahead set for the pattern element
         *
         * @throws ParserCreationException if an infinite loop was found
         *             in the grammar
         */
        private LookAheadSet FindLookAhead(ProductionPatternElement elem,
                                           int length,
                                           CallStack stack,
                                           LookAheadSet filter) {

            LookAheadSet  result;
            LookAheadSet  first;
            LookAheadSet  follow;
            int           max;

            // Find initial element look-ahead
            first = FindLookAhead(elem, length, 0, stack, filter);
            result = new LookAheadSet(length);
            result.AddAll(first);
            if (filter == null || !filter.IsOverlap(result)) {
                return result;
            }

            // Handle element repetitions
            if (elem.MaxCount == Int32.MaxValue) {
                first = first.CreateRepetitive();
            }
            max = elem.MaxCount;
            if (length < max) {
                max = length;
            }
            for (int i = 1; i < max; i++) {
                first = first.CreateOverlaps(filter);
                if (first.Size() <= 0 || first.GetMinLength() >= length) {
                    break;
                }
                follow = FindLookAhead(elem,
                                       length,
                                       0,
                                       stack,
                                       filter.CreateFilter(first));
                first = first.CreateCombination(follow);
                result.AddAll(first);
            }

            return result;
        }
        /**
         * Finds the look-ahead set for a production pattern alternative.
         * The pattern position and maximum look-ahead length must be
         * specified. It is also possible to specify a look-ahead set
         * filter, which will make sure that unnecessary token sequences
         * will be avoided.
         *
         * @param alt            the production pattern alternative
         * @param length         the maximum look-ahead length
         * @param pos            the pattern element position
         * @param stack          the call stack used for loop detection
         * @param filter         the look-ahead set filter
         *
         * @return the look-ahead set for the pattern alternative
         *
         * @throws ParserCreationException if an infinite loop was found
         *             in the grammar
         */
        private LookAheadSet FindLookAhead(ProductionPatternAlternative alt,
                                           int length,
                                           int pos,
                                           CallStack stack,
                                           LookAheadSet filter) {

            LookAheadSet  first;
            LookAheadSet  follow;
            LookAheadSet  overlaps;

            // Check trivial cases
            if (length <= 0 || pos >= alt.Count) {
                return new LookAheadSet(0);
            }

            // Find look-ahead for this element
            first = FindLookAhead(alt[pos], length, stack, filter);
            if (alt[pos].MinCount == 0) {
                first.AddEmpty();
            }

            // Find remaining look-ahead
            if (filter == null) {
                length -= first.GetMinLength();
                if (length > 0) {
                    follow = FindLookAhead(alt, length, pos + 1, stack, null);
                    first = first.CreateCombination(follow);
                }
            } else if (filter.IsOverlap(first)) {
                overlaps = first.CreateOverlaps(filter);
                length -= overlaps.GetMinLength();
                filter = filter.CreateFilter(overlaps);
                follow = FindLookAhead(alt, length, pos + 1, stack, filter);
                first.RemoveAll(overlaps);
                first.AddAll(overlaps.CreateCombination(follow));
            }

            return first;
        }
        /**
         * Finds the look-ahead set for a production pattern. The maximum
         * look-ahead length must be specified. It is also possible to
         * specify a look-ahead set filter, which will make sure that
         * unnecessary token sequences will be avoided.
         *
         * @param pattern        the production pattern
         * @param length         the maximum look-ahead length
         * @param stack          the call stack used for loop detection
         * @param filter         the look-ahead set filter
         *
         * @return the look-ahead set for the production pattern
         *
         * @throws ParserCreationException if an infinite loop was found
         *             in the grammar
         */
        private LookAheadSet FindLookAhead(ProductionPattern pattern,
                                           int length,
                                           CallStack stack,
                                           LookAheadSet filter) {

            LookAheadSet  result;
            LookAheadSet  temp;

            // Check for infinite loop
            if (stack.Contains(pattern.Name, length)) {
                throw new ParserCreationException(
                    ParserCreationException.ErrorType.INFINITE_LOOP,
                    pattern.Name,
                    (String) null);
            }

            // Find pattern look-ahead
            stack.Push(pattern.Name, length);
            result = new LookAheadSet(length);
            for (int i = 0; i < pattern.Count; i++) {
                temp = FindLookAhead(pattern[i],
                                     length,
                                     0,
                                     stack,
                                     filter);
                result.AddAll(temp);
            }
            stack.Pop();

            return result;
        }
Beispiel #42
0
 public void ShowCallStack(CallStack callStack, ThrownException thrownException)
 {
     TreeNode node = this.SelectedClassNode;
     Job worker = Job.Analysis.NewJob(this.ClassTree, (cancelToken) =>
     {
         this.ExceptionTree.Preselect = thrownException.Exception;
         this.ClassTree.ShowCallStack(callStack, node, cancelToken);
     });
     worker.Execute();
 }
        protected override void WalkProperty(IObject propertyObject, CallStack stack)
        {
            base.WalkProperty(propertyObject, stack);

            var nameAsObject = propertyObject.get("name");
            var name = nameAsObject == null ? string.Empty : nameAsObject.ToString();
            if (name != null)
            {
                Result.AppendLine($"{stack.Indentation}public static string @{name} = \"{name}\";");
                Result.AppendLine($"{stack.Indentation}public IElement _{name} = null;");
                Result.AppendLine();
            }
            else
            {
                Debug.WriteLine($"Found unknown property: {propertyObject}");
            }
        }
        /// <summary>
        ///     Creates a C# source code. Not to be used for recursive
        ///     call since the namespace is just once created
        /// </summary>
        /// <param name="element">
        ///     Regards the given element as a package
        ///     and returns a full namespace for the package.
        /// </param>
        private void EndNamespace(ref CallStack stack)
        {
            // Check, if we have namespaces
            Action preAction = () => { };
            Action postAction = () => { };
            if (!string.IsNullOrEmpty(Namespace))
            {
                stack = stack.Owner;
                var indentation = stack.Indentation;
                Result.AppendLine($"{indentation}}}");

                stack = new CallStack(stack);
                stack.Level--;
            }
        }
Beispiel #45
0
 private void processCallStack(CallStack stack)
 {
     runTime.TotalCalls++;
     processPaths(stack);
     processModules(stack);
 }
        protected override void WalkPackage(IObject element, CallStack stack)
        {
            if (stack.Level == 1)
            {
                // Removes the name of the package of the first hierarchy level
                // since it is already included into the class name
                stack.Fullname = string.Empty;
            }

            var name = GetNameOfElement(element);

            var methodStack = stack;
            var innerStack = stack;
            var foreachStack = stack;

            if (stack.Level == 0)
            {
                methodStack = stack.NextWithoutLevelIncrease;
                foreachStack = methodStack.NextWithoutLevelIncrease;
                innerStack = foreachStack.NextWithoutLevelIncrease;

                Result.AppendLine($"{stack.Indentation}public class FillThe{name} : DatenMeister.Filler.IFiller<{ClassNameOfTree}>");
                Result.AppendLine($"{stack.Indentation}{{");

                // Creates the GetNameOfElement helper method
                Result.AppendLine($"{methodStack.Indentation}private static readonly object[] EmptyList = new object[] {{ }};");
                Result.AppendLine($"{methodStack.Indentation}private static string GetNameOfElement(IObject element)");
                Result.AppendLine($"{methodStack.Indentation}{{");
                Result.AppendLine($"{methodStack.Indentation}    var nameAsObject = element.get(\"name\");");
                Result.AppendLine(
                    $"{methodStack.Indentation}    return nameAsObject == null ? string.Empty : nameAsObject.ToString();");
                Result.AppendLine($"{methodStack.Indentation}}}");
                Result.AppendLine();

                Result.AppendLine(
                    $"{methodStack.Indentation}public void Fill(IEnumerable<object> collection, {ClassNameOfTree} tree)");
                Result.AppendLine($"{methodStack.Indentation}{{");
                Result.AppendLine($"{foreachStack.Indentation}FillThe{name}.DoFill(collection, tree);");
                Result.AppendLine($"{methodStack.Indentation}}}");
                Result.AppendLine();

                Result.AppendLine(
                    $"{methodStack.Indentation}public static void DoFill(IEnumerable<object> collection, {ClassNameOfTree} tree)");
                Result.AppendLine($"{methodStack.Indentation}{{");
                Result.AppendLine($"{foreachStack.Indentation}string name;");
                Result.AppendLine($"{foreachStack.Indentation}IElement value;");
                Result.AppendLine($"{foreachStack.Indentation}bool isSet;");

                Result.AppendLine($"{foreachStack.Indentation}foreach (var item in collection)");
                Result.AppendLine($"{foreachStack.Indentation}{{");
                Result.AppendLine($"{innerStack.Indentation}value = item as IElement;");
                Result.AppendLine($"{innerStack.Indentation}name = GetNameOfElement(value);");
            }

            // First, go through the elements
            Result.AppendLine($"{innerStack.Indentation}if (name == \"{name}\") // Looking for package");
            Result.AppendLine($"{innerStack.Indentation}{{");

            var ifStack = innerStack.NextWithoutLevelIncrease;
            var ifForeachStack = ifStack.NextWithoutLevelIncrease;
            Result.AppendLine($"{ifStack.Indentation}isSet = value.isSet(\"packagedElement\");");
            Result.AppendLine(
                $"{ifStack.Indentation}collection = isSet ? (value.get(\"packagedElement\") as IEnumerable<object>) : EmptyList;");
            Result.AppendLine($"{ifStack.Indentation}foreach (var item{ifStack.Level} in collection)");
            Result.AppendLine($"{ifStack.Indentation}{{");
            Result.AppendLine($"{ifForeachStack.Indentation}value = item{ifStack.Level} as IElement;");
            Result.AppendLine($"{ifForeachStack.Indentation}name = GetNameOfElement(value);");

            base.WalkPackage(element, ifStack);

            Result.AppendLine($"{ifStack.Indentation}}}");
            Result.AppendLine($"{innerStack.Indentation}}}");

            if (stack.Level == 0)
            {
                Result.AppendLine($"{foreachStack.Indentation}}}");
                Result.AppendLine($"{methodStack.Indentation}}}");
                Result.AppendLine($"{stack.Indentation}}}");
            }
        }
        /// <summary>
        ///     Creates a C# source code. Not to be used for recursive
        ///     call since the namespace is just once created
        /// </summary>
        /// <param name="element">
        ///     Regards the given element as a package
        ///     and returns a full namespace for the package.
        /// </param>
        private void StartNamespace(ref CallStack stack)
        {
            Result.AppendLine($"{stack.Indentation}// Created by {GetType().FullName} Version {FactoryVersion}");

            // Check, if we have namespaces
            if (!string.IsNullOrEmpty(Namespace))
            {
                var indentation = stack.Indentation;
                    Result.AppendLine($"{indentation}namespace {Namespace}");
                    Result.AppendLine($"{indentation}{{");

                stack = new CallStack(stack);
                stack.Level--;
            }
        }
        /// <summary>
        ///     Parses the packages and creates the C# Code for all the
        ///     packages by recursive calls to itself for packages and
        ///     ParseClasses for classes.
        /// </summary>
        /// <param name="element">Element being parsed</param>
        /// <param name="stack">Callstack being used</param>
        protected override void WalkPackage(IObject element, CallStack stack)
        {
            var name = GetNameOfElement(element);

            Result.AppendLine($"{stack.Indentation}public class _{name}");
            Result.AppendLine($"{stack.Indentation}{{");

            var innerStack = new CallStack(stack);
            innerStack.Fullname = stack.Fullname == null ? name : $"{stack.Fullname}.{name}";

            base.WalkPackage(element, stack);

            if (stack.Level == 0)
            {
                UsedClassName = $"_{name}";
                Result.AppendLine($"{innerStack.Indentation}public static _{name} TheOne = new _{name}();");
                Result.AppendLine();
            }

            Result.AppendLine($"{stack.Indentation}}}");

            Result.AppendLine();

            if (stack.Level > 0)
            {
                Result.AppendLine($"{stack.Indentation}public _{name} {name} = new _{name}();");
                Result.AppendLine();
            }
        }
 private static string generateMessage(CallStack stack)
 {
     if (stack.Count == 0)
         return "before script execution";
     return "at " + stack.Peek().ToString();
 }
        protected CallStack GetCallStackForChild(ItemInfo info)
        {
            // child item - get the stack by moving up the list
            CallStack stack = new CallStack();
            ItemInfo previous = info;

            while (previous != null)
            {
                MethodItem te = previous.Data as MethodItem;
                stack.Push(te.Method);
                previous = previous.PreviousChild;
            }

            return stack;
        }
 public void ExistingPackageCompatible(PackageIdentifier packageIdentifier, CallStack callStack)
 {
     _compatiblePackageVersions.Peek().Add(packageIdentifier, new[] { callStack });
 }
        protected override void WalkProperty(IObject propertyInstance, CallStack stack)
        {
            var name = GetNameOfElement(propertyInstance);
            Result.AppendLine($"{stack.Indentation}if(name == \"{name}\") // Looking for property");
            Result.AppendLine($"{stack.Indentation}{{");
            Result.AppendLine($"{stack.NextIndentation}tree{stack.Fullname}._{name} = value;");

            base.WalkProperty(propertyInstance, stack);

            Result.AppendLine($"{stack.Indentation}}}");
        }
Beispiel #53
0
 private void processModules(CallStack stack)
 {
     for (int i = 0; i < stack.Length; i++)
     {
         Function func = runTime.Functions[stack.GetId(i)];
         if (!runTime.Modules.ContainsKey(func.Module))
             runTime.Modules[func.Module] = new Dictionary<string, Tuple<float, float>>();
         Dictionary<string, Tuple<float, float>> mod = runTime.Modules[func.Module];
         if (!mod.ContainsKey(func.Name))
         {
             mod.Add(func.Name, new Tuple<float,float>(1.0f, i==0? 1.0f : 0.0f));
         }
         else
         {
             Tuple<float,float> prev = mod[func.Name];
             mod[func.Name] = new Tuple<float, float>(prev.Item1 + 1.0f, prev.Item2 + (i == 0 ? 1.0f : 0.0f));
         }
     }
 }
Beispiel #54
0
        void GuardedUpdate(Category category)
        {
            try
            {
                Current = new CallStack
                {
                    Former = Current,
                    Item = new Call
                    {
                        Category = category,
                        Item = this
                    }
                };

                Update(category);
            }
            finally
            {
                Current = Current.Former;
            }
        }
Beispiel #55
0
        private void processPaths(CallStack stack)
        {
            int topId = stack.GetId(stack.Length - 1);
            CallPaths path = null;
            if (!runTime.Paths.ContainsKey(topId))
            {
                path = new CallPaths(topId);
                runTime.Paths.Add(topId, path);
            }
            else
            {
                path = runTime.Paths[topId];
                path.Incl++;
            }

            for (int i = stack.Length - 2; i >= 0; i--)
                path = path.AddChild(stack.GetId(i));

            path.StackEnd();

            // load script section
            Function endFunc = runTime.Functions[stack.GetId(0)];
            runTime.SourceSections.ProcessHit(endFunc.Module, endFunc.Name, stack.GetLine(0));
        }
        /**
         * Calculates the look-ahead needed for the specified production
         * pattern. This method attempts to resolve any conflicts and
         * stores the results in the pattern look-ahead object.
         *
         * @param pattern        the production pattern
         *
         * @throws ParserCreationException if the look-ahead set couldn't
         *             be determined due to inherent ambiguities
         */
        private void CalculateLookAhead(ProductionPattern pattern) {
            ProductionPatternAlternative  alt;
            LookAheadSet                  result;
            LookAheadSet[]                alternatives;
            LookAheadSet                  conflicts;
            LookAheadSet                  previous = new LookAheadSet(0);
            int                           length = 1;
            int                           i;
            CallStack                     stack = new CallStack();

            // Calculate simple look-ahead
            stack.Push(pattern.Name, 1);
            result = new LookAheadSet(1);
            alternatives = new LookAheadSet[pattern.Count];
            for (i = 0; i < pattern.Count; i++) {
                alt = pattern[i];
                alternatives[i] = FindLookAhead(alt, 1, 0, stack, null);
                alt.LookAhead = alternatives[i];
                result.AddAll(alternatives[i]);
            }
            if (pattern.LookAhead == null) {
                pattern.LookAhead = result;
            }
            conflicts = FindConflicts(pattern, 1);

            // Resolve conflicts
            while (conflicts.Size() > 0) {
                length++;
                stack.Clear();
                stack.Push(pattern.Name, length);
                conflicts.AddAll(previous);
                for (i = 0; i < pattern.Count; i++) {
                    alt = pattern[i];
                    if (alternatives[i].Intersects(conflicts)) {
                        alternatives[i] = FindLookAhead(alt,
                                                        length,
                                                        0,
                                                        stack,
                                                        conflicts);
                        alt.LookAhead = alternatives[i];
                    }
                    if (alternatives[i].Intersects(conflicts)) {
                        if (pattern.DefaultAlternative == null) {
                            pattern.DefaultAlternative = alt;
                        } else if (pattern.DefaultAlternative != alt) {
                            result = alternatives[i].CreateIntersection(conflicts);
                            ThrowAmbiguityException(pattern.Name,
                                                    null,
                                                    result);
                        }
                    }
                }
                previous = conflicts;
                conflicts = FindConflicts(pattern, length);
            }

            // Resolve conflicts inside rules
            for (i = 0; i < pattern.Count; i++) {
                CalculateLookAhead(pattern[i], 0);
            }
        }
        /// <summary>
        ///     Parses the packages
        /// </summary>
        /// <param name="element">Element classInstance parsed</param>
        /// <param name="classInstance">The classes that need to be parsed</param>
        /// <param name="stack">Stack to be used</param>
        protected virtual void WalkClass(IObject classInstance, CallStack stack)
        {
            var innerStack = new CallStack(stack);
            var name = GetNameOfElement(classInstance);
            innerStack.Fullname += $".{name}";

            // Needs to be updated
            foreach (var propertyObject in Helper.GetSubProperties(classInstance))
            {
                if (_parser.IsProperty(propertyObject))
                {
                    WalkProperty(propertyObject, innerStack);
                }
            }
        }
        /// <summary>
        ///     Creates a C# source code. Not to be used for recursive
        ///     call since the namespace is just once created
        /// </summary>
        /// <param name="element">
        ///     Regards the given element as a package
        ///     and returns a full namespace for the package.
        /// </param>
        private void Walk(IObject element, CallStack stack)
        {
            if (_parser.IsPackage(element))
            {
                WalkPackage(element, stack);
            }

            if (_parser.IsClass(element))
            {
                WalkClass(element, stack);
            }
        }
Beispiel #59
0
        private void loadCalls()
        {
            BinaryReader reader = new BinaryReader(File.Open(FileName, FileMode.Open));
            int len = (int)reader.BaseStream.Length;

            // verify header
            uint header = (uint)(reader.ReadInt32());
            if (header != 0x10ADB10B) return;

            // version, ignored
            reader.ReadInt32();

            // load modules
            for (string s = reader.ReadNullString(); s.Length > 0; s = reader.ReadNullString())
            {
                //if (s.Contains("str")) MessageBox.Show(s);
                string lines = reader.ReadNullString();
                string[] split = lines.Split('\n');
                runTime.SourceSections.AddModule(s, split);
            }
            // load functions
            for (int funcId = reader.ReadInt32(); funcId != -1; funcId = reader.ReadInt32())
            {
                ;
                string module = reader.ReadNullString();
                string name = reader.ReadNullString();
                Function func = new Function(funcId, module, name);
                runTime.Functions[funcId] = func;
            }

            len -= (int)(reader.BaseStream.Position);
            int pos = 0;
            int id = 0;
            int line = 0;
            CallStack stack = new CallStack();
            while (pos < len)
            {
                mainForm.SetBar(pos, len);
                id = reader.ReadInt32();
                if (id != -1)
                {
                    pos += 2 * sizeof(int);
                    line = reader.ReadInt32();
                    stack.AddCall(id, line);
                    continue;
                }

                // end of call stack, process
                pos += sizeof(int);

                processCallStack(stack);

                stack = new CallStack();
            }
            reader.Close();
        }
 public CallStack(CallStack ownerStack)
 {
     _ownerStack = ownerStack;
     Indentation = ownerStack == null ? string.Empty : $"{ownerStack.NextIndentation}";
     Level = ownerStack?.Level + 1 ?? 0;
     Fullname = ownerStack?.Fullname;
 }