コード例 #1
0
ファイル: frame.cs プロジェクト: jantolenaar/kiezellisp
 public Frame(List<Symbol> names)
 {
     Link = null;
     Names = names ?? new List<Symbol>();
     Values = null;
 }
コード例 #2
0
ファイル: frame.cs プロジェクト: jantolenaar/kiezellisp
 public Frame(Frame template, List<object> args)
 {
     Link = template.Link;
     Names = template.Names;
     Values = args;
 }
コード例 #3
0
ファイル: frame.cs プロジェクト: jantolenaar/kiezellisp
 public FrameAndScope()
 {
     Frame = new Frame();
     Scope = new AnalysisScope();
     Scope.IsFileScope = true;
     Scope.IsBlockScope = true;
 }
コード例 #4
0
 public static ThreadContextState SaveStackAndFrameWith(Frame frame, Cons form)
 {
     // used by compiler generated code
     return CurrentThreadContext.SaveStackAndFrame(frame, form);
 }
コード例 #5
0
        public static AnalysisScope ReconstructAnalysisScope(Frame context, AnalysisScope consoleScope = null)
        {
            if (consoleScope == null)
            {
                consoleScope = new AnalysisScope();
            }

            var stack = new Stack<AnalysisScope>();
            stack.Push(consoleScope);

            var scope = consoleScope;
            scope.Names = null;

            for (var frame = context; frame != null; frame = frame.Link)
            {
                if (frame.Names == null)
                {
                    continue;
                }

                if (scope == null)
                {
                    scope = new AnalysisScope();
                    stack.Push(scope);
                }

                scope.Names = new List<Symbol>();

                foreach (var key in frame.Names)
                {
                    scope.DefineFrameLocal(key, ScopeFlags.All);
                }

                scope = null;
            }

            scope = null;

            while (stack.Count > 0)
            {
                var top = stack.Pop();
                top.Parent = scope;
                scope = top;
            }

            return scope;
        }
コード例 #6
0
ファイル: threading.cs プロジェクト: jantolenaar/kiezellisp
        public ThreadContextState SaveStackAndFrame(Frame frame = null, Cons form = null)
        {
            var saved = new ThreadContextState();

            saved.EvaluationStack = EvaluationStack;
            saved.SpecialStack = SpecialStack;
            saved.Frame = Frame;
            saved.NestingDepth = NestingDepth;

            ++NestingDepth;

            if (NestingDepth == 10000)
            {
                Debugger.Break();
            }

            if (frame != null)
            {
                Frame = new Frame(frame, null);
                Frame.Link = saved.Frame;
            }

            if (form != null)
            {
                EvaluationStack = Runtime.MakeCons(form, EvaluationStack);
            }

            return saved;
        }
コード例 #7
0
ファイル: compiler.cs プロジェクト: jantolenaar/kiezellisp
        public static Expression WrapEvaluationStack(Expression code, Frame frame = null, Cons form = null)
        {
            // For function, try and loop: anything that has a non-local exit method.
            var saved = Expression.Parameter(typeof(ThreadContextState), "saved");
            var result = Expression.Parameter(typeof(object), "result");
            var index = Expression.Parameter(typeof(int), "index");
            var exprs = new List<Expression>();

            exprs.Add(Expression.Assign(saved, CallRuntime(SaveStackAndFrameWithMethod,
                Expression.Constant(frame, typeof(Frame)),
                Expression.Constant(form, typeof(Cons)))));

            //if ( form != null )
            //{
            //    exprs.Add( Expression.Assign( index, CallRuntime( LogBeginCallMethod, Expression.Constant( form ) ) ) );
            //}

            exprs.Add(Expression.Assign(result, code));

            //if ( form != null )
            //{
            //    exprs.Add( CallRuntime( LogEndCallMethod, index ) );
            //}

            exprs.Add(CallRuntime(RestoreStackAndFrameMethod, saved));
            exprs.Add(result);

            return Expression.Block
                    (
                typeof(object),
                new[] { saved, result, index },
                exprs
            );
        }