Exemplo n.º 1
0
Arquivo: ResEnv.cs Projeto: kzyg/spark
        public override IResTerm Lookup(SourceRange range, Identifier name)
        {
            var memberNameGroupSpecs = _pipeline.LookupMembers(range, name).Reverse().ToArray();

            if (memberNameGroupSpecs.Length == 0)
            {
                return(null);
            }

            IResTerm result = null;

            foreach (var mngs in memberNameGroupSpecs)
            {
                var memberCategorySpecs = mngs.Categories.ToArray();

                IResTerm term = null;

                switch (memberCategorySpecs.Length)
                {
                case 0:
                    break;

                case 1:
                    var thisRef = new ResVarRef(range, _thisParameter);
                    term = memberCategorySpecs[0].Bind(range, thisRef);
                    break;

                default:
                    term = new ResOverloadedTerm(
                        range,
                        from mcs in memberCategorySpecs
                        let tr = new ResVarRef(range, _thisParameter)
                                 select mcs.Bind(range, tr));
                    break;
                }

                if (term != null)
                {
                    var oldResult = result;
                    result = new ResLayeredTerm(
                        term.Range,
                        term,
                        () => oldResult);
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 private MidExp EmitExpImpl(ResVarRef resVarRef, MidEmitEnv env)
 {
     return(env.Lookup(resVarRef.Range, resVarRef.Decl));
 }