Пример #1
0
        private NodeHeader *CreateNode(int index, MemorySlice key, NodeFlags flags, int len, ushort previousNodeVersion)
        {
            Debug.Assert(index <= NumberOfEntries && index >= 0);
            Debug.Assert(IsBranch == false || index != 0 || key.KeyLength == 0);// branch page's first item must be the implicit ref
            if (HasSpaceFor(key, len) == false)
            {
                throw new InvalidOperationException("The page is full and cannot add an entry, this is probably a bug");
            }

            var prefixedKey = key as PrefixedSlice;

            if (prefixedKey != null && prefixedKey.NewPrefix != null)
            {
                WritePrefix(prefixedKey.NewPrefix, prefixedKey.Header.PrefixId);
            }

            // move higher pointers up one slot
            for (int i = NumberOfEntries; i > index; i--)
            {
                KeysOffsets[i] = KeysOffsets[i - 1];
            }

            var nodeSize = SizeOf.NodeEntry(PageMaxSpace, key, len);
            var node     = AllocateNewNode(index, nodeSize, previousNodeVersion);

            node->KeySize = key.Size;

            if (key.Options == SliceOptions.Key && key.Size > 0)
            {
                key.CopyTo((byte *)node + Constants.NodeHeaderSize);
            }

            node->Flags = flags;

            return(node);
        }
Пример #2
0
        private bool TryMergePages(Page parentPage, Page left, Page right)
        {
            TemporaryPage tmp;

            using (_tx.Environment.GetTemporaryPage(_tx, out tmp))
            {
                var mergedPage = tmp.GetTempPage(left.KeysPrefixed);
                MemoryUtils.Copy(mergedPage.Base, left.Base, left.PageSize);

                var previousSearchPosition = right.LastSearchPosition;

                for (int i = 0; i < right.NumberOfEntries; i++)
                {
                    right.LastSearchPosition = i;
                    var key  = GetActualKey(right, right.LastSearchPositionOrLastEntry);
                    var node = right.GetNode(i);

                    var prefixedKey = mergedPage.PrepareKeyToInsert(key, mergedPage.NumberOfEntries);

                    if (mergedPage.HasSpaceFor(_tx, SizeOf.NodeEntryWithAnotherKey(node, prefixedKey) + Constants.NodeOffsetSize + SizeOf.NewPrefix(prefixedKey)) == false)
                    {
                        right.LastSearchPosition = previousSearchPosition;                         //previous position --> prevent mutation of parameter
                        return(false);
                    }

                    mergedPage.CopyNodeDataToEndOfPage(node, prefixedKey);
                }

                MemoryUtils.Copy(left.Base, mergedPage.Base, left.PageSize);
            }

            parentPage.RemoveNode(parentPage.LastSearchPositionOrLastEntry);             // unlink the right sibling
            _tx.FreePage(right.PageNumber);

            return(true);
        }
Пример #3
0
 protected internal virtual Node TransformSizeof(SizeOf @sizeof)
 {
     return(@sizeof.AcceptTransformer(this, true));
 }
Пример #4
0
void case_583()
#line 4247 "cs-parser.jay"
{
		Error_SyntaxError (yyToken);

		yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]));
	  }
Пример #5
0
 public int GetRequiredSpace(MemorySlice key, int len)
 {
     return(SizeOf.NodeEntry(PageMaxSpace, key, len) + Constants.NodeOffsetSize + SizeOf.NewPrefix(key));
 }
