コード例 #1
0
 public Binding Bind(string symbol, BindingRequestFlags options) {
   var request = new BindingRequest(this, CurrentNode, symbol, options);
   var binding = Bind(request); 
   if (binding == null)
     ThrowScriptError("Unknown symbol '{0}'.", symbol); 
   return binding; 
 }
コード例 #2
0
        }//method

        public virtual Binding BindSymbolForRead(BindingRequest request)
        {
            var symbol = request.Symbol;
            // First check current and enclosing scopes
            var currScope = request.Thread.CurrentScope;
            do
            {
                var existingSlot = currScope.Info.GetSlot(symbol);
                if (existingSlot != null)
                    return new SlotBinding(existingSlot, request.FromNode, request.FromScopeInfo);
                currScope = currScope.Parent;
            } while (currScope != null);

            // If not found, check imports
            foreach (var imp in request.FromModule.Imports)
            {
                var result = imp.Bind(request);
                if (result != null)
                    return result;
            }

            // Check built-in modules
            var builtIn = BuiltIns.Bind(request);
            if (builtIn != null) return builtIn;

            // if not found, return null
            return null;
        }
コード例 #3
0
ファイル: IBindingSource.cs プロジェクト: yangbodevp/irony
        //IBindingSource Members
        public Binding Bind(BindingRequest request)
        {
            IBindingSource target;

            if (TryGetValue(request.Symbol, out target))
            {
                return(target.Bind(request));
            }
            return(null);
        }
コード例 #4
0
        public Binding Bind(string symbol, BindingRequestFlags options)
        {
            var request = new BindingRequest(this, CurrentNode, symbol, options);
            var binding = Bind(request);

            if (binding == null)
            {
                ThrowScriptError("Unknown symbol '{0}'.", symbol);
            }
            return(binding);
        }
コード例 #5
0
        public virtual Binding BindSymbolForWrite(BindingRequest request)
        {
            var scope        = request.Thread.CurrentScope;
            var existingSlot = scope.Info.GetSlot(request.Symbol);

            //1. If new only, check it does not exist yet, create and return it
            if (request.Flags.IsSet(BindingRequestFlags.NewOnly))
            {
                if (existingSlot != null)
                {
                    request.Thread.ThrowScriptError("Variable {0} already exists.", request.Symbol);
                }

                var newSlot = scope.AddSlot(request.Symbol);
                return(new SlotBinding(newSlot, request.FromNode, request.FromScopeInfo));
            }

            //2. If exists, then return it
            if (existingSlot != null && request.Flags.IsSet(BindingRequestFlags.ExistingOrNew))
            {
                //TODO: For external client, check that slot is actually public or exported
                return(new SlotBinding(existingSlot, request.FromNode, request.FromScopeInfo));
            }

            //3. Check external module imports
            foreach (var imp in request.FromModule.Imports)
            {
                var result = imp.Bind(request);
                if (result != null)
                {
                    return(result);
                }
            }

            //4. If nothing found, create new slot in current scope
            if (request.Flags.IsSet(BindingRequestFlags.ExistingOrNew))
            {
                var newSlot = scope.AddSlot(request.Symbol);
                return(new SlotBinding(newSlot, request.FromNode, request.FromScopeInfo));
            }

            //5. Check built-in methods
            var builtIn = BuiltIns.Bind(request);

            if (builtIn != null)
            {
                return(builtIn);
            }

            //6. If still not found, return null.
            return(null);
        }
コード例 #6
0
 //Binds to local variables, enclosing scopes, module scopes/globals and built-ins
 public virtual Binding Bind(BindingRequest request) {
   var symbol = request.Symbol;
   var mode = request.Flags;
   if (mode.IsSet(BindingRequestFlags.Write))
     return BindSymbolForWrite(request);
   else if (mode.IsSet(BindingRequestFlags.Read))
     return BindSymbolForRead(request);
   else {
     //TODO: need to throw fatal error here
     request.Thread.ThrowScriptError("Invalid binding request, access type (Read or Write) is not set in request Options.");
     return null; // never happens
   }
 }//method
コード例 #7
0
        //Binds to local variables, enclosing scopes, module scopes/globals and built-ins
        public virtual Binding Bind(BindingRequest request)
        {
            var mode = request.Flags;

            if (mode.IsSet(BindingRequestFlags.Write))
            {
                return(BindSymbolForWrite(request));
            }
            else if (mode.IsSet(BindingRequestFlags.Read))
            {
                return(BindSymbolForRead(request));
            }
            else
            {
                //TODO: need to throw fatal error here
                request.Thread.ThrowScriptError("Invalid binding request, access type (Read or Write) is not set in request Options.");
                return(null); // never happens
            }
        }
