Пример #1
0
        public System.Type emit()
        {
            if (m_type == null)
              {
            if (Debug) Console.WriteLine("-- emit:   " + m_qname);

            // make sure we have reflected to setup slots
            reflect();

            // if sys class, just load it by name
            string podName = m_pod.m_name;
            if (podName == "sys")
            {
              try
              {
            m_dotnetRepr = FanUtil.isDotnetRepresentation(this);
            m_type = System.Type.GetType(FanUtil.toDotnetImplTypeName(podName, m_name));
              }
              catch (Exception e)
              {
            Err.dumpStack(e);
            throw Err.make("Cannot load precompiled class: " + m_qname, e).val;
              }
            }

            // otherwise we need to emit it
            else
            {
              try
              {
            System.Type[] types = FTypeEmit.emitAndLoad(m_ftype);
            this.m_type = types[0];
            if (types.Length > 1)
              this.m_auxType = types[1];
              }
              catch (Exception e)
              {
            Err.dumpStack(e);
            throw Err.make("Cannot emit: " + m_qname, e).val;
              }
            }

            // we are done with our ftype now, gc it
            this.m_ftype = null;
              }
              return m_type;
        }
Пример #2
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 public FErrEmit(Emitter emitter, Type parent, FType type)
     : base(emitter, parent, type)
 {
 }
Пример #3
0
        //////////////////////////////////////////////////////////////////////////
        // Factory
        //////////////////////////////////////////////////////////////////////////
        public static System.Type[] emitAndLoad(FType ftype)
        {
            string className = ftype.m_pod.nname(ftype.m_self);
              Assembly assembly = emitPod(ftype.m_pod, true, null);

              FTypeEmit[] emitted = (FTypeEmit[])ftypes[ftype];
              System.Type[] types = new System.Type[emitted.Length];
              for (int i=0; i<emitted.Length; i++)
              {
            FTypeEmit e = emitted[i];
            types[i] = assembly.GetType(e.className);
              }

              return types;
        }
Пример #4
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 internal ClassType(Pod pod, FType ftype)
 {
     this.m_pod      = pod;
       this.m_ftype    = ftype;
       this.m_name     = pod.fpod.typeRef(ftype.m_self).typeName;
       this.m_qname    = pod.m_name + "::" + m_name;
       this.m_nullable = new NullableType(this);
       this.m_flags    = ftype.m_flags;
       if (Debug) Console.WriteLine("-- init:   " + m_qname);
 }
Пример #5
0
        private static Hashtable ftypes = new Hashtable(); // ftype[] lookup

        #endregion Fields

        #region Constructors

        //////////////////////////////////////////////////////////////////////////
        // Constructor
        //////////////////////////////////////////////////////////////////////////
        protected FTypeEmit(Emitter emitter, Type parent, FType type)
        {
            this.emitter = emitter;
              this.parent  = parent;
              this.pod     = type.m_pod;
              this.type    = type;
        }
Пример #6
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 public FMixinInterfaceEmit(Emitter emitter, Type parent, FType type)
     : base(emitter, parent, type)
 {
 }
Пример #7
0
 public void type(FType type)
 {
     WriteLine("--" + typeRef(type.m_self) + " extends " + typeRef(type.m_base) + "--");
       if (type.m_mixins.Length > 0)
       {
     Write("  mixin ");
     for (int i=0; i<type.m_mixins.Length; i++)
     {
       if (i > 0) Write(", ");
       Write(typeRef(type.m_mixins[i]));
     }
     WriteLine();
       }
       attrs(type.m_attrs);
       WriteLine();
       for (int i=0; i<type.m_fields.Length; i++)  field(type.m_fields[i]);
       for (int i=0; i<type.m_methods.Length; i++) method(type.m_methods[i]);
       Flush();
 }
Пример #8
0
 private void readTypeMeta(FStore.Input input)
 {
     m_types = new FType[input.u2()];
       for (int i=0; i<m_types.Length; i++)
       {
     m_types[i] = new FType(this).readMeta(input);
     m_types[i].m_hollow = true;
       }
       input.Close();
 }
Пример #9
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 public FMixinBodyEmit(Emitter emitter, Type parent, FType type)
     : base(emitter, parent, type)
 {
 }