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(); } } }
private void Push(ScopeFrame frame) { lock (syncLock) { stack.Push(frame); } }
public ScopeStack(ScopeStack otherStack) { GlobalFrame = otherStack.GlobalFrame; lock (otherStack.syncLock) { stack = new Stack <ScopeFrame>(otherStack.stack); } }
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)); }
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); }
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; }
internal InterpretationContext(InterpretationContext otherContext) : this(new ScopeStack(otherContext.scopeStack), otherContext.clrImportContext, new BikeImportContext(otherContext.bikeImportContext)) { CurrentExecFolder = otherContext.CurrentExecFolder; CurrentLocation = otherContext.CurrentLocation; LastFrame = otherContext.LastFrame; }
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(); }
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); }
public ScopeFrame(BikeFunction func, ScopeFrame global, ScopeFrame parent, ScopeFrame caller) : this(InterpretationContext.Instance.CurrentLocation, func, global, parent, caller) { }
} // global frame public ScopeFrame(BikeFunction func, ScopeFrame global, ScopeFrame parent, ScopeFrame caller) : this(InterpretationContext.Instance.CurrentLocation, func, global, parent, caller) { }
public ScopeStack(ScopeFrame globalFrame) { GlobalFrame = globalFrame; stack.Push(globalFrame); }