Пример #1
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.documentPosition = documentPosition;
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
 }
Пример #2
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
     SourceCodePosition = sourcePosition;
 }
Пример #3
0
        public MethodDisassembly(MethodDefinition methodDef, MapFileLookup mapFile = null, TypeEntry typeEntry = null, MethodEntry methodEntry = null)
        {
            _typeEntry = typeEntry;
            _methodEntry = methodEntry;
            _methodDef = methodDef;
            _mapFile = mapFile;

            JumpTargetOffsets=new HashSet<int>();
            ExceptionHandlerOffsets = new HashSet<int>();

            if (methodDef.Body != null)
            {
                foreach (var i in methodDef.Body.Instructions)
                {
                    var op = i.Operand as Instruction;
                    if (op != null)
                        JumpTargetOffsets.Add(op.Offset);
                }
                foreach (var e in methodDef.Body.Exceptions)
                {
                    foreach(var c in e.Catches)
                        ExceptionHandlerOffsets.Add(c.Instruction.Offset);
                    if (e.CatchAll != null)
                        ExceptionHandlerOffsets.Add(e.CatchAll.Offset);
                }
            }

            Format = FormatOptions.Default;
        }
Пример #4
0
        /// <summary>
        /// Create a new location breakpoint.
        /// </summary>
        protected override DalvikLocationBreakpoint CreateLocationBreakpoint(SourceCodePosition sourceCode, TypeEntry typeEntry, MethodEntry methodEntry, object data)
        {
            // Create breakpoint objects
            var pendingBreakpoint = (DebugPendingBreakpoint)data;
            var boundBreakpoint = new DebugBoundBreakpoint<DebugLocationBreakpoint>(pendingBreakpoint, this, enum_BP_TYPE.BPT_CODE, x => new DebugLocationBreakpoint(Jdwp.EventKind.BreakPoint, sourceCode, typeEntry, methodEntry, x));

            // Return breakpoint
            return boundBreakpoint.Breakpoint;
        }
Пример #5
0
 /// <summary>
 /// Create from a reader.
 /// </summary>
 public FrameworkTypeMap(Stream stream)
 {
     var doc = CompressedXml.Load(stream);
     foreach (var element in doc.Root.Elements("type"))
     {
         var entry = new TypeEntry(element);
         classMap[entry.ClassName] = entry;
         typeMap[entry.FullName] = entry;
     }
 }
Пример #6
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DocumentLocation(Location location, SourceCodePosition sourceCode, DalvikReferenceType referenceType, DalvikMethod method, TypeEntry typeEntry, MethodEntry methodEntry)
 {
     if (location == null)
         throw new ArgumentNullException("location");
     Location = location;
     SourceCode = sourceCode;
     ReferenceType = referenceType;
     Method = method;
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
 }
Пример #7
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DocumentLocation(Location location, Document document, DocumentPosition position, DalvikReferenceType referenceType, DalvikMethod method, TypeEntry typeEntry, MethodEntry methodEntry)
 {
     if (location == null)
         throw new ArgumentNullException("location");
     Location = location;
     Document = document;
     Position = position;
     ReferenceType = referenceType;
     Method = method;
     this.typeEntry = typeEntry;
     this.methodEntry = methodEntry;
 }
Пример #8
0
 //-----------------------------------------------------------------------------
 // There is a circular reference.
 //-----------------------------------------------------------------------------
 public static SymbolErrorException CircularReference(TypeEntry t)
 {
     return new SymbolErrorException(
         Code.cCircularReference,            
         t.Node.Location, 
         "Type '" + t.FullName + "' is in a circular reference"
     );
 }
Пример #9
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, BreakpointBookmark bookmark)
     : base(eventKind, sourcePosition, typeEntry, methodEntry)
 {
     this.bookmark = bookmark;
     InvalidateBookmark();
 }
Пример #10
0
    public void RegisterNode(Type type)
    {
        if (type.BaseType.Equals(typeof(BNodeAction)))
        {
            TypeEntry typeEntry = listTypeEntry.Find(e => e.type == type.BaseType);
            typeEntry.childrenType.Add(new TypeEntry(type, (Activator.CreateInstance(type) as BNode).NodeName));

            Debug.LogError("RegisterNode BNodeAction  " + type.Name);
            dicTypeToUI.Add(type, "NodeActionUI");
        }
        else if (type.BaseType.Equals(typeof(BNodeCondition)))
        {
            TypeEntry typeEntry = listTypeEntry.Find(e => e.type == type.BaseType);
            typeEntry.childrenType.Add(new TypeEntry(type, (Activator.CreateInstance(type) as BNode).NodeName));

            Debug.LogError("RegisterNode BNodeCondition  " + type.Name);
            dicTypeToUI.Add(type, "NodeConditionUI");
        }
        else if (type.BaseType.Equals(typeof(BNodeComposite)))
        {
            TypeEntry typeEntry = listTypeEntry.Find(e => e.type == type.BaseType);
            typeEntry.childrenType.Add(new TypeEntry(type, (Activator.CreateInstance(type) as BNode).NodeName));
            Debug.LogError("(Activator.CreateInstance(type) as BNode).NodeName  " + (Activator.CreateInstance(type) as BNode).NodeName + "  type  " + type);

            Debug.LogError("RegisterNode BNodeComposite  " + type.Name);
            if (type.Equals(typeof(BNodeIterator)))
            {
                dicTypeToUI.Add(type, "NodeIteratorUI");
            }
            else if (type.Equals(typeof(BNodeParallel)))
            {
                dicTypeToUI.Add(type, "NodeParallelUI");
            }
            else if (type.Equals(typeof(BNodeRandom)))
            {
                dicTypeToUI.Add(type, "NodeRandomUI");
            }
            else if (type.Equals(typeof(BNodeSelector)))
            {
                dicTypeToUI.Add(type, "NodeSelectorUI");
            }
            else if (type.Equals(typeof(BNodeSequence)))
            {
                dicTypeToUI.Add(type, "NodeSequenceUI");
            }
            else if (type.Equals(typeof(BNodeInverse)))
            {
                dicTypeToUI.Add(type, "NodeInverseUI");
            }
        }
        else if (type.BaseType.Equals(typeof(BNodeDecorator)))
        {
            TypeEntry typeEntry = listTypeEntry.Find(e => e.type == type.BaseType);
            typeEntry.childrenType.Add(new TypeEntry(type, (Activator.CreateInstance(type) as BNode).NodeName));

            Debug.LogError("RegisterNode BNodeDecorator  " + type.Name);
            dicTypeToUI.Add(type, "NodeDecoratorUI");
        }
        else if (type.Equals(typeof(BNodeRoot)))
        {
            Debug.LogError("ui BNodeRoot  " + type.Name);
            dicTypeToUI.Add(type, "NodeRootUI");
        }
    }
Пример #11
0
 //-----------------------------------------------------------------------------
 // The methdo must be public because it is implementing an interface.
 //-----------------------------------------------------------------------------
 public static SymbolErrorException IMethodMustBePublic(        
     FileRange location,
     MethodExpEntry mInterface,
     TypeEntry tClass
     
     )
 {
     string stClass = tClass.FullName;
     string stMethod = mInterface.PrettyDecoratedName;
     string stInterface = mInterface.SymbolClass.FullName;
     
     return new SymbolErrorException(
         Code.cIMethodMustBePublic, 
         location,
         "The method '" + stMethod + "' must be public to implement interface '" + stInterface + "'");
 }
