当前位置: 首页>>代码示例>>C#>>正文


C# SubRecord.SetStrData方法代码示例

本文整理汇总了C#中SubRecord.SetStrData方法的典型用法代码示例。如果您正苦于以下问题:C# SubRecord.SetStrData方法的具体用法?C# SubRecord.SetStrData怎么用?C# SubRecord.SetStrData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SubRecord的用法示例。


在下文中一共展示了SubRecord.SetStrData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compile

        public static bool Compile(Record r2, out string msg)
        {
            msg=null;
            r=new Record();
            string script=null;
            int scptype=0;
            foreach(SubRecord sr2 in r2.SubRecords) {
                if(sr2.Name=="SCTX") script=sr2.GetStrData();
                if(sr2.Name=="SCHR") {
                    byte[] tmp=sr2.GetReadonlyData();
                    scptype=TypeConverter.h2si(tmp[16], tmp[17], tmp[18], tmp[19]);
                }
            }
            if(script==null) {
                msg="Script had no SCTX record to compile";
                return false;
            }
            locals.Clear();
            localList.Clear();
            edidRefs.Clear();
            refcount=0;
            errors.Clear();

            ts=new TokenStream(script, errors);
            if(errors.Count>0) return OutputErrors( out msg);
            Token[] smt=ts.PopNextStatement();
            if(smt.Length!=2||!smt[0].IsKeyword(Keywords.ScriptName)||smt[1].token==null) return ReturnError("Expected 'ScriptName <edid>'", out msg);
            SubRecord sr=new SubRecord();
            sr.Name="EDID";
            sr.SetStrData(smt[1].utoken, true);
            r.AddRecord(sr);
            r.descriptiveName=" ("+smt[1].token+")";
            schr=new SubRecord();
            schr.Name="SCHR";
            r.AddRecord(schr);
            scda=new SubRecord();
            scda.Name="SCDA";
            r.AddRecord(scda);
            sr=new SubRecord();
            sr.Name="SCTX";
            sr.SetStrData(script, false);
            r.AddRecord(sr);

            bw=new BinaryWriter(new MemoryStream());
            Emit(0x001d);
            Emit(0x0000);
            try {
                HandleVariables();
            } catch(Exception ex) {
                return ReturnError(ex.Message, out msg);
            }
            for(int i=0;i<localList.Count;i++) {
                if(localList[i].type==VarType.Ref) {
                    sr=new SubRecord();
                    sr.Name="SCRV";
                    sr.SetData(TypeConverter.si2h(i+1));
                    r.AddRecord(sr);
                    refcount++;
                    localList[i].refid=refcount;
                }
            }
            while(ts.PeekNextStatement().Length>0) {
                try {
                    HandleBlock();
                } catch(Exception ex) {
                    return ReturnError(ex.Message, out msg);
                }
            }
            if(errors.Count>0) {
                return OutputErrors(out msg);
            }

            byte[] header=new byte[20];
            TypeConverter.si2h(refcount, header, 4);
            TypeConverter.i2h((uint)bw.BaseStream.Length, header, 8);
            TypeConverter.si2h(localList.Count, header, 12);
            TypeConverter.si2h(scptype, header, 16);
            schr.SetData(header);
            byte[] compileddata=((MemoryStream)bw.BaseStream).GetBuffer();
            if(compileddata.Length!=bw.BaseStream.Length) Array.Resize<byte>(ref compileddata, (int)bw.BaseStream.Length);
            scda.SetData(compileddata);
            r2.SubRecords.Clear();
            r2.SubRecords.AddRange(r.SubRecords);
            bw.Close();
            return true;
        }
开发者ID:robjer,项目名称:tesvsnip,代码行数:86,代码来源:ScriptCompiler.cs

示例2: HandleVariables

        private static void HandleVariables()
        {
            Token[] smt=ts.PeekNextStatement();
            SubRecord slsd;
            SubRecord scvr;
            while(smt.Length>0&&smt[0].IsType()) {
                ts.PopNextStatement();
                if(smt.Length!=2||smt[1].type!=TokenType.Unknown) {
                    AddError("Expected <type> <variable name>");
                    smt=ts.PeekNextStatement();
                    continue;
                }
                slsd=new SubRecord();
                slsd.Name="SLSD";
                byte[] data=new byte[24];
                TypeConverter.si2h(locals.Count+1, data, 0);
                if(smt[0].IsKeyword(Keywords.Int)) data[16]=1;
                slsd.SetData(data);
                r.AddRecord(slsd);
                scvr=new SubRecord();
                scvr.Name="SCVR";
                scvr.SetStrData(smt[1].utoken, true);
                r.AddRecord(scvr);

                LocalVar lv=new LocalVar(locals.Count+1, smt[0]);
                locals.Add(smt[1].token, lv);
                localList.Add(lv);
                ts.AddLocal(smt[1].token);

                smt=ts.PeekNextStatement();
            }
        }
开发者ID:robjer,项目名称:tesvsnip,代码行数:32,代码来源:ScriptCompiler.cs


注:本文中的SubRecord.SetStrData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。