FStore models IO streams to use for reading and writing pod files.
示例#1
0
文件: FAttrs.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Read
        //////////////////////////////////////////////////////////////////////////
        public static FAttrs read(FStore.Input input)
        {
            int n = input.u2();
              if (n == 0) return none;
              FAttrs attrs = new FAttrs();
              for (int i=0; i<n; ++i)
              {
            string name = input.name();

            switch (name[0])
            {
              case 'E':
            if (name == FConst.ErrTableAttr) { attrs.errTable(input); continue; }
            break;
              case 'F':
            if (name == FConst.FacetsAttr) { attrs.facets(input); continue; }
            break;
              case 'L':
            if (name == FConst.LineNumberAttr) { attrs.lineNumber(input); continue; }
            if (name == FConst.LineNumbersAttr) { attrs.lineNumbers(input); continue; }
            break;
              case 'S':
            if (name == FConst.SourceFileAttr) { attrs.sourceFile(input); continue; }
            break;
            }
            int skip = input.u2();
            if (input.skip(skip) != skip)
              throw new System.IO.IOException("Can't skip over attr " + name);
              }
              return attrs;
        }
示例#2
0
文件: FField.cs 项目: nomit007/f4
        public int m_type; // type qname index

        #endregion Fields

        #region Methods

        public FField read(FStore.Input input)
        {
            base.readCommon(input);
              m_type = input.u2();
              base.readAttrs(input);
              return this;
        }
示例#3
0
文件: FBuf.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // IO
        //////////////////////////////////////////////////////////////////////////
        public static FBuf read(FStore.Input input)
        {
            int len = input.u2();
              if (len == 0) return null;

              byte[] buf = new byte[len];
              for (int r=0; r<len;) r += input.Read(buf, r, len-r);
              return new FBuf(buf, len);
        }
示例#4
0
文件: FPod.cs 项目: nomit007/f4
        private NField[] m_nfields; // cached fan fieldRef  -> .NET field signatures

        #endregion Fields

        #region Constructors

        //////////////////////////////////////////////////////////////////////////
        // Constructor
        //////////////////////////////////////////////////////////////////////////
        public FPod(string podName, FStore store)
        {
            if (store != null) store.fpod = this;
              this.m_podName    = podName;
              this.m_store      = store;
              this.m_names      = new FTable.Names(this);
              this.m_typeRefs   = new FTable.TypeRefs(this);
              this.m_fieldRefs  = new FTable.FieldRefs(this);
              this.m_methodRefs = new FTable.MethodRefs(this);
        }
示例#5
0
文件: FAttrs.cs 项目: nomit007/f4
 private void facets(FStore.Input input)
 {
     input.u2();
       int n = input.u2();
       m_facets = new FFacet[n];
       for (int i=0; i<n; ++i)
       {
     FFacet f = m_facets[i] = new FFacet();
     f.type = input.u2();
     f.val  = input.utf();
       }
 }
示例#6
0
文件: FPod.cs 项目: syatanic/fantom
        //////////////////////////////////////////////////////////////////////////
        // Constructor
        //////////////////////////////////////////////////////////////////////////

        public FPod(string podName, FStore store)
        {
            if (store != null)
            {
                store.fpod = this;
            }
            this.m_podName    = podName;
            this.m_store      = store;
            this.m_names      = new FTable.Names(this);
            this.m_typeRefs   = new FTable.TypeRefs(this);
            this.m_fieldRefs  = new FTable.FieldRefs(this);
            this.m_methodRefs = new FTable.MethodRefs(this);
        }
示例#7
0
文件: FMethod.cs 项目: nomit007/f4
 public FMethod read(FStore.Input input)
 {
     base.readCommon(input);
       m_ret = input.u2();
       m_inheritedRet = input.u2();
       m_maxStack   = input.u1();
       m_paramCount = input.u1();
       m_localCount = input.u1();
       m_vars = new FMethodVar[m_paramCount+m_localCount];
       for (int i=0; i<m_vars.Length; i++)
     m_vars[i] = new FMethodVar().read(input);
       m_code = FBuf.read(input);
       base.readAttrs(input);
       return this;
 }
示例#8
0
文件: FMethodVar.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // IO
        //////////////////////////////////////////////////////////////////////////
        public FMethodVar read(FStore.Input input)
        {
            name  = input.name();
              type  = input.u2();
              flags = input.u1();

              int attrCount = input.u2();
              for (int i=0; i<attrCount; ++i)
              {
            string attrName = input.fpod.name(input.u2());
            FBuf attrBuf = FBuf.read(input);
            if (attrName == FConst.ParamDefaultAttr)
              def = attrBuf;
              }
              return this;
        }
