示例#1
0
        private static ProcDefBlock ToProcDef(JToken json)
        {
            ProcDefBlock    b        = new ProcDefBlock();
            string          procName = json[1][0].ToString();
            List <string>   argNames = new List <string>();
            List <DataType> argTypes = new List <DataType>();

            for (int i = 1; i < json[1].Count(); i += 2)
            {
                argNames.Add(json[1][i].ToString());
                argTypes.Add(DataTypeNames.TypeOf(json[1][i + 1].ToString()));
            }
            string[] bits     = procName.SplitFuncArgs();
            int      argCount = 0;

            for (int i = 0; i < bits.Length; ++i)
            {
                string bit = bits[i];
                if (bit == "%")
                {
                    b.AddBit(new VarDefBlock(argNames[argCount], argTypes[argCount]));
                    argCount++;
                }
                else
                {
                    b.AddBit(new ProcDefTextBit(bit));
                }
            }
            return(b);
        }
示例#2
0
        public InvokationBlock ToInvokationBlock(JToken json)
        {
            string name            = json[0].ToString();
            string typeFingerPrint = json[1].ToString();
            string retTypeName     = json[2].ToString();

            TypeCheck(name, typeFingerPrint);
            DataType[]    argTypes = DataTypeNames.DecodeFingerprint(typeFingerPrint);
            DataType      retType  = DataTypeNames.TypeOf(retTypeName);
            List <IBlock> args     = new List <IBlock>();

            for (int i = 3; i < json.Count(); ++i)
            {
                args.Add(ToBlock(json[i]));
            }
            BlockAttributes attr;

            if (!blockSpace.RegisteredMethodAttribute(name, out attr))
            {
                attr = BlockAttributes.Stack;
            }
            InvokationBlock ib = new InvokationBlock(name, attr, argTypes, retType);

            ib.Args.AddRange(args.ToArray(), argTypes.ToArray());
            return(ib);
        }
示例#3
0
        public string ToJson()
        {
            List <string> lst = new List <string>();

            lst.AddRange(this.Args.Select(b => b.ToJson()));
            return(string.Format("[\"{0}\",\"{1}\",\"{2}\", {3}]",
                                 this.Text,
                                 DataTypeNames.TypeFingerprint(this.ArgTypes),
                                 this.ReturnType,
                                 lst.Combine(", ")));
        }
示例#4
0
        public string ToJson()
        {
            List <string> lst = new List <string>();

            lst.Add("\"define\"");

            List <string> lst2 = new List <string>();

            lst2.Add(this.GetMethodString());
            lst2.AddRange(this.GetArgNames().InterleavedWith(this.GetArgTypes().Select(at => DataTypeNames.NameOf(at))));
            lst.Add(string.Format("[{0}]", lst2.Select(a => string.Format("\"{0}\"", a)).Combine(", ")));

            return(string.Format("[{0}]", lst.Combine(", ")));
        }
示例#5
0
 public static string TypeFingerprint(IEnumerable <DataType> types)
 {
     return(types.Select(t => DataTypeNames.NameOf(t)).Combine(","));
 }