Пример #6
0
        private int AdjustSplitPosition(int currentIndex, int splitIndex, PrefixNode[] prefixes, ref bool toRight)
        {
            MemorySlice keyToInsert;

            int pageSize = 0;

            if (_tree.KeysPrefixing)
            {
                keyToInsert = new PrefixedSlice(_newKey); // let's assume that _newkey won't match any of the existing prefixes

                pageSize += Constants.PrefixInfoSectionSize;
                pageSize += Constants.PrefixNodeHeaderSize + 1; // possible new prefix,  + 1 because of possible 2-byte alignment
            }
            else
            {
                keyToInsert = _newKey;
            }

            pageSize += SizeOf.NodeEntry(AbstractPager.PageMaxSpace, keyToInsert, _len) + Constants.NodeOffsetSize;

            if (prefixes != null)
            {
                // we are going to copy all existing prefixes so we need to take into account their sizes
                for (var i = 0; i < prefixes.Length; i++)
                {
                    var prefixNodeSize = Constants.PrefixNodeHeaderSize + prefixes[i].Header.PrefixLength;
                    pageSize += prefixNodeSize + (prefixNodeSize & 1); // & 1 because we need 2-byte alignment
                }
            }

            if (toRight == false)
            {
                for (int i = 0; i < splitIndex; i++)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i <= currentIndex)
                        {
                            if (i < currentIndex)
                            {
                                toRight = true;
                            }
                            return(currentIndex);
                        }
                        return(i);
                    }
                }
            }
            else
            {
                for (int i = _page.NumberOfEntries - 1; i >= splitIndex; i--)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i >= currentIndex)
                        {
                            toRight = false;
                            return(currentIndex);
                        }
                        return(i + 1);
                    }
                }
            }

            return(splitIndex);
        }
Пример #7
0
 public int GetRequiredSpace(Slice key, int len)
 {
     return(SizeOf.NodeEntry(PageMaxSpace, key, len) + Constants.NodeOffsetSize);
 }
Пример #8
0
        /// <summary>
        ///     For leaf pages, check the split point based on what
        ///     fits where, since otherwise adding the node can fail.
        ///     This check is only needed when the data items are
        ///     relatively large, such that being off by one will
        ///     make the difference between success or failure.
        ///     It's also relevant if a page happens to be laid out
        ///     such that one half of its nodes are all "small" and
        ///     the other half of its nodes are "large." If the new
        ///     item is also "large" and falls on the half with
        ///     "large" nodes, it also may not fit.
        /// </summary>
        private int AdjustSplitPosition(int currentIndex, int splitIndex,
                                        ref bool newPosition)
        {
            MemorySlice keyToInsert;

            if (_tree.KeysPrefixing)
            {
                keyToInsert = new PrefixedSlice(_newKey);         // let's assume that _newkey won't be prefixed to ensure the destination page will have enough space
            }
            else
            {
                keyToInsert = _newKey;
            }

            int nodeSize = SizeOf.NodeEntry(AbstractPager.PageMaxSpace, keyToInsert, _len) + Constants.NodeOffsetSize;

            if (_page.NumberOfEntries >= 20 && nodeSize <= AbstractPager.PageMaxSpace / 16)
            {
                return(splitIndex);
            }

            int pageSize = nodeSize;

            if (_tree.KeysPrefixing)
            {
                pageSize += (Constants.PrefixNodeHeaderSize + 1);                 // let's assume that prefix will be created to ensure the destination page will have enough space, + 1 because prefix node might require 2-byte alignment
            }
            if (currentIndex <= splitIndex)
            {
                newPosition = false;
                for (int i = 0; i < splitIndex; i++)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i <= currentIndex)
                        {
                            if (i < currentIndex)
                            {
                                newPosition = true;
                            }
                            return(currentIndex);
                        }
                        return((ushort)i);
                    }
                }
            }
            else
            {
                for (int i = _page.NumberOfEntries - 1; i >= splitIndex; i--)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i >= currentIndex)
                        {
                            newPosition = false;
                            return(currentIndex);
                        }
                        return((ushort)(i + 1));
                    }
                }
            }
            return(splitIndex);
        }