示例#9
0
文件: FType.cs 项目: nomit007/f4
        public void read(FStore.Input input)
        {
            if (input.fpod.m_fcodeVersion == null)
            throw new IOException("FStore.Input.version == null");

              m_fields = new FField[input.u2()];
              for (int i=0; i<m_fields.Length; i++)
            m_fields[i] = new FField().read(input);

              m_methods = new FMethod[input.u2()];
              for (int i=0; i<m_methods.Length; i++)
            m_methods[i] = new FMethod().read(input);

              m_attrs = FAttrs.read(input);

              m_hollow = false;
              input.Close();
        }
示例#10
0
文件: FTable.cs 项目: nomit007/f4
 public override FTable read(FStore.Input input)
 {
     if (input == null) { m_size = 0; return this; }
     m_size = input.u2();
     m_table = new object[m_size];
     for (int i=0; i<m_size; i++)
     {
       int[] x = { input.u2(), input.u2(), input.u2() };
       m_table[i] = new FTuple(x);
     }
     return this;
 }
示例#11
0
文件: FAttrs.cs 项目: nomit007/f4
 private void lineNumber(FStore.Input input)
 {
     input.u2();
       m_lineNum = input.u2();
 }
示例#12
0
文件: FPod.cs 项目: nomit007/f4
        private void readType(string name, FStore.Input input)
        {
            if (m_types == null || m_types.Length == 0)
            throw new System.IO.IOException("types.def must be defined first");

              string typeName = name.Substring(0, name.Length-".fcode".Length);
              for (int i=0; i<m_types.Length; ++i)
              {
            string n = typeRef(m_types[i].m_self).typeName;
            if (n == typeName) { m_types[i].read(input); return; }
              }

              throw new System.IO.IOException("Unexpected fcode file: " + name);
        }
示例#13
0
文件: FAttrs.cs 项目: nomit007/f4
 private void errTable(FStore.Input input)
 {
     m_errTable = FBuf.read(input);
 }
示例#14
0
文件: FPod.cs 项目: nomit007/f4
 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();
 }
示例#15
0
文件: FAttrs.cs 项目: nomit007/f4
 private void sourceFile(FStore.Input input)
 {
     input.u2();
       m_sourceFile = input.utf();
 }
示例#16
0
文件: FAttrs.cs 项目: nomit007/f4
 private void lineNumbers(FStore.Input input)
 {
     m_lineNums = FBuf.read(input);
 }
示例#17
0
文件: FPod.cs 项目: nomit007/f4
        private void readPodMeta(FStore.Input input)
        {
            // handle sys bootstrap specially using just java.util.Properties
              string metaName;
              if ("sys" == m_podName)
              {
            Properties props = new Properties();
            props.load(input);
            input.Close();
            metaName =  props.getProperty("pod.name");
            m_podVersion = props.getProperty("pod.version");
            m_fcodeVersion = props.getProperty("fcode.version");
            m_depends = new Depend[0];
            return;
              }
              else
              {
            SysInStream sysIn = new SysInStream(input);
            this.m_meta = (Map)sysIn.readProps().toImmutable();
            sysIn.close();

            metaName = meta("pod.name");
            m_podVersion = meta("pod.version");

            m_fcodeVersion = meta("fcode.version");
            string dependsStr = meta("pod.depends").Trim();
            if (dependsStr.Length == 0) m_depends = new Depend[0];
            else
            {
              string[] toks = dependsStr.Split(';');
              m_depends = new Depend[toks.Length];
              for (int i=0; i<m_depends.Length; ++i) m_depends[i] = Depend.fromStr(toks[i].Trim());
            }
              }

              // check meta name matches podName passed to ctor
              if (m_podName == null) m_podName = metaName;
              if (m_podName != metaName)
            throw new System.IO.IOException("Pod name mismatch " + m_podName + " != " + metaName);

              // sanity checking
              if (FConst.FCodeVersion != m_fcodeVersion)
            throw new System.IO.IOException("Invalid fcode version " + m_fcodeVersion);
        }
示例#18
0
文件: FSlot.cs 项目: nomit007/f4
 protected void readCommon(FStore.Input input)
 {
     m_name  = input.name();
       m_flags = input.u4();
 }
