Ejemplo n.º 1
0
 public StaticReference(
     NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
     TypeInfo type
     ) : base(parentNodeIndices, statementIndex, nodeIndex)
 {
     Type = type;
 }
Ejemplo n.º 2
0
            public Invocation(
                NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
                JSVariable thisVariable, JSMethod method, object nonJSMethod,
                Dictionary <string, ArraySegment <string> > variables
                ) : base(parentNodeIndices, statementIndex, nodeIndex)
            {
                if (thisVariable != null)
                {
                    ThisVariable = thisVariable.Identifier;
                }
                else
                {
                    ThisVariable = null;
                }

                ThisType = null;
                Method   = method;
                if (method == null)
                {
                    NonJSMethod = nonJSMethod;
                }
                else
                {
                    NonJSMethod = null;
                }
                Variables = variables;
            }
Ejemplo n.º 3
0
            public Assignment(
                NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
                string target, JSExpression newValue,
                JSOperator @operator,
                TypeReference targetType, TypeReference sourceType
                ) : base(parentNodeIndices, statementIndex, nodeIndex)
            {
                Target   = target;
                NewValue = newValue;

                var newVariable = newValue as JSVariable;

                if (newVariable != null)
                {
                    SourceVariable = newVariable.Identifier;
                }
                else
                {
                    SourceVariable = null;
                }

                SourceType   = sourceType;
                TargetType   = targetType;
                Operator     = @operator;
                IsConversion = !TypeUtil.TypesAreEqual(targetType, sourceType);
            }
Ejemplo n.º 4
0
 public FieldAccess(
     NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
     JSField field, bool isRead
     ) : base(parentNodeIndices, statementIndex, nodeIndex)
 {
     Field  = field;
     IsRead = isRead;
 }
Ejemplo n.º 5
0
 public SideEffect(
     NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
     string variable, string type
     ) : base(parentNodeIndices, statementIndex, nodeIndex)
 {
     Variable = variable;
     Type     = type;
 }
Ejemplo n.º 6
0
 public Access(
     NodeIndices parentNodeIndices, int statementIndex, int nodeIndex,
     string source, bool isControlFlow
     ) : base(parentNodeIndices, statementIndex, nodeIndex)
 {
     Source        = source;
     IsControlFlow = isControlFlow;
 }
Ejemplo n.º 7
0
        /// <summary>Tries to get node index corresponding to given node name. Returns true on success.</summary>
        /// <param name="name">Name of the node.</param>
        /// <param name="index">Index of the node.</param>
        /// <returns></returns>
        public bool TryGetNodeIndex(string name, out int index)
        {
            index = 0;
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new InvalidEnumArgumentException($"Parameter {nameof(name)} must be nonempty.");
            }

            return(NodeIndices.TryGetValue(name, out index));
        }
Ejemplo n.º 8
0
            public NodeIndexGroup(CacheBase Cache, int Address)
            {
                EndianReader Reader = Cache.Reader;

                Reader.SeekTo(Address);

                int iCount  = Reader.ReadInt32();
                int iOffset = Reader.ReadInt32() - Cache.Magic;

                for (int i = 0; i < iCount; i++)
                {
                    NodeIndices.Add(new NodeIndex(Cache, iOffset + 1 * i));
                }
            }
Ejemplo n.º 9
0
 /// <summary>Returns whether given symbol is already used for a device or node.</summary>
 /// <param name="symbol"></param>
 /// <returns></returns>
 private bool IsDefined(string symbol)
 {
     return(DefinedDevices.Contains(symbol) || NodeIndices.ContainsKey(symbol));
 }
Ejemplo n.º 10
0
 /// <summary>Returns dictionary with mappings from node id to their respective names.</summary>
 /// <returns></returns>
 public IDictionary <int, string> GetNodeIdMappings()
 {
     return(NodeIndices.ToDictionary(kvp => kvp.Value, kvp => kvp.Key));
 }