Пример #9
0
        // Token: 0x060000FE RID: 254 RVA: 0x00015024 File Offset: 0x00013224
        private void metroButton2_Click(object sender, EventArgs e)
        {
            ModuleDef moduleDef      = ModuleDefMD.Load(this.metroTextBox1.Text);
            bool      numberToString = Settings.NumberToString;

            if (numberToString)
            {
                Constants__numbers_.ObfuscateNumbers(moduleDef);
            }
            bool stackUnderflow = Settings.StackUnderflow;

            if (stackUnderflow)
            {
                Stack_Underflow.StackUnderflow(moduleDef);
            }
            bool sizeOf = Settings.SizeOf;

            if (sizeOf)
            {
                SizeOf.Sizeof(moduleDef);
            }
            bool disConstants = Settings.DisConstants;

            if (disConstants)
            {
                Distant_Constants.DisConstants(moduleDef);
            }
            bool refProxy = Settings.RefProxy;

            if (refProxy)
            {
                Method_Wiper.Execute(moduleDef);
            }
            bool constants = Settings.Constants;

            if (constants)
            {
                Constants__numbers_.Inject(moduleDef);
            }
            bool localToFields = Settings.LocalToFields;

            if (localToFields)
            {
                LocalToFields.Protect(moduleDef);
            }
            bool renamer = Settings.Renamer;

            if (renamer)
            {
                Renamer.Execute(moduleDef);
            }
            bool controlFlow = Settings.ControlFlow;

            if (controlFlow)
            {
                Control_Flow.Encrypt(moduleDef);
                Constants__numbers_.Execute(moduleDef);
            }
            bool constant_Mutation = Settings.Constant_Mutation;

            if (constant_Mutation)
            {
                Constant_Mutation.Execute(moduleDef);
            }
            bool antiDe4dot = Settings.AntiDe4dot;

            if (antiDe4dot)
            {
                Anti_De4dot.RemoveDe4dot(moduleDef);
            }
            bool antiILdasm = Settings.AntiILdasm;

            if (antiILdasm)
            {
                Anti_ILDasm.Anti(moduleDef);
            }
            bool koiVMFakeSig = Settings.KoiVMFakeSig;

            if (koiVMFakeSig)
            {
                KoiVM_Fake_Watermark.Execute(moduleDef);
            }
            bool antiDump = Settings.AntiDump;

            if (antiDump)
            {
                AntiDump.Inject(moduleDef);
            }
            bool invalidMetadata = Settings.InvalidMetadata;

            if (invalidMetadata)
            {
                Invalid_Metadata.InvalidMD(moduleDef);
            }
            bool calli = Settings.Calli;

            if (calli)
            {
                Calli.Execute(moduleDef);
            }
            bool antiHTTPDebugger = Settings.AntiHTTPDebugger;

            if (antiHTTPDebugger)
            {
                Anti_Http_Debugger.Execute(moduleDef);
            }
            bool antiFiddler = Settings.AntiFiddler;

            if (antiFiddler)
            {
                Anti_Fiddler.Execute(moduleDef);
            }
            bool stringEncryption = Settings.StringEncryption;

            if (stringEncryption)
            {
                String_Encryption.Inject(moduleDef);
            }
            Watermark.Execute(moduleDef);
            ModuleDef manifestModule = moduleDef.Assembly.ManifestModule;

            moduleDef.EntryPoint.Name = "BlinkRE";
            moduleDef.Mvid            = new Guid?(Guid.NewGuid());
            bool strong = Settings.Strong;

            if (strong)
            {
                Protection.Protect(moduleDef);
                Inject.ProtectValue(moduleDef);
                Inject.DoubleProtect(moduleDef);
                Inject.Triple(moduleDef);
                Inject.Triple(moduleDef);
                Method_Wiper.Execute(moduleDef);
                Assembly.MarkAssembly(moduleDef);
                Locals.Protect(moduleDef);
            }
            Directory.CreateDirectory(".\\AtomicProtected");
            moduleDef.Write(".\\AtomicProtected\\" + Path.GetFileName(this.metroTextBox1.Text), new ModuleWriterOptions(moduleDef)
            {
                PEHeadersOptions =
                {
                    NumberOfRvaAndSizes = new uint?(13U)
                },
                MetaDataOptions =
                {
                    TablesHeapOptions =
                    {
                        ExtraData     = new uint?(4919U)
                    }
                },
                Logger = DummyLogger.NoThrowInstance
            });
            Process.Start(".\\AtomicProtected");
            MessageBox.Show("Obfuscation complete! Restart to obfuscate again");
            Environment.Exit(0);
        }
 protected internal override void TraverseSizeof(SizeOf @sizeof)
 {
     Dispatch(@sizeof);
 }