示例#19
0
文件: Pod.cs 项目: nomit007/f4
        public static FPod readFPod(string name)
        {
            FStore store = null;

              // handle sys specially for bootstrapping the VM
              if (name == "sys")
              {
            store = new FStore(new ZipFile(FileUtil.combine(Sys.m_podsDir, name + ".pod")));
              }

              // otherwise delegate to Env.cur to find the pod file
              else
              {
            FileSystemInfo file = null;
            Fan.Sys.File f = Env.cur().findPodFile(name);
            if (f != null) file = ((LocalFile)f).m_file;

            // if null or doesn't exist then its a no go
            if (file == null || !file.Exists) throw UnknownPodErr.make(name).val;

            // verify case since Windoze is case insensitive
            String actualName = file.Name; //getCanonicalFile().getName();
            actualName = actualName.Substring(0, actualName.Length-4);
            if (actualName != name) throw UnknownPodErr.make("Mismatch case: " + name + " != " + actualName).val;

            store = new FStore(new ZipFile(file.FullName));
              }

              // read in the FPod tables
              FPod fpod = new FPod(name, store);
              fpod.read();
              return fpod;
        }
示例#20
0
文件: FTable.cs 项目: nomit007/f4
 public override FTable read(FStore.Input input)
 {
     if (input == null) { m_size = 0; return this; }
      m_size = input.u2();
      m_table = new object[m_size];
      for (int i=0; i<m_size; i++)
        m_table[i] = Duration.make(input.u8());
      return this;
 }
示例#21
0
文件: FTypeRef.cs 项目: nomit007/f4
 //////////////////////////////////////////////////////////////////////////
 // IO
 //////////////////////////////////////////////////////////////////////////
 public static FTypeRef read(FStore.Input input)
 {
     FPod fpod = input.fpod;
       string podName = fpod.name(input.u2());
       string typeName = fpod.name(input.u2());
       string sig = input.utf(); // full sig if parameterized, "?" if nullable, or ""
       return new FTypeRef(podName, typeName, sig);
 }
示例#22
0
文件: FType.cs 项目: nomit007/f4
 //////////////////////////////////////////////////////////////////////////
 // Meta IO
 //////////////////////////////////////////////////////////////////////////
 public FType readMeta(FStore.Input input)
 {
     m_self  = input.u2();
       m_base  = input.u2();
       m_mixins = new int[input.u2()];
       for (int i=0; i<m_mixins.Length; i++) m_mixins[i] = input.u2();
       m_flags  = input.u4();
       return this;
 }
示例#23
0
文件: FTable.cs 项目: nomit007/f4
 public override FTable read(FStore.Input input)
 {
     if (input == null) { m_size = 0; return this; }
     m_size = input.u2();
     m_table = new object[m_size];
     for (int i=0; i<m_size; i++)
     {
       int parent = input.u2();
       int name   = input.u2();
       int ret    = input.u2();
       int paramn = input.u1();
       int[] x = new int[3+paramn];
       x[0] = parent;
       x[1] = name;
       x[2] = ret;
       for (int j=0; j<paramn; ++j)
     x[j+3] = input.u2();
       m_table[i] = new FTuple(x);
     }
     return this;
 }
示例#24
0
文件: FSlot.cs 项目: nomit007/f4
 protected void readAttrs(FStore.Input input)
 {
     m_attrs = FAttrs.read(input);
 }
示例#25
0
文件: FTable.cs 项目: nomit007/f4
 public override FTable read(FStore.Input input)
 {
     if (input == null) { m_size = 0; return this; }
      m_size = input.u2();
      m_table = new object[m_size];
      for (int i=0; i<m_size; i++)
        m_table[i] = Uri.fromStr(input.utf());
      return this;
 }
示例#26
0
文件: Nstub.cs 项目: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // Stub
        //////////////////////////////////////////////////////////////////////////
        public static void stub(string podName, DirectoryInfo outDir, bool verbose)
        {
            writeLine("    .NET Stub [" + podName + "]");

              string fanHome = SysProps.getProperty("fan.home");
              string podPath = fanHome + "\\lib\\fan\\" + podName + ".pod";
              string target = new FileInfo(outDir + "\\" + podName + ".dll").FullName;

              if (verbose)
              {
            writeLine("  <- " + podPath);
            Pod pod = Pod.doFind(podName, true, null);
            List list = pod.types();
            string pre = "Fan." + FanUtil.upper(podName) + ".";
            for (int i=0; i<list.sz(); i++)
              writeLine("  " + pre + (list.get(i) as Type).name());
            writeLine("  -> " + target);
              }

              FStore store = new FStore(new ZipFile(podPath));
              FPod fpod = new FPod(podName, store);
              fpod.read();
              FTypeEmit.emitPod(fpod, false, target);
        }
示例#27
0
文件: FTable.cs 项目: nomit007/f4
 ///
 /// Serialize.
 ///
 public abstract FTable read(FStore.Input input);