Exemplo n.º 1
0
        public Smartcontract GenerateSmartcontract(string sendTo, IXISettings settings)
        {
            //we first take the code and lex it
            var lexedCode = Lexing(_code);

            var name = lexedCode.Line.Split(' ')[0];

            var smart = new Smartcontract(name, sendTo);

            var list = new List <string>();

            SearchForNode(list, lexedCode);

            list.SelectMany(x => {
                var helper = new ExpressionHelper(x);

                if (helper.Contains("["))
                {
                    var arrayList = new List <string>();
                    for (int i = 0; i < int.Parse(helper[helper.Length - 2]); i++)
                    {
                        arrayList.Add(helper[1] + "_" + i);
                    }

                    return(arrayList);
                }
                else
                {
                    return(new List <string>()
                    {
                        helper[1]
                    });
                }
            }).ToList().ForEach(x => smart.AddVariable(x, new SC_Int()));

            return(smart.AddExpression(Parse(lexedCode).Compile()).Final(settings));
        }