Пример #11
0
        private int AdjustSplitPosition(int currentIndex, int splitIndex, PrefixNode[] prefixes, ref bool newPosition)
        {
            MemorySlice keyToInsert;

            if (_tree.KeysPrefixing)
            {
                keyToInsert = new PrefixedSlice(_newKey);         // let's assume that _newkey won't be prefixed to ensure the destination page will have enough space
            }
            else
            {
                keyToInsert = _newKey;
            }

            var pageSize = SizeOf.NodeEntry(AbstractPager.PageMaxSpace, keyToInsert, _len) + Constants.NodeOffsetSize;

            if (prefixes != null)
            {
                // we are going to copy all existing prefixes so we need to take into account their sizes
                for (var i = 0; i < prefixes.Length; i++)
                {
                    pageSize += (Constants.PrefixNodeHeaderSize + prefixes[i].Header.PrefixLength) & 1;                     // & 1 because we need 2-byte alignment
                }
            }

            if (currentIndex <= splitIndex)
            {
                newPosition = false;
                for (int i = 0; i < splitIndex; i++)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i <= currentIndex)
                        {
                            if (i < currentIndex)
                            {
                                newPosition = true;
                            }
                            return(currentIndex);
                        }
                        return((ushort)i);
                    }
                }
            }
            else
            {
                for (int i = _page.NumberOfEntries - 1; i >= splitIndex; i--)
                {
                    NodeHeader *node = _page.GetNode(i);
                    pageSize += node->GetNodeSize();
                    pageSize += pageSize & 1;
                    if (pageSize > AbstractPager.PageMaxSpace)
                    {
                        if (i >= currentIndex)
                        {
                            newPosition = false;
                            return(currentIndex);
                        }
                        return((ushort)(i + 1));
                    }
                }
            }
            return(splitIndex);
        }
 protected internal override void TraverseSizeof(SizeOf @sizeof)
 {
     var t = @sizeof.Type;
     _writer.Write("sizeof({0})", t == null ? "?" : t.GetCSharpRef(ToCSharpOptions.Informative));
 }
 protected internal virtual void TraverseSizeof(SizeOf @sizeof)
 {
     @sizeof.Unsupported();
 }