Ejemplo n.º 11
0
 /// <summary>Gives set of node names for given set of indexes</summary>
 /// <param name="indexes"></param>
 /// <returns></returns>
 public IEnumerable <string> GetNodeNames(IEnumerable <int> indexes)
 {
     return(indexes.Select(id => NodeIndices.First(kvp => kvp.Value == id).Key));
 }
Ejemplo n.º 12
0
 public Item(NodeIndices parentNodeIndices, int statementIndex, int nodeIndex)
 {
     ParentNodeIndices = parentNodeIndices;
     StatementIndex    = statementIndex;
     NodeIndex         = nodeIndex;
 }
        /// <summary>
        ///     Aktualisiert den Baumstring.
        /// </summary>
        /// <param name="pTree">Der Baumstring.</param>
        public void UpdateTree(string pTree)
        {
            Debug.WriteLine(pTree);
            lock (_updateTreeLock)
            {
                Reset(pTree);            // Listen neu init. und Positionszeiger des Baumstrings auf 0(Anfang) setzen.
                //+ --------------------------------
                Hash  = Next <string>(); // Hash auslesen
                Index = Next <int>();    // Hauptknotenindex auslesen
                //+ --------------------------------
                // Füge X NULL-Werte in die Listen hinzu. 'X' steht hierbei für den Wert der 'Index'-Variable. In 90aeq und kleiner sind es 20 (gewesen).
                // Die NULL-Werte sind nicht Sinnlos, sondern dienen für bestimmte Befehle.
                // Hier eine Auflistung der Befehle in 90aeq:
                // 0 = Byte auslesen
                // 1 = Boolean auslesen
                // 2 = Byte auslesen
                // 3 = Short auslesen
                // 4 = int auslesen
                // 5 = long auslesen
                // 6 = Float auslesen
                // 7 = Double auslesen
                // 8 = Char auslesen
                // 9 = UTF-String auslesen
                // 11 = Neue Liste
                // 12 = Ende der Liste
                // 13 = Verschlüsselter String?
                // Alles über oder gleich dem Wert der 'Index'-Variable = Node
                for (int i = 0; i < Index; i++)
                {
                    NodeNames.Add(null);
                    NodeIndices.Add(null);
                }
                //+ --------------------------------
                // Füge nun alle Knotennamen in die Liste hinzu.
                while (!IsEmpty())
                {
                    NodeNames.Add(Next <string>());
                }
                //+ --------------------------------
                // Manche Knoten haben nicht wie andere Werte oder andere Knoten gespeichert sondern bestimmte Werte.
                for (int i = Index; i < NodeNames.Count; i++)
                {
                    if (!NodeValues.ContainsKey(NodeNames[i]))
                    {
                        NodeValues.Add(NodeNames[i], i);
                    }
                }
                //+ --------------------------------
                // Fügt alle Indices eines Knotens in eine Liste hinzu.
                // Key = Knotenname
                // Value = Index
                // Die Indices geben die Unterknoten des Knotens zurück.

                #region " BEISPIEL "

                // Baum: 1337;20;PROTOCOL_HASH;;5;;:
                // KEY = PROTOCOL_HASH
                // VALUE = List<int>() { 5 };
                // 5 Gibt an das der Knoten ein Long zurückgibt. Siehe oben in der Befehlsliste.

                #endregion

                while (NodeIndices.Count < NodeNames.Count)
                {
                    var indices = new List <int>();
                    while (!IsEmpty())
                    {
                        indices.Add(Next <int>());
                    }
                    NodeIndices.Add(indices);
                }
                //+ --------------------------------
                // Springt zur Stelle an der ':' steht.
                Next <object>(':');
                //+ --------------------------------
                for (int i = Index; i < NodeIndices.Count; i++)
                {
                    List <int> indices = NodeIndices[i];
                    foreach (int t in indices)
                    {
                        if (t != 0)
                        {
                            continue;
                        }
                        var values = new Dictionary <string, int>();
                        for (int k = 0; !IsEmpty(); k++)
                        {
                            values.Add(Next <string>(), k);
                        }
                        NodeValues[NodeNames[i]] = values;
                    }
                }
            }
        }