Пример #12
0
		/// <summary>
		/// Create custom breakpoint.
		/// </summary>
		protected override DalvikLocationBreakpoint CreateLocationBreakpoint(DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, object data)
		{
			return new DebugLocationBreakpoint(Jdwp.EventKind.BreakPoint, documentPosition, typeEntry, methodEntry, (BreakpointBookmark)data);
		}
Пример #13
0
 /// <summary>
 /// Create a new location breakpoint.
 /// </summary>
 protected virtual DalvikLocationBreakpoint CreateLocationBreakpoint(SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, object data)
 {
     return(new DalvikLocationBreakpoint(Jdwp.EventKind.BreakPoint, sourcePosition, typeEntry, methodEntry));
 }
Пример #14
0
 public GlobalSymbolTable Add(TypeEntry typeEntry) =>
     new GlobalSymbolTable(this.TypeDefs.Add(typeEntry), this.Enums, this.GlobalObjects);
Пример #15
0
//-----------------------------------------------------------------------------
// Helper to import the specific type and return a TypeEntry. 
// This will recursively import all base types.
// Returns null if we can't import the type.
//-----------------------------------------------------------------------------         
    protected TypeEntry AddImportedType(System.Type tImport)
    {     
        #if true   
        // Don't import non-public classes
        // be wary of nesting
        //if (tImport.IsClass || tImport.IsValueType)
        {
            if (tImport.DeclaringType == null)
            {
                // Not nested
                if (!tImport.IsPublic)
                    return null;
            } else {
                // If Nested, check topmost containing class.
                System.Type t = tImport;
                while (t.DeclaringType != null)
                {
                    t = t.DeclaringType;
                }
                if (!t.IsPublic)
                    return null;            
            }
        }
        #endif
                    
        // If we've already imported this, then nothing to do.   
        {
            TypeEntry t = TryLookupCLRType(tImport);
            if (t != null)
                return t;
        }
        
        // Blue doesn't handle Generics (from V2.0 CLR), so just ignore them when imported.
        if (IsGenericType(tImport))
        {
            Console.WriteLine("Skipping Generic type:" + tImport.FullName);
            return null;
        }

        #if false
        // Debugging facility. Userbreakpoint when we import a specific class.
        if (tImport.Name == "IDictionaryEnumerator")
            System.Diagnostics.Debugger.Break();
        #endif
        
        // Stub immediately to avoid infinite cycles.        
        TypeEntry tBlue = TypeEntry.CreateImportStub(tImport);
        m_hashClrType.Add(tImport, tBlue);
                
        // If we're a nested type, make sure our containing type is imported.                        
        if (tImport.DeclaringType != null)
        {
            AddImportedType(tImport.DeclaringType);
        }
                      
        
        Scope scope = this.CreateImportedContext(tImport);
                             
        
        string stClass = tImport.Name;     
        
        // Already check for multiple imports       
        //if (LookupSymbol(scope, stClass, false) == null)
        {           
            
            // Add Base class
            TypeEntry tSuper = null;            
            if (tImport.BaseType != null)
            {                
                tSuper = AddImportedType(tImport.BaseType);
            }
                
            // Add interfaces, removing all interfaces that we can't access
            System.Type [] tCLRInterfaces = tImport.GetInterfaces();
            ArrayList al = new ArrayList(tCLRInterfaces.Length);            
            
            foreach(System.Type tInterface in tCLRInterfaces)
            {                
                TypeEntry t = AddImportedType(tInterface);
                if (t != null)
                    al.Add(t);
            }
            TypeEntry [] tBlueInterfaces = (TypeEntry[]) al.ToArray(typeof(TypeEntry));
            
            TypeEntry tParent = (tImport.DeclaringType == null) ? 
                null :
                this.ResolveCLRTypeToBlueType(tImport.DeclaringType);
                       
            // @todo - do we have to check if we've been imported again?
            
            // We create the symbol, but don't add the scope until we need to.
            // (else that would be a lot of scopes to add that we'd never use)
            // Note that this must be done on the same reference that we added at the top
            // because by now, the other types have links to that original reference.
            tBlue.FinishImportStub(tSuper, tBlueInterfaces, tParent);
            scope.AddSymbol(tBlue);
                
            
#if true   
            // If we have any nested classes, add them.
            // This will require us to create the class scope.            
            System.Type [] tNestedTypes = tImport.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic);
            if (tNestedTypes.Length > 0)
            {
                tBlue.EnsureScopeCreated();
                foreach(System.Type tNested in tNestedTypes)
                {                
                    AddImportedType(tNested);
                }
            }
#endif            
            return tBlue;
        } 
        /*
        else 
        {            
            ThrowError(SymbolError.IllegalAssembly(tImport.Assembly, 
                "Class '" + tImport.FullName + "' defined multiple times"));
            return null;
        }
        */
    
    } // end function
Пример #16
0
        private bool LaunchLocal()
        {
            string dbFile = m_resultsFileTextBox.Text;

            if (!m_launcher.CheckParams())
            {
                return(false);
            }

            //connect to data engine before launching the process -- we don't want to launch if this fails
            IDataEngine data = null;

            if (m_connectCheckBox.Checked)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;
                    if (m_sqliteRadio.Checked)
                    {
                        data = new SQLiteEngine(dbFile, true);
                    }
                    else if (m_sqliteMemoryRadio.Checked)
                    {
                        data = new SQLiteMemoryEngine();
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Launch Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }

            if (!m_launcher.Launch())
            {
                if (data != null)
                {
                    data.Dispose();
                }
                return(false);
            }

            //connect, if we're asked to
            if (m_connectCheckBox.Checked)
            {
                ConnectProgress progress = new ConnectProgress("localhost", m_launcher.ListenPort, data, 10);
                progress.ShowDialog(this);

                if (progress.Client != null)
                {
                    Connection conn = new Connection(data);
                    conn.Executable = m_launcher.Name;
                    conn.RunClient(progress.Client);
                    //TODO: set options like auto snapshot frequency
                    conn.SetAutoSnapshots(10000, false);

                    var profilerWindow = new ProfilerWindow(m_mainWindow, conn);
                    profilerWindow.Show();

                    TypeEntry visEntry = m_visualizerCombo.SelectedItem as TypeEntry;
                    if (visEntry != null && visEntry.Type != null)
                    {
                        profilerWindow.AddVisualizer(visEntry.Type);
                    }

                    profilerWindow.BringToFront();
                }
                else
                {
                    //connection failed, shut down the storage
                    data.Dispose();
                }
            }

            return(true);
        }
Пример #17
0
 public LocalSymbolTable Add(TypeEntry typeEntry) =>
 new LocalSymbolTable(this.TypeDefs.Add(typeEntry), this.Enums, this.FrameObjects);
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.typeEntry     = typeEntry;
     this.methodEntry   = methodEntry;
     SourceCodePosition = sourcePosition;
 }
