Ejemplo n.º 1
0
        private static ImportedMethod TryGetCurrentMethod(DkmInspectionContext inspectionContext, DkmStackWalkFrame frame)
        {
            InspectionSession session = InspectionSession.GetInstance(inspectionContext.InspectionSession);
            InspectionScope   scope   = session.GetScope((DkmClrInstructionAddress)frame.InstructionAddress);

            return(scope.TryImportCurrentMethod());
        }
        public void InitializeSymbols()
        {
            ImportedMethod currentMethod = Scope.TryImportCurrentMethod();

            if (currentMethod == null)
            {
                return; // Nothing to evaluate if we can't get the current method
            }
            // Add compiler intrinsics
            AddIntrinsics();

            // Add debugger intrinsics
            // (Not implemented yet)

            // Add globals
            ImportedType type = currentMethod.DeclaringType;

            foreach (ImportedField importedfield in type.GetFields())
            {
                IrisType irisType = importedfield.FieldType;
                if (irisType != IrisType.Invalid)
                {
                    SymbolTable.Add(importedfield.Name, irisType, StorageClass.Global, importedfield);
                }
            }

            // Add methods
            foreach (ImportedMethod importedMethod in type.GetMethods())
            {
                Method method = importedMethod.ConvertToIrisMethod();
                if (IsValidMethod(method))
                {
                    SymbolTable.Add(importedMethod.Name, method, StorageClass.Global, importedMethod);
                }
            }

            // Create symbol for query method and transition the SymbolTable to method scope
            _irisMethod = currentMethod.ConvertToIrisMethod();
            SymbolTable.OpenMethod("$.query", _irisMethod);

            // Add symbols for parameters
            foreach (Variable param in _irisMethod.GetParameters())
            {
                SymbolTable.Add(param.Name, param.Type, StorageClass.Argument);
            }

            // Add symbols for local variables
            foreach (LocalVariable local in Scope.GetLocals())
            {
                SymbolTable.Add(local.Name, local.Type, StorageClass.Local, local.Slot);
            }
        }