Beispiel #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);
        }
Beispiel #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);
        }