Пример #19
0
 // Expose constructor that takes an already resolved type
 // Very useful when we build/modify parts of the AST during resolution
 public ResolvedTypeSig(TypeEntry t)
 {
     Debug.Assert(!t.IsRef, "Don't expect ref types");
     Debug.Assert(t != null);
     m_type = t;
 }
Пример #20
0
 public void SetCurrentClass(TypeEntry type)
 {
     m_curClass = type;
 }
Пример #21
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DalvikLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry)
     : base(eventKind)
 {
     this.documentPosition = documentPosition;
     this.typeEntry        = typeEntry;
     this.methodEntry      = methodEntry;
 }
Пример #22
0
 private bool IsDelegateInstance(TypeEntry type)
 {
     return type != null && type.ScopeId != null && type.ScopeId.Contains(":delegate:");
 }
Пример #23
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, DebugBoundBreakpoint <DebugLocationBreakpoint> boundBreakpoint)
     : base(eventKind, documentPosition, typeEntry, methodEntry)
 {
     this.boundBreakpoint = boundBreakpoint;
 }
Пример #24
0
//-----------------------------------------------------------------------------
// Create the scopes for an imported types
//-----------------------------------------------------------------------------
    Scope CreateImportedContext(System.Type tImport)
    {
        // Traverse namespaces to find scope
        Scope scope = m_scopeGlobal;
        string s = tImport.ToString();
               
        // In a type's string name, the '.' separates namespaces,
        // the '+' separates for nested classes.        
        // Valid form:
        // i.i.i+i+i+i
                        
        int iStart  = 0;
        int i       = s.IndexOf('.');            
        
        // Search past namespaces
        while(i != -1) 
        {                
            string stNamespace = s.Substring(iStart, i - iStart);
            SymEntry sym = LookupSymbol(scope, stNamespace, false);
                                               
            if (sym == null) 
            {            
                ImportedNamespaceEntry nsImported = new ImportedNamespaceEntry(
                    stNamespace, 
                    s.Substring(0, i)
                    );
                    
                scope.AddSymbol(nsImported);
                    
                scope = nsImported.ChildScope;
            } 
            else 
            {
                // If the symbol already exists, must be a namespace                    
                if (sym is NamespaceEntry) 
                {
                    scope = ((NamespaceEntry) sym).ChildScope;
                } 
                else 
                {
                    ThrowError(SymbolError.IllegalAssembly(tImport.Assembly, "Illegal type: " + s));
                }
            }
            iStart = i + 1;
            i = s.IndexOf('.', iStart);
        }
                   
        // If we're not a nested type, then we can return the scope now
        if (tImport.DeclaringType == null)                   
        {
            Debug.Assert(s.Substring(iStart) == tImport.Name);
            return scope;
        }
        
        // Containing class should have already been added.
        Debug.Assert(TryLookupCLRType(tImport.DeclaringType) != null);
                        
        // Else we have to traverse the class scopes to find out containing scope.        
        // n.n. c1+c2
        i = s.IndexOf('+', iStart);   
        while (i != -1)
        {
            string stClass = s.Substring(iStart, i - iStart);
            
            TypeEntry tBlue = (TypeEntry) LookupSymbol(scope, stClass, true);
            scope = tBlue.MemberScope;
            Debug.Assert(scope != null);
        
            iStart = i + 1;
            i = s.IndexOf('+', iStart);        
        }
        
        Debug.Assert(s.Substring(iStart) == tImport.Name);
        
        return scope;
    }
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, BreakpointBookmark bookmark) :
     base(eventKind, sourcePosition, typeEntry, methodEntry)
 {
     this.bookmark = bookmark;
     InvalidateBookmark();
 }
Пример #26
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DocumentLocation(Location location, SourceCodePosition sourceCode, DalvikReferenceType referenceType, DalvikMethod method, TypeEntry typeEntry, MethodEntry methodEntry)
 {
     if (location == null)
     {
         throw new ArgumentNullException("location");
     }
     Location         = location;
     SourceCode       = sourceCode;
     ReferenceType    = referenceType;
     Method           = method;
     this.typeEntry   = typeEntry;
     this.methodEntry = methodEntry;
 }
Пример #27
0
 /// <summary>
 /// Try to get a type from the given java class name.
 /// Will ignore the case.
 /// </summary>
 public bool TryGetFromClassName(string javaClassName, out TypeEntry entry)
 {
     return classMap.TryGetValue(javaClassName, out entry);
 }
Пример #28
0
    void OnClickPop1Item(GameObject sender)
    {
        if (lastClickPop1Item == sender)
        {
            return;
        }
        if (lastClickPop1Item != null)
        {
            lastClickPop1Item.GetComponent <Image>().color = normalColor;
        }
        TypeEntry typeEntry = sender.GetComponent <BtnNodeAddItem>().typeEntry;

        if (typeEntry.type == typeof(BNodeRoot))
        {
            Debug.LogError("BNodeRoot");

            string outPath = Application.dataPath + "/Config/BTJson";
            if (!Directory.Exists(outPath))
            {
                Directory.CreateDirectory(outPath);
            }

            string filepath = EditorUtility.OpenFilePanel("Bahvior Tree", outPath, "json");
            if (filepath == "")
            {
                return;
            }

            string txt = File.ReadAllText(filepath);

            BTree    tree = new BTree();
            JsonData json = JsonMapper.ToObject(txt);
            tree.InitTreeByJsonData(json);

            if (isInsert)
            {
                int index = currentNode.ParentNode.ListChildren.IndexOf(currentNode);
                currentNode.ParentNode.InsertChild(tree.rootNode, index);
            }
            else
            {
                currentNode.AddChild(tree.rootNode);
            }

            editorUI.DrawTree(editorUI.currentTree);

            Reset();
        }
        else
        {
            for (int i = 0; i < listPop2Items.Count; i++)
            {
                GameObject.Destroy(listPop2Items[i].gameObject);
            }
            listPop2Items.Clear();

            sender.GetComponent <Image>().color = selectColor;

            Pop2.gameObject.SetActive(true);
            Vector3 pos = Pop2.GetComponent <RectTransform>().localPosition;
            pos.y = sender.GetComponent <RectTransform>().localPosition.y;
            Pop2.GetComponent <RectTransform>().localPosition = pos;

            for (int i = 0; i < typeEntry.childrenType.Count; i++)
            {
                TypeEntry te = typeEntry.childrenType[i];

                GameObject btnNodeAddItem = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath(EditorUI.EditorUIPrefabPath + "BtnNodeAddItemPop2.prefab", typeof(GameObject))) as GameObject;
                listPop2Items.Add(btnNodeAddItem);
                btnNodeAddItem.transform.SetParent(Pop2ItemsContainer);
                btnNodeAddItem.GetComponent <RectTransform>().localScale   = Vector3.one;
                btnNodeAddItem.GetComponent <ButtonCustom>().onClickCustom = OnClickPop2Item;
                pos   = new Vector3();
                pos.x = 35;
                pos.y = 170 - 40 * i;
                pos.z = 0;
                btnNodeAddItem.GetComponent <RectTransform>().localPosition      = pos;
                btnNodeAddItem.GetComponent <BtnNodeAddItem>().typeEntry         = te;
                btnNodeAddItem.transform.Find("Text").GetComponent <Text>().text = te.typeName;
            }
            Vector2 size = Pop2.Find("Pop2BG").GetComponent <RectTransform>().sizeDelta;
            if (typeEntry.childrenType.Count > 4)
            {
                size.y = 200 + (typeEntry.childrenType.Count - 4) * 40;
            }
            else
            {
                size.y = 200;
            }

            Pop2.Find("Pop2BG").GetComponent <RectTransform>().sizeDelta = size;
            lastClickPop1Item = sender;
        }
    }
