Пример #1
0
        static CodeBlock RewriteBody(CodeBlock cb)
        {
            CodeBlock ncb = Ast.CodeBlock("temp-inline:" + cb.Name, cb.ReturnType);

            ncb.Parent = cb.Parent;

            foreach (var item in cb.Parameters)
            {
                Variable newvar = ncb.CreateParameter(item.Name, item.Type);
                newvar.Lift = item.Lift;
            }

            foreach (var item in cb.Variables)
            {
                Variable newvar = ncb.CreateLocalVariable(item.Name, item.Type);
                newvar.Lift = item.Lift;
            }

            Expression body = ((ReturnStatement)cb.Body).Expression;

            body = RewriteExpression(ncb, body);

            ncb.Body = Ast.Return(body);

            return(ncb);
        }