Пример #14
0
void case_535()
#line 4617 "ps-parser.jay"
{ 
		CheckIsPlayScript("sizeof", GetLocation(yyVals[-3+yyTop])); 	  
		yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
			public override object Visit (SizeOf sizeOfExpression)
			{
				var result = new SizeOfExpression ();
				var location = LocationsBag.GetLocations (sizeOfExpression);
				result.AddChild (new CSharpTokenNode (Convert (sizeOfExpression.Location), SizeOfExpression.SizeofKeywordRole), SizeOfExpression.SizeofKeywordRole);
				if (location != null)
					result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
				if (sizeOfExpression.TypeExpression != null)
					result.AddChild (ConvertToType (sizeOfExpression.TypeExpression), Roles.Type);
				if (location != null && location.Count > 1)
					result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
				return result;
			}
Пример #16
0
        private void AddSeparatorToParentPage(Page parentPage, long pageNumber, MemorySlice seperatorKey, int separatorKeyPosition)
        {
            var separatorKeyToInsert = parentPage.PrepareKeyToInsert(seperatorKey, separatorKeyPosition);

            if (parentPage.HasSpaceFor(_tx, SizeOf.BranchEntry(separatorKeyToInsert) + Constants.NodeOffsetSize + SizeOf.NewPrefix(separatorKeyToInsert)) == false)
            {
                var pageSplitter = new PageSplitter(_tx, _tree, seperatorKey, -1, pageNumber, NodeFlags.PageRef,
                                                    0, _cursor, _tree.State);
                pageSplitter.Execute();
            }
            else
            {
                parentPage.AddPageRefNode(separatorKeyPosition, separatorKeyToInsert, pageNumber);
            }
        }
 protected internal override void TraverseSizeof(SizeOf @sizeof)
 {
     Types.Add(@sizeof, typeof(uint));
 }
Пример #18
0
        private void AddSeparatorToParentPage(long pageNumber, MemorySlice seperatorKey)
        {
            var separatorKeyToInsert = _parentPage.PrepareKeyToInsert(seperatorKey, _parentPage.LastSearchPosition);

            if (_parentPage.HasSpaceFor(_tx, SizeOf.BranchEntry(separatorKeyToInsert) + Constants.NodeOffsetSize + SizeOf.NewPrefix(separatorKeyToInsert)) == false)
            {
                var pageSplitter = new PageSplitter(_tx, _tree, seperatorKey, -1, pageNumber, NodeFlags.PageRef,
                                                    0, _cursor, _treeState);
                pageSplitter.Execute();
            }
            else
            {
                _parentPage.NodePositionFor(seperatorKey); // select the appropriate place for this
                _parentPage.AddPageRefNode(_parentPage.LastSearchPosition, separatorKeyToInsert, pageNumber);
            }
        }
Пример #19
0
        public byte *AddSeparator(MemorySlice separator, long pageRefNumber, int?nodePos = null)
        {
            var originalLastSearchPositionOfParent = _parentPage.LastSearchPosition;

            if (nodePos == null)
            {
                nodePos = _parentPage.NodePositionFor(separator); // select the appropriate place for this
            }
            var separatorKeyToInsert = _parentPage.PrepareKeyToInsert(separator, nodePos.Value);

            if (_parentPage.HasSpaceFor(_tx, SizeOf.BranchEntry(separatorKeyToInsert) + Constants.NodeOffsetSize + SizeOf.NewPrefix(separatorKeyToInsert)) == false)
            {
                var pageSplitter = new PageSplitter(_tx, _tree, separator, -1, pageRefNumber, NodeFlags.PageRef, 0, _cursor, _tree.State);

                var posToInsert = pageSplitter.Execute();

                ParentOfAddedPageRef = _cursor.CurrentPage;

                var adjustParentPageOnCursor = true;

                for (int i = 0; i < _cursor.CurrentPage.NumberOfEntries; i++)
                {
                    if (_cursor.CurrentPage.GetNode(i)->PageNumber == _currentPage.PageNumber)
                    {
                        adjustParentPageOnCursor = false;
                        _cursor.CurrentPage.LastSearchPosition = i;
                        break;
                    }
                }

                if (adjustParentPageOnCursor)
                {
                    // the above page split has modified the cursor that its first page points to the parent of the leaf where 'separatorKey' was inserted
                    // and it doesn't have the reference to _page, we need to ensure that the actual parent is first at the cursor

                    _cursor.Pop();
                    _cursor.Push(_parentPage);

                    EnsureValidLastSearchPosition(_parentPage, _currentPage.PageNumber, originalLastSearchPositionOfParent);
                }
#if VALIDATE
                Debug.Assert(_cursor.CurrentPage.GetNode(_cursor.CurrentPage.LastSearchPosition)->PageNumber == _currentPage.PageNumber,
                             "The parent page is not referencing a page which is being split");

                var parentToValidate = ParentOfAddedPageRef;
                Debug.Assert(Enumerable.Range(0, parentToValidate.NumberOfEntries).Any(i => parentToValidate.GetNode(i)->PageNumber == pageRefNumber),
                             "The parent page of a page reference isn't referencing it");
#endif


                return(posToInsert);
            }

            ParentOfAddedPageRef = _parentPage;

            var pos = _parentPage.AddPageRefNode(nodePos.Value, separatorKeyToInsert, pageRefNumber);

            EnsureValidLastSearchPosition(_parentPage, _currentPage.PageNumber, originalLastSearchPositionOfParent);

            return(pos);
        }
 protected internal override void TraverseSizeof(SizeOf @sizeof)
 {
     Dispatch(@sizeof);
 }
Пример #21
0
 public override void Visit(SizeOf node)
 {
     PushInteger(thread.Pop().Read().Size);
 }
 protected internal override void TraverseSizeof(SizeOf @sizeof)
 {
     Types.Add(@sizeof, typeof(uint));
 }
 protected internal override Node TransformSizeof(SizeOf @sizeof)
 {
     return Dispatch(@sizeof);
 }
Пример #24
0
        /// <summary>
        /// Internal method that is used when splitting pages
        /// No need to do any work here, we are always adding at the end
        /// </summary>
        internal void CopyNodeDataToEndOfPage(NodeHeader *other, MemorySlice key)
        {
            var index = NumberOfEntries;

            Debug.Assert(HasSpaceFor(SizeOf.NodeEntryWithAnotherKey(other, key) + Constants.NodeOffsetSize + SizeOf.NewPrefix(key)));

            var nodeSize = SizeOf.NodeEntryWithAnotherKey(other, key);

            Debug.Assert(IsBranch == false || index != 0 || key.KeyLength == 0); // branch page's first item must be the implicit ref

            var nodeVersion = other->Version;                                    // every time new node is allocated the version is increased, but in this case we do not want to increase it

            if (nodeVersion > 0)
            {
                nodeVersion -= 1;
            }

            var prefixedKey = key as PrefixedSlice;

            if (prefixedKey != null && prefixedKey.NewPrefix != null)
            {
                WritePrefix(prefixedKey.NewPrefix, prefixedKey.Header.PrefixId);
            }

            var newNode = AllocateNewNode(index, nodeSize, nodeVersion);

            newNode->KeySize = key.Size;
            newNode->Flags   = other->Flags;

            if (key.Options == SliceOptions.Key && key.Size > 0)
            {
                key.CopyTo((byte *)newNode + Constants.NodeHeaderSize);
            }

            if (IsBranch || other->Flags == (NodeFlags.PageRef))
            {
                newNode->PageNumber = other->PageNumber;
                newNode->Flags      = NodeFlags.PageRef;
                return;
            }
            newNode->DataSize = other->DataSize;
            MemoryUtils.Copy((byte *)newNode + Constants.NodeHeaderSize + key.Size,
                             (byte *)other + Constants.NodeHeaderSize + other->KeySize,
                             other->DataSize);
        }
Пример #25
0
        private byte *AddSeparatorToParentPage(long pageNumber, MemorySlice seperatorKey, bool toRight, out Page parent)
        {
            var pos = _parentPage.NodePositionFor(seperatorKey); // select the appropriate place for this

            var separatorKeyToInsert = _parentPage.PrepareKeyToInsert(seperatorKey, pos);

            if (_parentPage.HasSpaceFor(_tx, SizeOf.BranchEntry(separatorKeyToInsert) + Constants.NodeOffsetSize + SizeOf.NewPrefix(separatorKeyToInsert)) == false)
            {
                var pageSplitter = new PageSplitter(_tx, _tree, seperatorKey, -1, pageNumber, NodeFlags.PageRef,
                                                    0, _cursor, _treeState);

                var posToInsert = pageSplitter.Execute();

                if (toRight == false && _cursor.CurrentPage.PageNumber != _parentPage.PageNumber)
                {
                    // _newKey being added to _page wasn't meant to be inserted to a newly created right page
                    // however the above page split has modified the cursor that its first page is a parent page for the right page containing separator key
                    // we need to ensure that the current _parentPage is first at the cursor

                    parent = _cursor.Pop();
                    _cursor.Push(_parentPage);
                }
                else
                {
                    parent = _parentPage;
                }

                return(posToInsert);
            }

            parent = _parentPage;

            return(_parentPage.AddPageRefNode(pos, separatorKeyToInsert, pageNumber));
        }
Пример #26
0
void case_582()
#line 4242 "cs-parser.jay"
{ 
		yyVal = new SizeOf ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-3+yyTop]));
		lbag.AddLocation (yyVal, GetLocation (yyVals[-2+yyTop]), GetLocation (yyVals[0+yyTop]));
	  }
