Example #1
0
 public void OpenScopeFor(Action body,
                          bool when = true,
                          Action <ScopeFrame> withInit = null,
                          ScopeFrame parentScope       = null,
                          BikeFunction func            = null)
 {
     if (when)
     {
         var scopeFrame = new ScopeFrame(func, GlobalFrame, parentScope ?? CurrentFrame, CurrentFrame);
         if (withInit != null)
         {
             withInit(scopeFrame);
         }
         Push(scopeFrame);
     }
     try
     {
         body();
     }
     finally
     {
         if (when)
         {
             Pop();
         }
     }
 }
Example #2
0
 private void Push(ScopeFrame frame)
 {
     lock (syncLock)
     {
         stack.Push(frame);
     }
 }
Example #3
0
 public ScopeStack(ScopeStack otherStack)
 {
     GlobalFrame = otherStack.GlobalFrame;
     lock (otherStack.syncLock)
     {
         stack = new Stack <ScopeFrame>(otherStack.stack);
     }
 }
Example #4
0
 public T OpenScopeFor <T>(Func <T> body,
                           bool when = true,
                           Action <ScopeFrame> withInit = null,
                           ScopeFrame parentScope       = null,
                           BikeFunction func            = null)
 {
     return(scopeStack.OpenScopeFor(body, when, withInit, parentScope, func));
 }
Example #5
0
 public void OpenScopeFor(Action body,
                          bool when = true,
                          Action <ScopeFrame> withInit = null,
                          ScopeFrame parentScope       = null,
                          BikeFunction func            = null)
 {
     scopeStack.OpenScopeFor(body, when, withInit, parentScope, func);
 }
Example #6
0
 private ScopeFrame(SourceLocation location, BikeFunction func, 
     ScopeFrame global, ScopeFrame parent, ScopeFrame caller)
 {
     this.Location = location;
     this.Func = func;
     this.global = global;
     this.parent = parent;
     this.Caller = caller;
 }
Example #7
0
 private ScopeFrame(SourceLocation location, BikeFunction func,
                    ScopeFrame global, ScopeFrame parent, ScopeFrame caller)
 {
     this.Location = location;
     this.Func     = func;
     this.global   = global;
     this.parent   = parent;
     this.Caller   = caller;
 }
Example #8
0
 internal InterpretationContext(InterpretationContext otherContext)
     : this(new ScopeStack(otherContext.scopeStack),
            otherContext.clrImportContext,
            new BikeImportContext(otherContext.bikeImportContext))
 {
     CurrentExecFolder = otherContext.CurrentExecFolder;
     CurrentLocation   = otherContext.CurrentLocation;
     LastFrame         = otherContext.LastFrame;
 }
Example #9
0
 public BikeFunction(Node node, Identifier funcName,
     List<FormalParameter> parameters, SourceElements body,
     ScopeFrame boundScope)
     : base(InterpretationContext.FunctionBase)
 {
     Node = node;
     Name = new BikeString(funcName == null ? Anonymous : funcName.Value);
     Parameters = parameters;
     Body = body;
     BoundScope = boundScope;
     DefineVariables();
 }
Example #10
0
        private static ScopeFrame InitScopeFrame()
        {
            var scopeFrame    = new ScopeFrame();
            var bikeNamespace = new BikeObject(ObjectBase);

            scopeFrame.Define("Bike", bikeNamespace);
            bikeNamespace.Define("Object", ObjectBase);
            bikeNamespace.Define("Array", ArrayBase);
            bikeNamespace.Define("String", StringBase);
            bikeNamespace.Define("Number", NumberBase);
            bikeNamespace.Define("Boolean", BooleanBase);
            bikeNamespace.Define("Function", FunctionBase);
            bikeNamespace.Define("Error", ErrorBase);
            return(scopeFrame);
        }
Example #11
0
 public ScopeFrame(BikeFunction func, ScopeFrame global, 
                   ScopeFrame parent, ScopeFrame caller)
     : this(InterpretationContext.Instance.CurrentLocation,
            func, global, parent, caller)
 {
 }
Example #12
0
        }                                                            // global frame

        public ScopeFrame(BikeFunction func, ScopeFrame global,
                          ScopeFrame parent, ScopeFrame caller)
            : this(InterpretationContext.Instance.CurrentLocation,
                   func, global, parent, caller)
        {
        }
Example #13
0
 public ScopeStack(ScopeFrame globalFrame)
 {
     GlobalFrame = globalFrame;
     stack.Push(globalFrame);
 }