コード例 #8
0
        }//method

        public virtual Binding BindSymbolForWrite(BindingRequest request)
        {
            var scope = request.Thread.CurrentScope;
            var existingSlot = scope.Info.GetSlot(request.Symbol);
            //1. If new only, check it does not exist yet, create and return it
            if (request.Flags.IsSet(BindingRequestFlags.NewOnly))
            {
                if (existingSlot != null)
                    request.Thread.ThrowScriptError("Variable {0} already exists.", request.Symbol);
                var newSlot = scope.AddSlot(request.Symbol);
                return new SlotBinding(newSlot, request.FromNode, request.FromScopeInfo);
            }
            //2. If exists, then return it
            if (existingSlot != null && request.Flags.IsSet(BindingRequestFlags.ExistingOrNew))
            {
                //TODO: For external client, check that slot is actually public or exported
                return new SlotBinding(existingSlot, request.FromNode, request.FromScopeInfo);
            }

            //3. Check external module imports
            foreach (var imp in request.FromModule.Imports)
            {
                var result = imp.Bind(request);
                if (result != null)
                    return result;
            }

            //4. If nothing found, create new slot in current scope
            if (request.Flags.IsSet(BindingRequestFlags.ExistingOrNew))
            {
                var newSlot = scope.AddSlot(request.Symbol);
                return new SlotBinding(newSlot, request.FromNode, request.FromScopeInfo);
            }

            //5. Check built-in methods
            var builtIn = BuiltIns.Bind(request);
            if (builtIn != null) return builtIn;

            //6. If still not found, return null.
            return null;
        }//method
コード例 #9
0
        public virtual Binding BindSymbolForRead(BindingRequest request)
        {
            var symbol = request.Symbol;
            // First check current and enclosing scopes
            var currScope = request.Thread.CurrentScope;

            do
            {
                var existingSlot = currScope.Info.GetSlot(symbol);
                if (existingSlot != null)
                {
                    return(new SlotBinding(existingSlot, request.FromNode, request.FromScopeInfo));
                }
                currScope = currScope.Parent;
            } while (currScope != null);

            // If not found, check imports
            foreach (var imp in request.FromModule.Imports)
            {
                var result = imp.Bind(request);
                if (result != null)
                {
                    return(result);
                }
            }

            // Check built-in modules
            var builtIn = BuiltIns.Bind(request);

            if (builtIn != null)
            {
                return(builtIn);
            }

            // if not found, return null
            return(null);
        }
コード例 #10
0
 public virtual Binding Bind(BindingRequest request) {
   throw new NotImplementedException();
 }
コード例 #11
0
ファイル: ModuleExport.cs プロジェクト: yangbodevp/irony
 public Binding Bind(BindingRequest request)
 {
     return(null);
 }
コード例 #12
0
 public override Binding Bind(BindingRequest request)
 {
     return(_binding);
 }
コード例 #13
0
 //Implement IBindingSource.Bind
 public Binding Bind(BindingRequest request)
 {
     return(BindingInstance);
 }
コード例 #14
0
 public Binding Bind(BindingRequest request) {
   return Binding; 
 }
コード例 #15
0
ファイル: ModuleInfo.cs プロジェクト: yangbodevp/irony
 //Used for imported modules
 public Binding BindToExport(BindingRequest request)
 {
     return(null);
 }
コード例 #16
0
 public Binding Bind(BindingRequest request)
 {
     return(Runtime.Bind(request));
 }
コード例 #17
0
 public virtual Binding Bind(BindingRequest request)
 {
     throw new NotImplementedException();
 }
コード例 #18
0
 public override Binding Bind(BindingRequest request) {
   return _binding;
 }
コード例 #19
0
 //Binds symbol to a public member exported by a module.
 public virtual Binding BindSymbol(BindingRequest request, ModuleInfo module)
 {
     return module.BindToExport(request);
 }
コード例 #20
0
 //Implement IBindingSource.Bind
 public Binding Bind(BindingRequest request) {
   return BindingInstance;
 }
コード例 #21
0
ファイル: ModuleExport.cs プロジェクト: androdev4u/XLParser
 public Binding Bind(BindingRequest request) {
   return null;
 }
コード例 #22
0
 //Binds symbol to a public member exported by a module.
 public virtual Binding BindSymbol(BindingRequest request, ModuleInfo module)
 {
     return(module.BindToExport(request));
 }
コード例 #23
0
 public Binding Bind(BindingRequest request) {
   return Runtime.Bind(request);
 }
コード例 #24
0
 //IBindingSource Members
 public Binding Bind(BindingRequest request)
 {
     return(TryGetValue(request.Symbol, out IBindingSource target) ? target.Bind(request) : null);
 }