Пример #27
0
 private Expression ParseTypeofSizeofOrDefault(TokenSet followers)
   //^ requires this.currentToken == Token.Typeof || this.currentToken == Token.Sizeof || this.currentToken == Token.Default;
   //^ ensures followers[this.currentToken] || this.currentToken == Token.EndOfFile;
 {
   Token tok = this.currentToken;
   SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.SourceLocationOfLastScannedToken);
   this.GetNextToken();
   this.Skip(Token.LeftParenthesis);
   TypeExpression type = this.ParseTypeExpression(false, true, followers|Token.RightParenthesis);
   slb.UpdateToSpan(this.scanner.SourceLocationOfLastScannedToken);
   this.SkipOverTo(Token.RightParenthesis, followers);
   Expression result;
   if (tok == Token.Typeof) 
     result = new TypeOf(type, slb);
   else if (tok == Token.Sizeof)
     result = new SizeOf(type, slb);
   else {
     //^ assert tok == Token.Default;
     result = new DefaultValue(type, slb);
   }
   //^ assume followers[this.currentToken] || this.currentToken == Token.EndOfFile;
   return result;
 }
Пример #28
0
 protected internal virtual void TraverseSizeof(SizeOf @sizeof) { @sizeof.Unsupported(); }
Пример #29
0
 protected internal override T ReduceSizeof(SizeOf @sizeof)
 {
     return(Dispatch(@sizeof));
 }
