public EthSharpCompilerContext()
 {
     Assembly           = new EthSharpAssembly();
     StorageIdentifiers = new Dictionary <string, int>();
     _tagCount          = 1;
     _storageTracker    = 0;
 }
Exemple #2
0
 public EthSharpCompilerContext(SyntaxTree root)
 {
     Assembly               = new EthSharpAssembly();
     StorageIdentifiers     = new Dictionary <string, int>();
     MethodBlockEntryPoints = new Dictionary <string, EthSharpAssemblyItem>();
     MethodQueue            = new Queue <MethodDeclarationSyntax>();
     _tagCount              = 1;
     _storageTracker        = 0;
     Root = root;
 }
        // constructor also goes here
        private EvmByteCode WrapByteCode(EvmByteCode toWrap)
        {
            var preAssembly = new EthSharpAssembly();

            preAssembly.Append(toWrap.ByteCode.Count);   // push length of bytecode
            preAssembly.Append(0x0c);                    // push offset of bytecode - TODO: THIS COULD CHANGE IF THIS BLOCK CHANGES!
            preAssembly.Append(UInt256.Zero);            // push memory location to store in (0)
            preAssembly.Append(EvmInstruction.CODECOPY); // codecopy
            preAssembly.Append(toWrap.ByteCode.Count);   // push length of code to pick
            preAssembly.Append(UInt256.Zero);            // push location of code (0)
            preAssembly.Append(EvmInstruction.RETURN);
            var preByteCode = preAssembly.Assemble();

            toWrap.ByteCode.InsertRange(0, preByteCode.ByteCode);
            return(toWrap);
        }