Пример #29
0
        /// <summary>
        /// Create a new location breakpoint.
        /// </summary>
        protected override DalvikLocationBreakpoint CreateLocationBreakpoint(SourceCodePosition sourceCode, TypeEntry typeEntry, MethodEntry methodEntry, object data)
        {
            // Create breakpoint objects
            var pendingBreakpoint = (DebugPendingBreakpoint)data;
            var boundBreakpoint   = new DebugBoundBreakpoint <DebugLocationBreakpoint>(pendingBreakpoint, this, enum_BP_TYPE.BPT_CODE, x => new DebugLocationBreakpoint(Jdwp.EventKind.BreakPoint, sourceCode, typeEntry, methodEntry, x));

            // Return breakpoint
            return(boundBreakpoint.Breakpoint);
        }
 private static string GetTypeScopeId(TypeEntry type)
 {
     return(GetTypeScopeId(type.Scope, type.ScopeId, type.Name));
 }
Пример #31
0
    // Semantic checking
    public override void ResolveMember(
        TypeEntry symDefiningClass, 
        ISemanticResolver s,
        ICLRtypeProvider provider
    )
    {
        //TypeEntry tRetType = null;
        if (!IsCtor)
        {
            m_tRetType.ResolveType(s);
            //tRetType = m_tRetType.TypeRec;
        } 
        else 
        {            
            ClassDecl nodeClass = symDefiningClass.Node;
            if (Mods.IsStatic)
            {
                // Checks on static ctors
                if (this.Params.Length != 0)
                {
                    //s.ThrowError_NoParamsOnStaticCtor(this);
                    ThrowError(SymbolError.NoParamsOnStaticCtor(this));
                }

                // Rename to avoid a naming collision w/ a default ctor.
                // Since no one will call a static ctor (and codegen ignores ctor names),
                // we can pick anything here.
                //this.m_strName = "$static_ctor";
                this.m_idName = new Identifier("$static_ctor", m_idName.Location);

                // Is there a static field initializer to chain to?
                if (nodeClass.StaticInitMethod != null)
                {
                    /*                           
                    Statement stmt = new ExpStatement(
                        new MethodCallExp(
                        null,
                        new Identifier(nodeClass.StaticInitMethod.Name, nodeClass.StaticInitMethod.Location),
                        new ArgExp[0]
                        ));
                    */
                    // If there are Static, ReadOnly fields, then they must be assigned directly
                    // in a constructor, not in a function called by the constructor.
                    Statement stmt = nodeClass.StaticInitMethod.Body;
                    Body.InjectStatementAtHead(stmt);                    
                }
            } // static ctor
            else 
            {
                if (nodeClass.InstanceInitMethod != null)
                {
                    // Chain to an instance-field initializer if we don't chain to
                    // a this() ctor.
                    CtorChainStatement chain = (this.Body.Statements[0]) as CtorChainStatement;
                    Debug.Assert(chain != null);
                    
                    if (chain.TargetType == CtorChainStatement.ETarget.cBase)
                    {       
                        /*                 
                        Statement stmt = new MethodCallStatement(
                            new MethodCallExp(
                                null,
                                new Identifier(nodeClass.InstanceInitMethod.Name, nodeClass.InstanceInitMethod.Location),
                                new ArgExp[0]
                            ));
                        */
                        // PEVerify barfs if we try to do an instance method call in the ctor,
                        // so just inject the raw method body. It's just a bunch of assigns anyway,
                        // so we're ok.
                        Statement stmt = nodeClass.InstanceInitMethod.Body;
                            
                        Body.InjectStatementAtHead(stmt);
                    }
                }
            } // instance ctor
        }
                       
        // Add new sym entry to our parent class's scope
        MethodExpEntry m = new MethodExpEntry(
            Name, 
            this, 
            symDefiningClass, 
            IsCtor ? null : m_tRetType.BlueType
        );
        
        m.m_scope = new Scope(
            "method: " + symDefiningClass.m_strName + "." + Name, 
            this,
            symDefiningClass.MemberScope);
        
        m_symbol = m;
        
        //s.PushScope(m.m_scope);
        Scope prev = s.SetCurrentContext(m.m_scope);
        
        // resolve params (because we'll need them for overloading)
        // Add param 0 for 'this' (if not static)
        // For structs, "this" is a reference, for classes, it's a value.
        if (!Mods.IsStatic)
        {
            ParamVarExpEntry e = new ParamVarExpEntry();
            e.m_strName = "this";
            
            TypeEntry t = m_symbol.SymbolClass;
            if (t.IsStruct)
            {
                t = new RefTypeEntry(t, s);
            }
            e.m_type = t; // 'this' is the type of the containg class   
            e.CodeGenSlot = 0;
            s.GetCurrentContext().AddSymbol(e);
        }
        
        // do rest of the params
        foreach(ParamVarDecl param in m_arParams)
        {
            param.ResolveVarDecl(s);
        }

        //s.PopScope(m.m_scope);
        s.RestoreContext(prev);
                
        symDefiningClass.AddMethodToScope(m);
    }
 private bool IsDelegateInstance(TypeEntry type)
 {
     return(type != null && type.ScopeId != null && type.ScopeId.Contains(":delegate:"));
 }
Пример #33
0
 //-----------------------------------------------------------------------------
 // Missing an method inherited from an interface
 //-----------------------------------------------------------------------------
 public static SymbolErrorException MissingInterfaceMethod(        
     FileRange location,
     MethodExpEntry mInterface,
     TypeEntry tClass        
     )
 {
     string stClass = tClass.FullName;
     string stMethod = mInterface.PrettyDecoratedName;
     string stInterface = mInterface.SymbolClass.FullName;
     
     return new SymbolErrorException(
         Code.cMissingInterfaceMethod, 
         location,
         "The type '"+stClass+"' does not implement method '"+
         stMethod + "' from interface '" + stInterface + "'");
 }
