Пример #1
0
 public JavaClass(javaloader.ClassFile classfile, string[] srcfile = null)
 {
     this.classfile = classfile;
     this.srcfile   = srcfile;
     if (this.srcfile == null)
     {
         this.srcfile = new string[0];
     }
     foreach (var f in this.classfile.Fields)
     {
         this.fields.Add(f.Name, f.Signature);
     }
     foreach (var m in this.classfile.Methods)
     {
         bool bskip = false;
         if (m.Annotations != null)
         {
             object[] info = m.Annotations[0] as object[];
             if (info[1] as string == "LAntShares/SmartContract/Framework/Appcall;" ||
                 info[1] as string == "LAntShares/SmartContract/Framework/Syscall;" |
                 info[1] as string == "LAntShares/SmartContract/Framework/Opcall;")
             {
                 //continue;
                 bskip = true;
             }
             //if(m.Annotations[0])
         }
         var nm = new JavaMethod(this, m);
         nm.skip = bskip;
         this.methods[m.Name] = nm;
     }
     this.superClass = this.classfile.SuperClass;
 }
Пример #2
0
        public JavaClass LoadClassByBytes(byte[] data, string srccode = null)
        {
            var js     = new javaloader.ClassFile(data, 0, data.Length);
            var _class = new JavaClass(this, js, null);

            this.classes[_class.classfile.Name] = _class;
            return(_class);
        }
Пример #3
0
        public JavaClass(JavaModule module, javaloader.ClassFile classfile, string[] srcfile = null)
        {
            this.module    = module;
            this.classfile = classfile;
            if (this.classfile.IsEnum)
            {
                this.IsEnum = true;
                foreach (var m in this.classfile.Methods)
                {
                    if (m.Name == javaloader.StringConstants.CLINIT)
                    {
                        _InitConsts(m.Instructions);
                    }
                }
            }
            this.srcfile = srcfile;
            if (this.srcfile == null)
            {
                this.srcfile = new string[0];
            }
            foreach (var f in this.classfile.Fields)
            {
                this.fields.Add(f.Name, f.Signature);
            }
            bool isKtObj = false;

            if (this.classfile.SourceFileAttribute.Contains(".kt"))
            {
                var sign = "L" + this.classfile.Name + ";";
                foreach (var f in this.classfile.Fields)
                {
                    if (f.Name == "INSTANCE" && f.IsStatic && f.Signature == sign)
                    {
                        isKtObj = true;
                        break;
                    }
                }
            }
            foreach (var m in this.classfile.Methods)
            {
                bool bskip = false;
                if (m.IsStatic == false && isKtObj == false)
                {
                    bskip = true;
                    //静态成员不要,除非是kotlin 的 object 对象,相当于静态
                }

                if (m.Annotations != null)
                {
                    object[] info = m.Annotations[0] as object[];
                    if (info[1] as string == "Lorg/neo/smartcontract/framework/Appcall;" ||
                        info[1] as string == "Lorg/neo/smartcontract/framework/Syscall;" ||
                        info[1] as string == "Lorg/neo/smartcontract/framework/OpCode;" ||
                        info[1] as string == "Lorg/neo/smartcontract/framework/Nonemit;")
                    {
                        //continue;
                        bskip = true;
                    }
                    //if(m.Annotations[0])
                }
                if (m.Name == "<init>")
                {
                    bskip = true;
                }
                var nm = new JavaMethod(this, m);
                nm.skip = bskip;
                //if (bskip == false && methods.ContainsKey(m.Name))
                //{
                //    throw new Exception("already have a func named:" + classfile.Name + "." + m.Name);
                //}
                this.methods[m.Name + m.Signature] = nm;
            }
            this.superClass = this.classfile.SuperClass;
        }