Пример #1
0
        /// <summary>
        /// Applies local names to a temporary scope. Is useful for expanding nodes that introduce a variable.
        /// </summary>
        public static T WithTempLocals <T>(Context ctx, Func <T> action, params Local[] vars)
        {
            var scope = new Scope(ScopeKind.Unclosured);

            foreach (var curr in vars)
            {
                scope.DeclareLocal(curr);
            }

            ctx.EnterScope(scope);
            var result = action();

            ctx.ExitScope();

            return(result);
        }