Пример #34
0
        private void setupStruct()
        {
            this.Magic = new TypeEntry <MagicNumber>(entries, this.is32Bit, "Magic", headerBaseAddress, EntrySize._16Bits);

            this.MajorLinkerVersion = new NumericEntry(entries, this.is32Bit, "MajorLinkerVersion", headerBaseAddress, EntrySize._8Bits);

            this.MinorLinkerVersion = new NumericEntry(entries, this.is32Bit, "MinorLinkerVersion", headerBaseAddress, EntrySize._8Bits);

            this.SizeOfCode = new NumericEntry(entries, this.is32Bit, "SizeOfCode", headerBaseAddress, EntrySize._32Bits);

            this.SizeOfInitializedData = new NumericEntry(entries, this.is32Bit, "SizeOfInitializedData", headerBaseAddress, EntrySize._32Bits);

            this.SizeOfUninitializedData = new NumericEntry(entries, this.is32Bit, "SizeOfUninitializedData", headerBaseAddress, EntrySize._32Bits);

            this.AddressOfEntryPoint = new NumericEntry(entries, this.is32Bit, "AddressOfEntryPoint", headerBaseAddress, EntrySize._32Bits);

            this.BaseOfCode = new NumericEntry(entries, this.is32Bit, "BaseOfCode", headerBaseAddress, EntrySize._32Bits);

            // BaseOfData is not in x64
            if (this.is32Bit)
            {
                this.BaseOfData = new NumericEntry(entries, this.is32Bit, "BaseOfData", headerBaseAddress, EntrySize._32Bits);
            }

            this.ImageBase = new NumericEntry(entries, this.is32Bit, "ImageBase", headerBaseAddress, EntrySize._32Bits, EntrySize._64Bits);

            this.SectionAlignment = new NumericEntry(entries, this.is32Bit, "SectionAlignment", headerBaseAddress, EntrySize._32Bits);

            this.FileAlignment = new NumericEntry(entries, this.is32Bit, "FileAlignment", headerBaseAddress, EntrySize._32Bits);

            this.MajorOSVersion = new NumericEntry(entries, this.is32Bit, "MajorOSVersion", headerBaseAddress, EntrySize._16Bits);

            this.MinorOSVersion = new NumericEntry(entries, this.is32Bit, "MinorOSVersion", headerBaseAddress, EntrySize._16Bits);

            this.MajorImageVersion = new NumericEntry(entries, this.is32Bit, "MajorImageVersion", headerBaseAddress, EntrySize._16Bits);

            this.MinorImageVersion = new NumericEntry(entries, this.is32Bit, "MinorImageVersion", headerBaseAddress, EntrySize._16Bits);

            this.MajorSubsystemVersion = new NumericEntry(entries, this.is32Bit, "MajorSubsystemVersion", headerBaseAddress, EntrySize._16Bits);

            this.MinorSubsystemVersion = new NumericEntry(entries, this.is32Bit, "MinorSubsystemVersion", headerBaseAddress, EntrySize._16Bits);

            this.Win32VersionValue = new NumericEntry(entries, this.is32Bit, "Win32VersionValue", headerBaseAddress, EntrySize._32Bits);

            this.SizeOfImage = new NumericEntry(entries, this.is32Bit, "SizeOfImage", headerBaseAddress, EntrySize._32Bits);

            this.SizeOfHeaders = new NumericEntry(entries, this.is32Bit, "SizeOfHeaders", headerBaseAddress, EntrySize._32Bits);

            this.Checksum = new NumericEntry(entries, this.is32Bit, "Checksum", headerBaseAddress, EntrySize._32Bits);

            this.peSubSystem = new TypeEntry <SubSystem>(entries, this.is32Bit, "SubSystem", headerBaseAddress, EntrySize._16Bits);

            this.DLLCharacteristics = new NumericEntry(entries, this.is32Bit, "DLLCharacteristics", headerBaseAddress, EntrySize._16Bits);

            this.SizeOfStackReserve = new NumericEntry(entries, this.is32Bit, "SizeOfStackReserve", headerBaseAddress, EntrySize._32Bits, EntrySize._64Bits);

            this.SizeOfStackCommit = new NumericEntry(entries, this.is32Bit, "SizeOfStackCommit", headerBaseAddress, EntrySize._32Bits, EntrySize._64Bits);

            this.SizeOfHeapReserve = new NumericEntry(entries, this.is32Bit, "SizeOfHeapReserve", headerBaseAddress, EntrySize._32Bits, EntrySize._64Bits);

            this.SizeOfHeapCommit = new NumericEntry(entries, this.is32Bit, "SizeOfHeapCommit", headerBaseAddress, EntrySize._32Bits, EntrySize._64Bits);

            this.LoaderFlags = new NumericEntry(entries, this.is32Bit, "LoaderFlags", headerBaseAddress, EntrySize._32Bits);

            this.NumberOfRvaAndSizes = new NumericEntry(entries, this.is32Bit, "NumberOfRvaAndSizes", headerBaseAddress, EntrySize._32Bits);
        }
Пример #35
0
 //-----------------------------------------------------------------------------
 // The symbol is undefined in the type
 //-----------------------------------------------------------------------------
 public static SymbolErrorException UndefinedSymbolInType(                
     TypeEntry t,
     Identifier idMissingSymbol
     )
 {
     return new SymbolErrorException(
         Code.cSymbolNotInType,
         idMissingSymbol.Location,
         "'" + idMissingSymbol.Text + "' is not defined in the type '" + 
         t.FullName + "'.");
 }
