Ejemplo n.º 1
0
        /// <summary>
        /// Define class by name.
        /// </summary>
        /// <remarks>
        /// 'assemblyName%global::namespace/className' - VALID
        /// <br/>
        /// 'global::namespace/className' - VALID
        /// <br/>
        /// 'namespace/className' - INVALID, need 'global::' prefix.
        /// <br/>
        /// 'className' - INVALID, need describe namespace.
        /// </remarks>
        /// <exception cref="IncompleteClassNameException">See 'remarks'.</exception>
        public ClassBuilder DefineClass(string classFullname)
        {
            if (!classFullname.Contains("/"))
            {
                throw new IncompleteClassNameException("Class name not contained namespace.");
            }
            var typename = default(QualityTypeName);

            if (classFullname.Contains("%"))
            {
                if (!classFullname.StartsWith($"{Name}%"))
                {
                    throw new IncompleteClassNameException($"Class name contains incorrect assembly name.");
                }
                typename = new QualityTypeName(classFullname);
            }
            else
            {
                typename = new QualityTypeName($"{Name}%{classFullname}");
            }

            if (typename.TryGet(x => x.Namespace) is null)
            {
                throw new IncompleteClassNameException($"Class name has incorrect format.");
            }
            if (!typename.Namespace.StartsWith("global::"))
            {
                throw new IncompleteClassNameException($"Class namespace not start with 'global::'.");
            }

            return(DefineClass(typename));
        }
Ejemplo n.º 2
0
        public static void PutTypeNameInto(this ILGenerator gen, QualityTypeName type, BinaryWriter writer)
        {
            Func <QualityTypeName, int> getConst = gen._methodBuilder.moduleBuilder.InternTypeName;

            var key = getConst(type);

            writer.Write(key);
        }
Ejemplo n.º 3
0
        public static void PutTypeName(this ILGenerator gen, QualityTypeName type)
        {
            Func <QualityTypeName, int> getConst = gen._methodBuilder.moduleBuilder.InternTypeName;

            var key = getConst(type);

            gen.PutInteger4(key);
        }
Ejemplo n.º 4
0
 internal RuntimeIshtarClass(QualityTypeName name, VeinClass[] parents, RuntimeIshtarModule module)
     : base(name, parents, module)
 {
     if (module is null)
     {
         return;
     }
     ID            = module.Vault.TokenGranted.GrantClassID();
     runtime_token = new RuntimeToken(module.ID, ID);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Intern TypeName constant into module storage and return TypeName index.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        public int InternTypeName(QualityTypeName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            var key = _intern(types_table, name);

            //logger.Information("TypeName '{name}' baked by index: {key}", name, key);
            return(key);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Define class by name.
        /// </summary>
        public ClassBuilder DefineClass(QualityTypeName name)
        {
            if (class_table.Any(x => x.FullName.Equals(name)))
            {
                throw new DuplicateNameException($"Class '{name}' already defined.");
            }
            InternString(name.Name);
            InternString(name.Namespace);
            InternString(name.AssemblyName);
            var c = new ClassBuilder(this, name);

            class_table.Add(c);
            return(c);
        }
Ejemplo n.º 7
0
        public static RuntimeIshtarMethod GetMethod(uint index, QualityTypeName owner, VeinModule module, CallFrame frame)
        {
            var clazz = module.FindType(owner);
            var name  = module.GetConstStringByIndex((int)index);

            var method = clazz.FindMethod(name, m => m.Name.Equals(name));

            if (method is null)
            {
                FastFail(WNE.MISSING_METHOD, $"Method '{name}' not found in '{clazz.FullName.NameWithNS}'", frame);
                ValidateLastError();
                return(null);
            }
            Assert(method is RuntimeIshtarMethod, WNE.MISSING_METHOD, $"metadata is corrupted.");
            return((RuntimeIshtarMethod)method);
        }
Ejemplo n.º 8
0
 private IshtarMetaClass(QualityTypeName name) => this.FullName = name;
Ejemplo n.º 9
0
        public static void WriteTypeName(this BinaryWriter bin, QualityTypeName type, VeinModuleBuilder module)
        {
            var key = module.InternTypeName(type);

            bin.Write(key);
        }
Ejemplo n.º 10
0
 public UnresolvedVeinClass(QualityTypeName fullName)
 => this.FullName = fullName;