Inheritance: DefaultBinder
Esempio n. 1
0
        internal DynamicMetaObject /*!*/ CreateMetaObject(DynamicMetaObjectBinder /*!*/ binder, Type /*!*/ returnType)
        {
            Debug.Assert(ControlFlowBuilder == null, "Control flow required but not built");

            var restrictions = _restrictions;
            var expr         = _error ? Ast.Throw(_result, returnType) : AstUtils.Convert(_result, returnType);

            if (_condition != null)
            {
                var deferral = binder.GetUpdateExpression(returnType);
                expr = Ast.Condition(_condition, expr, deferral);
            }

            if (_temps != null || _initializations != null)
            {
                AddInitialization(expr);
                if (_temps != null)
                {
                    expr = Ast.Block(_temps, _initializations);
                }
                else
                {
                    expr = Ast.Block(_initializations);
                }
            }

            Clear();
            RubyBinder.DumpRule(binder, restrictions, expr);
            return(new DynamicMetaObject(expr, restrictions));
        }
Esempio n. 2
0
        internal AstGenerator(RubyBinder/*!*/ binder, RubyCompilerOptions/*!*/ options, SourceUnit/*!*/ sourceUnit, RubyEncoding/*!*/ encoding,
            bool debugCompiler, bool debugMode, bool traceEnabled, bool profilerEnabled, bool savingToDisk) {

            Assert.NotNull(binder, options, encoding);
            _binder = binder;
            _compilerOptions = options;
            _debugCompiler = debugCompiler;
            _debugMode = debugMode;
            _traceEnabled = traceEnabled;
            _sourceUnit = sourceUnit;
            _document = sourceUnit.Document;
            _encoding = encoding;
            _profiler = profilerEnabled ? Profiler.Instance : null;
            _savingToDisk = savingToDisk;
        }
Esempio n. 3
0
        protected override object BindPrecompiled(Type /*!*/ delegateType, object[] /*!*/ args)
        {
            if (Context == null ||
                Signature.ResolveOnly ||
                (Signature.Flags & ~(RubyCallFlags.HasImplicitSelf | RubyCallFlags.HasScope | RubyCallFlags.HasBlock | RubyCallFlags.HasRhsArgument)) != 0)
            {
                return(null);
            }

            RubyScope scope;
            object    target;

            if (Signature.HasScope)
            {
                scope  = (RubyScope)args[0];
                target = args[1];
            }
            else
            {
                scope  = Context.EmptyScope;
                target = args[0];
            }

            int version;
            MethodResolutionResult method;
            RubyClass targetClass = Context.GetImmediateClassOf(target);

            using (targetClass.Context.ClassHierarchyLocker()) {
                version = targetClass.Version.Method;
                method  = targetClass.ResolveMethodForSiteNoLock(_methodName, GetVisibilityContext(Signature, scope));
            }

            if (!method.Found || method.Info.IsProtected && !Signature.HasImplicitSelf)
            {
                return(null);
            }

            var dispatcher = method.Info.GetDispatcher(delegateType, Signature, target, version);

            if (dispatcher != null)
            {
                object result = dispatcher.CreateDelegate(MethodDispatcher.UntypedFuncs.Contains(delegateType));
                RubyBinder.DumpPrecompiledRule(this, dispatcher);
                return(result);
            }

            return(null);
        }