Пример #36
0
        private TypeEntry RegisterCilType(TypeDefinition type, TypeEnvironment typeEnvironment)
        {
            var typeFullName = type.GetCompatibleFullName();

            if (typeEnvironment.ContainsType(typeFullName))
            {
                return(typeEnvironment[typeFullName]);
            }

            // Gets all the classes from which the input class inherits.
            var baseClasses        = type.Interfaces.Select(i => i.InterfaceType).Append(type.BaseType);
            var baseInstanceFields = new List <FieldIdentifier>();
            var baseStaticFields   = new List <FieldIdentifier>();
            var baseSupers         = new List <string>();
            var baseTypes          = new List <string>();

            // Aggregates the instance and static fields, the super
            foreach (var baseClass in baseClasses)
            {
                if (baseClass != null)
                {
                    try
                    {
                        var resolvedBaseClass = baseClass.Resolve();
                        if (resolvedBaseClass != null)
                        {
                            var baseTypeEntry = RegisterCilType(resolvedBaseClass, typeEnvironment);

                            baseInstanceFields.AddRange(baseTypeEntry.TypeStruct.InstanceFields);
                            baseStaticFields.AddRange(baseTypeEntry.TypeStruct.StaticFields);
                            baseSupers.AddRange(baseTypeEntry.TypeStruct.Supers.Select(s => s.Name));
                            baseTypes.Add(baseClass.GetCompatibleFullName());
                        }
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            var allFields = type.Fields.Select(
                f => (f.IsStatic,
                      Field: new FieldIdentifier(f.GetCompatibleFullName(),
                                                 Typ.FromTypeReference(f.FieldType))));

            var instanceFields = allFields
                                 .Where(f => !f.IsStatic)
                                 .Select(f => f.Field)
                                 .Concat(baseInstanceFields);
            var staticFields = allFields
                               .Where(f => f.IsStatic)
                               .Select(f => f.Field)
                               .Concat(baseStaticFields);
            var procNames = type.Methods.Select(m => new ProcedureName(m));

            var typeStruct = new Struct(instanceFields,
                                        staticFields,
                                        baseSupers.Concat(baseTypes),
                                        procNames);

            var typeEntry = new TypeEntry
            {
                TypeName   = TypeName.FromTypeReference(type),
                TypeStruct = typeStruct,
            };

            typeEnvironment[typeFullName] = typeEntry;
            return(typeEntry);
        }
Пример #37
0
 //-----------------------------------------------------------------------------
 // Structs & Interfaces can only derive from interfaces
 //-----------------------------------------------------------------------------
 public static SymbolErrorException MustDeriveFromInterface(ClassDecl nodeThis, TypeEntry tBase)
 {
     return new SymbolErrorException(
         Code.cMustDeriveFromInterface,
         nodeThis.Location,
         "'" + tBase.FullName + "' is not an interface and so it can't be in the base-list for '" + nodeThis.Name +"'");
 }
Пример #38
0
 public GlobalSymbolTable Add(TypeEntry typeEntry) =>
 new GlobalSymbolTable(this.TypeDefs.Add(typeEntry), this.Enums, this.GlobalObjects);
Пример #39
0
 protected override TypeEntry CreateMappingEntry()
 {
     // Create mapping
     var dexName = Type.GetDexImportAttribute().ConstructorArguments[0].Value.ToString();
     var mapFileId = 0;
     var scopeId = Type.MetadataToken.ToScopeId();
     var entry = new TypeEntry(Type.FullName, Type.Scope.Name, dexName, mapFileId, scopeId);
     return entry;
 }
Пример #40
0
 public FunctionScope Add(TypeEntry typeEntry) {
     var localSymbleTable = this.LocalScopes.Peek().Add(typeEntry);
     return new FunctionScope(
         this.FunctionType,
         this.FunctionParams,
         this.LocalScopes.Pop().Push(localSymbleTable)
     );
 }
 public override void RecordMapping(TypeEntry typeEntry)
 {
     //var entry = new FieldEntry(xField.Name, xField.FieldType.FullName, dfield.Name, dfield.Type.ToString());
     //typeEntry.Fields.Add(entry);
 }
Пример #42
0
        public MethodDisassembly(MethodDefinition methodDef, MapFileLookup mapFile = null, TypeEntry typeEntry = null, MethodEntry methodEntry = null)
        {
            _typeEntry   = typeEntry;
            _methodEntry = methodEntry;
            _methodDef   = methodDef;
            _mapFile     = mapFile;

            JumpTargetOffsets       = new HashSet <int>();
            ExceptionHandlerOffsets = new HashSet <int>();

            if (methodDef.Body != null)
            {
                foreach (var i in methodDef.Body.Instructions)
                {
                    var op = i.Operand as Instruction;
                    if (op != null)
                    {
                        JumpTargetOffsets.Add(op.Offset);
                    }
                }
                foreach (var e in methodDef.Body.Exceptions)
                {
                    foreach (var c in e.Catches)
                    {
                        ExceptionHandlerOffsets.Add(c.Instruction.Offset);
                    }
                    if (e.CatchAll != null)
                    {
                        ExceptionHandlerOffsets.Add(e.CatchAll.Offset);
                    }
                }
            }

            Format = FormatOptions.Default;
        }
 /// <summary>
 /// Default ctor
 /// </summary>
 public DebugLocationBreakpoint(Jdwp.EventKind eventKind, SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, DebugBoundBreakpoint <DebugLocationBreakpoint> boundBreakpoint)
     : base(eventKind, sourcePosition, typeEntry, methodEntry)
 {
     this.boundBreakpoint = boundBreakpoint;
 }
Пример #44
0
        /// <summary>
        /// will throw if type is not found.
        /// </summary>
        private static XTypeDefinition ResolveToType(TypeEntry type, ClassReference sourceRef, AssemblyCompiler compiler)
        {
            XTypeDefinition xTypeDef = null;

            if (type != null)
            {
                string scopeId = GetTypeScopeId(type);
                xTypeDef = compiler.Module.GetTypeByScopeID(scopeId);
            }
            else
            {
                string scopeId = sourceRef.Descriptor.Substring(1,sourceRef.Descriptor.Length-2);
                xTypeDef = compiler.Module.GetTypeByScopeID(scopeId);
            }

            if (xTypeDef == null)
            {
                throw new CompilerCacheResolveException("unable to resolve " + sourceRef);
            }
            return xTypeDef;
        }
Пример #45
0
 public LocalSymbolTable Add(TypeEntry typeEntry) =>
     new LocalSymbolTable(this.TypeDefs.Add(typeEntry), this.Enums, this.FrameObjects);
Пример #46
0
        public void OptimizedClassHistogram()
        {
            using (DataTarget dt = TestTargets.Types.LoadFullDump())
            {
                ClrRuntime runtime = dt.ClrVersions.Single().CreateRuntime();
                ClrHeap    heap    = runtime.Heap;

                // ensure that the optimized version is faster than the default one
                Stopwatch timing = new Stopwatch();
                var       notOptimizedStatistics  = new Dictionary <ClrType, TypeEntry>(32768);
                int       notOptimizedObjectCount = 0;

                // with an optimized version
                timing.Start();

                foreach (var objDetails in heap.EnumerateObjectDetails())
                {
                    ClrType type = objDetails.Item3;
                    ulong   size = objDetails.Item4;

                    TypeEntry entry;
                    if (!notOptimizedStatistics.TryGetValue(type, out entry))
                    {
                        entry = new TypeEntry()
                        {
                            TypeName = type.Name,
                            Size     = 0
                        };
                        notOptimizedStatistics[type] = entry;
                    }
                    entry.Count++;
                    entry.Size += size;
                    notOptimizedObjectCount++;
                }

                timing.Stop();
                var notOptimizedTime = TimeSpan.FromMilliseconds(timing.ElapsedMilliseconds);


                // with an non-optimized version
                var statistics  = new Dictionary <ClrType, TypeEntry>(32768);
                int objectCount = 0;
                timing.Restart();

                foreach (ulong objAddress in heap.EnumerateObjectAddresses())
                {
                    ClrType type = heap.GetObjectType(objAddress);
                    ulong   size = type.GetSize(objAddress);

                    TypeEntry entry;
                    if (!statistics.TryGetValue(type, out entry))
                    {
                        entry = new TypeEntry()
                        {
                            TypeName = type.Name,
                            Size     = 0
                        };
                        statistics[type] = entry;
                    }
                    entry.Count++;
                    entry.Size += size;
                    objectCount++;
                }

                timing.Stop();

                // check object count
                Assert.AreEqual(notOptimizedObjectCount, objectCount);

                // check heap content
                var types = notOptimizedStatistics.Keys;
                foreach (var type in types)
                {
                    var notOptimizedDetails = notOptimizedStatistics[type];
                    var details             = statistics[type];

                    Assert.AreEqual(notOptimizedDetails.TypeName, details.TypeName);
                    Assert.AreEqual(notOptimizedDetails.Count, details.Count);
                    Assert.AreEqual(notOptimizedDetails.Size, details.Size);
                }
                Assert.AreEqual(types.Count, statistics.Count);

                // checking that optimized is faster could be flaky
                // Assert.IsTrue(notOptimizedTime > TimeSpan.FromMilliseconds(timing.ElapsedMilliseconds));
            }
        }
Пример #47
0
 public Env2 Add(TypeEntry entry) {
     if (this._functionScope.IsNone) {
         // global
         return new Env2(
             this._globalSymbolTable.Add(entry),
             this._functionScope
         );
     } else {
         // local
         return new Env2(
             this._globalSymbolTable,
             Option.Some(this._functionScope.Value.Add(entry))
         );
     }
 }
Пример #48
0
 /// <summary>
 /// Create custom breakpoint.
 /// </summary>
 protected override DalvikLocationBreakpoint CreateLocationBreakpoint(SourceCodePosition sourcePosition, TypeEntry typeEntry, MethodEntry methodEntry, object data)
 {
     return(new DebugLocationBreakpoint(Jdwp.EventKind.BreakPoint, sourcePosition, typeEntry, methodEntry, (BreakpointBookmark)data));
 }
Пример #49
0
        /// <summary>
        /// Delegate methods are created unfortunately during the compilation phase in AstCompiler.VisitExpression.
        /// Model this behaviour here.
        /// </summary>
        private DelegateInstanceType GetDelegateInstanceType(TypeEntry typeEntry, ClassReference classRef, AssemblyCompiler compiler, DexTargetPackage targetPackage)
        {
            var scopeIds = typeEntry.ScopeId.Split(new[] { ":delegate:" }, StringSplitOptions.None);

            var typeScopId = scopeIds[0];
            var xTypeDef = compiler.Module.GetTypeByScopeID(GetTypeScopeId(typeEntry.Scope, typeScopId, typeEntry.Name));
            var delegateType = compiler.GetDelegateType(xTypeDef);
            
            var calledMethodId = scopeIds[1];
            var calledTypeScopeId = calledMethodId.Split('|')[0];
            var calledMethodScope = calledMethodId.Split('|')[1];

            var calledTypeDef = compiler.Module.GetTypeByScopeID(calledTypeScopeId);
            var calledMethod = calledTypeDef.GetMethodByScopeId(calledMethodScope);

            // NOTE: we are loosing the SequencePoint (DebugInfo) here. I'm not sure if this
            //       was ever valuable anyways.
            var delInstanceType = delegateType.GetOrCreateInstance(null, targetPackage, calledMethod);
            return delInstanceType;
        }
Пример #50
0
        public static void ExtractUpdateFields()
        {
            var f  = new FileStream("wow.exe", FileMode.Open, FileAccess.Read, FileShare.Read, 10000000);
            var r1 = new BinaryReader(f);
            var r2 = new StreamReader(f);
            var o  = new FileStream("Global.UpdateFields.vb", FileMode.Create, FileAccess.Write, FileShare.None, 1024);
            var w  = new StreamWriter(o);
            int FIELD_NAME_OFFSET = SearchInFile(f, "CORPSE_FIELD_PAD");
            int OBJECT_FIELD_GUID = SearchInFile(f, "OBJECT_FIELD_GUID") + 0x400000;
            int FIELD_TYPE_OFFSET = SearchInFile(f, OBJECT_FIELD_GUID);

            if (FIELD_NAME_OFFSET == -1 | FIELD_TYPE_OFFSET == -1)
            {
                MessageBox.Show("Wrong offsets! " + FIELD_NAME_OFFSET + "  " + FIELD_TYPE_OFFSET);
            }
            else
            {
                var    Names  = new List <string>();
                string Last   = "";
                int    Offset = FIELD_NAME_OFFSET;
                f.Seek(Offset, SeekOrigin.Begin);
                while (Last != "OBJECT_FIELD_GUID")
                {
                    Last = ReadString(f);
                    Names.Add(Last);
                }

                var Info = new List <TypeEntry>();
                int Temp;
                var Buffer = new byte[4];
                Offset = 0;
                f.Seek(FIELD_TYPE_OFFSET, SeekOrigin.Begin);
                for (int i = 0, loopTo = Names.Count - 1; i <= loopTo; i++)
                {
                    f.Seek(FIELD_TYPE_OFFSET + i * 5 * 4 + Offset, SeekOrigin.Begin);
                    f.Read(Buffer, 0, 4);
                    Temp = BitConverter.ToInt32(Buffer, 0);
                    if (Temp < 0xFFFF)
                    {
                        i      -= 1;
                        Offset += 4;
                        continue;
                    }

                    var tmp = new TypeEntry
                    {
                        Name = Temp
                    };
                    f.Read(Buffer, 0, 4);
                    Temp       = BitConverter.ToInt32(Buffer, 0);
                    tmp.Offset = Temp;
                    f.Read(Buffer, 0, 4);
                    Temp     = BitConverter.ToInt32(Buffer, 0);
                    tmp.Size = Temp;
                    f.Read(Buffer, 0, 4);
                    Temp     = BitConverter.ToInt32(Buffer, 0);
                    tmp.Type = Temp;
                    f.Read(Buffer, 0, 4);
                    Temp      = BitConverter.ToInt32(Buffer, 0);
                    tmp.Flags = Temp;
                    Info.Add(tmp);
                }

                MessageBox.Show(string.Format("{0} fields extracted.", Names.Count));
                w.WriteLine("' Auto generated file");
                w.WriteLine("' {0}", DateAndTime.Now);
                w.WriteLine();
                string LastFieldType = "";
                string sName;
                string sField;
                int    BasedOn     = 0;
                string BasedOnName = "";
                var    EndNum      = new Dictionary <string, int>();
                for (int j = 0, loopTo1 = Info.Count - 1; j <= loopTo1; j++)
                {
                    sName = ReadString(f, Info[j].Name - 0x400000);
                    if (!string.IsNullOrEmpty(sName))
                    {
                        sField = ToField(sName.Substring(0, sName.IndexOf("_")));
                        if (sName == "OBJECT_FIELD_CREATED_BY")
                        {
                            sField = "GameObject";
                        }
                        if ((LastFieldType ?? "") != (sField ?? ""))
                        {
                            if (!string.IsNullOrEmpty(LastFieldType))
                            {
                                EndNum.Add(LastFieldType, Info[j - 1].Offset + 1);
                                if (LastFieldType.ToLower() == "object")
                                {
                                    w.WriteLine("    {0,-78}", LastFieldType.ToUpper() + "_END = &H" + Conversion.Hex(Info[j - 1].Offset + Info[j - 1].Size));
                                }
                                else
                                {
                                    w.WriteLine("    {0,-78}' 0x{1:X3}", LastFieldType.ToUpper() + "_END = " + BasedOnName + " + &H" + Conversion.Hex(Info[j - 1].Offset + Info[j - 1].Size), BasedOn + Info[j - 1].Offset + Info[j - 1].Size);
                                }

                                w.WriteLine("End Enum");
                            }

                            w.WriteLine("Public Enum E" + sField + "Fields");
                            if (sField.ToLower() == "container")
                            {
                                BasedOn     = EndNum["Item"];
                                BasedOnName = "EItemFields.ITEM_END";
                            }
                            else if (sField.ToLower() == "player")
                            {
                                BasedOn     = EndNum["Unit"];
                                BasedOnName = "EUnitFields.UNIT_END";
                            }
                            else if (sField.ToLower() != "object")
                            {
                                BasedOn     = EndNum["Object"];
                                BasedOnName = "EObjectFields.OBJECT_END";
                            }

                            LastFieldType = sField;
                        }

                        if (BasedOn > 0)
                        {
                            w.WriteLine("    {0,-78}' 0x{1:X3} - Size: {2} - Type: {3} - Flags: {4}", sName + " = " + BasedOnName + " + &H" + Conversion.Hex(Info[j].Offset), BasedOn + Info[j].Offset, Info[j].Size, ToType(Info[j].Type), ToFlags(Info[j].Flags));
                        }
                        else
                        {
                            w.WriteLine("    {0,-78}' 0x{1:X3} - Size: {2} - Type: {3} - Flags: {4}", sName + " = &H" + Conversion.Hex(Info[j].Offset), Info[j].Offset, Info[j].Size, ToType(Info[j].Type), ToFlags(Info[j].Flags));
                        }
                    }
                }

                if (!string.IsNullOrEmpty(LastFieldType))
                {
                    w.WriteLine("    {0,-78}' 0x{1:X3}", LastFieldType.ToUpper() + "_END = " + BasedOnName + " + &H" + Conversion.Hex(Info[^ 1].Offset + Info[^ 1].Size), BasedOn + Info[^ 1].Offset + Info[^ 1].Size);
Пример #51
0
 private static string GetTypeScopeId(TypeEntry type)
 {
     return GetTypeScopeId(type.Scope, type.ScopeId, type.Name);
 }
Пример #52
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DocumentLocation(Location location, Document document, DocumentPosition position, DalvikReferenceType referenceType, DalvikMethod method, TypeEntry typeEntry, MethodEntry methodEntry)
 {
     if (location == null)
     {
         throw new ArgumentNullException("location");
     }
     Location         = location;
     Document         = document;
     Position         = position;
     ReferenceType    = referenceType;
     Method           = method;
     this.typeEntry   = typeEntry;
     this.methodEntry = methodEntry;
 }
Пример #53
0
        public static void LoadPattern(string filepath)
        {
            entities  = new StringDictionary();
            types     = new SortedList();
            basetypes = new SortedList();
            dbtypes   = new SortedList();

            string     dir = System.IO.Directory.GetCurrentDirectory();
            FileStream fs  = new FileStream(filepath, FileMode.Open);

            XmlDocument dom = new XmlDocument();

            dom.Load(fs);

            string[] tags = new string[]
            {
                TAG_CLASS,
                TAG_ENGINE,
                TAG_INSTANCE,
                TAG_DECLARATION,
                TAG_PROPERTY,
                TAG_CONFIGFILE,
                TAG_CONFIGBBDD
            };

            foreach (string tag in tags)
            {
                XmlNode node = dom.SelectSingleNode(XPATH_ROOT + tag);
                entities.Add(tag, node.InnerXml);
            }

            XmlNodeList nodes = dom.SelectNodes(XPATH_ROOT + TAG_TYPES + "/" + TAG_TYPE);

            foreach (XmlNode n in nodes)
            {
                TypeEntry te = new TypeEntry();

                te.name = n.Attributes[ATTR_NAME].Value;

                XmlAttribute attr = n.Attributes[ATTR_PREFIX];
                if (attr != null)
                {
                    te.prefix = attr.Value;
                }

                attr = n.Attributes[ATTR_PARAMS];
                if (attr != null)
                {
                    te.parameters = attr.Value;
                }

                attr = n.Attributes[ATTR_DBPARAMS];
                if (attr != null)
                {
                    te.dbparameters = attr.Value;
                }

                attr = n.Attributes[ATTR_DBTYPE];
                if (attr != null)
                {
                    te.dbtype = attr.Value;
                }

                attr = n.Attributes[ATTR_BASETYPE];
                if (attr != null)
                {
                    te.basetype = attr.Value;
                }

                attr = n.Attributes[ATTR_NONNULLABLE];
                if (attr != null)
                {
                    te.nonNullable = (attr != null && attr.Value.ToLower() == "true");
                }

                if (!types.Contains(te.Name))
                {
                    types.Add(te.Name, te);
                }
                if (!dbtypes.Contains(te.DBType))
                {
                    dbtypes.Add(te.DBType, te);
                }
                if (!basetypes.Contains(te.BaseType))
                {
                    basetypes.Add(te.BaseType, te);
                }
            }

            fs.Close();

            isLoaded = true;
        }
Пример #54
0
 // Resolve member
 public override void ResolveMember(
     TypeEntry symDefiningClass, 
     ISemanticResolver s,
     ICLRtypeProvider provider
 )
 {
     m_tType.ResolveType(s);
     TypeEntry t = m_tType.BlueType;
     
     m_symbol = new FieldExpEntry(m_stName, t, symDefiningClass, this);
     s.GetCurrentContext().AddSymbol(m_symbol);
     m_symbol.SetInfo(provider);
 }
Пример #55
0
 /// <summary>
 /// Try to get a type from the given clr type name name.
 /// Will ignore the case.
 /// </summary>
 public bool TryGetFromClrName(string clrTypeName, out TypeEntry entry)
 {
     return typeMap.TryGetValue(clrTypeName, out entry);
 }
Пример #56
0
    public void ResolveMemberAsLiteral(TypeEntry symDefiningClass, ISemanticResolver s, object o)
    {
        //f.FieldTypeSig.ResolveType(s);

        m_tType.ResolveType(s);
        TypeEntry t = m_tType.BlueType;

        m_symbol = new LiteralFieldExpEntry(Name, t, symDefiningClass, this);                    
        LiteralFieldExpEntry l = (LiteralFieldExpEntry) m_symbol;
        l.Data = o;

        s.GetCurrentContext().AddSymbol(m_symbol);
    }
Пример #57
0
        /// <summary>
        /// Record the mapping from .NET to Dex
        /// </summary>
        public void RecordMapping(TypeEntry typeEntry)
        {
            var entry = new FieldEntry(field.Name, field.FieldType.ClassName, dfield.Name, dfield.Type.ToString());

            typeEntry.Fields.Add(entry);
        }
Пример #58
0
 // Resolve this
 public override void ResolveMember(
     TypeEntry symDefiningClass, 
     ISemanticResolver s,
     ICLRtypeProvider provider
 )
 {
     m_tType.ResolveType(s);
     
 // Spoof bodies
             
     if (HasGet)
     {                        
         m_declGet.ResolveMember(symDefiningClass, s, null);
         m_declGet.Symbol.IsSpecialName = true;
     }
     if (HasSet)
     {   
         m_declSet.ResolveMember(symDefiningClass, s, null);
         m_declSet.Symbol.IsSpecialName = true;
     }
 
 // Create a symbol for the property
     m_symbol = new SymbolEngine.PropertyExpEntry(symDefiningClass, this, m_declGet, m_declSet);
     
     s.GetCurrentContext().AddSymbol(m_symbol);
 }
Пример #59
0
 /// <include file='doc\XmlSerializationWriter.uex' path='docs/doc[@for="XmlSerializationWriter.AddWriteCallback"]/*' />
 protected void AddWriteCallback(Type type, string typeName, string typeNs, XmlSerializationWriteCallback callback) {
     TypeEntry entry = new TypeEntry();
     entry.typeName = typeName;
     entry.typeNs = typeNs;
     entry.type = type;
     entry.callback = callback;
     typeEntries[type] = entry;
 }
Пример #60
0
 /// <summary>
 /// Create a new location breakpoint.
 /// </summary>
 protected virtual DalvikLocationBreakpoint CreateLocationBreakpoint(DocumentPosition documentPosition, TypeEntry typeEntry, MethodEntry methodEntry, object data)
 {
     return(new DalvikLocationBreakpoint(Jdwp.EventKind.BreakPoint, documentPosition, typeEntry, methodEntry));
 }