Пример #30
0
        protected internal override void TraverseSizeof(SizeOf @sizeof)
        {
            var t = @sizeof.Type;

            _writer.Write("sizeof({0})", t == null ? "?" : t.GetCSharpRef(ToCSharpOptions.Informative));
        }
Пример #31
0
		public virtual object Visit (SizeOf sizeOfExpression)
		{
			return null;
		}
Пример #32
0
        public static void DumpHumanReadable(Transaction tx, string path, Page start)
        {
            using (var writer = File.CreateText(path))
            {
                var stack = new Stack <Page>();
                stack.Push(start);
                writer.WriteLine("Root page #{0}", start.PageNumber);
                while (stack.Count > 0)
                {
                    var currentPage = stack.Pop();
                    if (currentPage.IsLeaf)
                    {
                        writer.WriteLine();
                        writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Leaf), Used: {3} : {4}", currentPage.PageNumber, currentPage.NumberOfEntries, currentPage.Flags, currentPage.SizeUsed, currentPage.CalcSizeUsed());
                        if (currentPage.NumberOfEntries <= 0)
                        {
                            writer.WriteLine("Empty page (tree corrupted?)");
                        }


                        for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
                        {
                            var node = currentPage.GetNode(nodeIndex);
                            var key  = currentPage.GetNodeKey(node);

                            writer.WriteLine("Node #{0}, Flags = {1}, {4} = {2}, Key = {3}, Entry Size: {5}", nodeIndex, node->Flags, node->DataSize, MaxString(key.ToString(), 25), node->Flags == NodeFlags.Data ? "Size" : "Page",
                                             SizeOf.NodeEntry(node));
                        }
                        writer.WriteLine();
                    }
                    else if (currentPage.IsBranch)
                    {
                        writer.WriteLine();
                        writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Branch), Used: {3} : {4}", currentPage.PageNumber, currentPage.NumberOfEntries, currentPage.Flags, currentPage.SizeUsed, currentPage.SizeUsed);

                        var key = new Slice(SliceOptions.Key);
                        for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
                        {
                            var node = currentPage.GetNode(nodeIndex);
                            writer.WriteLine("Node #{2}, {0}  / to page #{1}, Entry Size: {3}", GetBranchNodeString(nodeIndex, key, currentPage, node), node->PageNumber, nodeIndex,
                                             SizeOf.NodeEntry(node));
                        }

                        for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
                        {
                            var node = currentPage.GetNode(nodeIndex);
                            if (node->PageNumber < 0 || node->PageNumber > tx.State.NextPageNumber)
                            {
                                writer.Write("Found invalid reference to page #{0}", currentPage.PageNumber);
                                stack.Clear();
                                break;
                            }

                            var child = tx.GetReadOnlyPage(node->PageNumber);
                            stack.Push(child);
                        }

                        writer.WriteLine();
                    }
                }
            }
        }
Пример #33
0
 protected internal override Node TransformSizeof(SizeOf @sizeof)
 {
     return(Dispatch(@sizeof));
 }
Пример #34
0
 public virtual object Visit(SizeOf sizeOfExpression)
 {
     return(null);
 }
 protected internal virtual Node TransformSizeof(SizeOf @sizeof) { return @sizeof.AcceptTransformer(this, true); }