예제 #1
0
        private void CompilePublicMethod(MethodDeclarationSyntax method, EthSharpAssemblyItem jumpDest)
        {
            Context.Append(jumpDest); // jumpdest for this public method
            int tagToJumpOutTo = Context.GetNewTag();

            Context.Append(new EthSharpAssemblyItem(AssemblyItemType.PushTag, tagToJumpOutTo)); // push jump back tag
            var internalMethodTag = Context.GetMethodTag(method);

            Context.Append(new EthSharpAssemblyItem(AssemblyItemType.PushTag, internalMethodTag)); // push private jump tag
            Context.Append(EvmInstruction.JUMP);
            Context.Append(new EthSharpAssemblyItem(AssemblyItemType.Tag, tagToJumpOutTo));        // jump back tag
            if (method.ReturnType.Kind() == SyntaxKind.VoidKeyword)
            {
                Context.Append(EvmInstruction.STOP);
            }
            else
            {
                // need to MSTORE the value currently on top of stack
                Context.Append(UInt256.Zero);
                Context.Append(EvmInstruction.MSTORE);
                // then add values for where it is
                Context.Append(0x20);
                Context.Append(UInt256.Zero);
                Context.Append(EvmInstruction.RETURN);
            }
        }
 public void Append(EthSharpAssemblyItem item)
 {
     Assembly.Append(item);
 }
예제 #3
0
 public void Append(EthSharpAssemblyItem assemblyItem)
 {
     Items.Add(assemblyItem);
 }