ClassType models a static type definition for an Obj class: 1) Hollow: in this state we know basic identity of the type, and it's inheritance hierarchy. A type is setup to be hollow during Pod.load(). 2) Reflected: in this state we read all the slot definitions from the fcode to populate the slot tables used to for reflection. At this point clients can discover the signatures of the Type. 3) Emitted: the final state of loading a Type is to emit to a .NET class called "Fan.{pod}.{type}". Once emitted we can instantiate the type or call it's methods. 4) Finished: once we have reflected the slots into memory and emitted the .NET class, the last stage is to bind the all the System.Reflection representations to the Slots for dynamic dispatch. We delay this until needed by Method or Field for a reflection invocation
상속: Type
예제 #1
0
파일: Pod.cs 프로젝트: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Load
        //////////////////////////////////////////////////////////////////////////
        internal void load(FPod fpod)
        {
            this.fpod = fpod;
              this.typesByName = new Hashtable();

              // create a hollow Type for each FType (this requires two steps,
              // because we don't necessary have all the Types created for
              // superclasses until this loop completes)
              m_types = new ClassType[fpod.m_types.Length];
              for (int i=0; i<fpod.m_types.Length; i++)
              {
            // create type instance
            ClassType type = new ClassType(this, fpod.m_types[i]);

            // add to my data structures
            m_types[i] = type;
            if (typesByName[type.m_name] != null)
              throw Err.make("Invalid pod: " + m_name + " type already defined: " + type.m_name).val;
            typesByName[type.m_name] = type;
              }

              // get TypeType to use for mixin List (we need to handle case
              // when loading sys itself - and lookup within my own pod)
              Type typeType = Sys.TypeType;
              if (typeType == null)
            typeType = (Type)typesByName["Type"];

              // now that everthing is mapped, we can fill in the super
              // class fields (unless something is wacked, this will only
              // use Types in my pod or in pods already loaded)
              for (int i=0; i<fpod.m_types.Length; i++)
              {
            FType ftype = fpod.m_types[i];
            ClassType type = m_types[i];
            type.m_base = findType(ftype.m_base);

            List mixins = new List(typeType, ftype.m_mixins.Length);
            for (int j=0; j<ftype.m_mixins.Length; j++)
              mixins.add(findType(ftype.m_mixins[j]));
            type.m_mixins = mixins.ro();
              }
        }
예제 #2
0
파일: Sys.cs 프로젝트: nomit007/f4
 private static ClassType initGeneric(int ch)
 {
     string name = ""+(char)ch;
       try
       {
     return m_genericParamTypes[ch] = new ClassType(m_sysPod, name, 0, null);
       }
       catch (Exception e)
       {
     throw initFail("generic " + name, e);
       }
 }