Example #1
0
        internal override Evaluation Analyze(Analyzer /*!*/ analyzer, ExInfoFromParent info)
        {
            Debug.Assert(this.IsMemberOf == null);

            access = info.Access;

            this.typeArgsResolved = classNameRef.Analyze(analyzer);

            DType            type = classNameRef.ResolvedType;
            RoutineSignature signature;

            if (typeArgsResolved)
            {
                analyzer.AnalyzeConstructedType(type);
            }

            if (type != null)
            {
                bool error_reported = false;

                // make checks if we are sure about character of the type:
                if (type.IsIdentityDefinite)
                {
                    if (type.IsAbstract || type.IsInterface)
                    {
                        analyzer.ErrorSink.Add(Errors.AbstractClassOrInterfaceInstantiated, analyzer.SourceUnit,
                                               position, type.FullName);
                        error_reported = true;
                    }
                }

                // disallow instantiation of Closure
                if (type.RealType == typeof(PHP.Library.SPL.Closure))
                {
                    analyzer.ErrorSink.Add(Errors.ClosureInstantiated, analyzer.SourceUnit, position, type.FullName);
                    error_reported = true;
                }

                // type name resolved, look the constructor up:
                constructor = analyzer.ResolveConstructor(type, position, analyzer.CurrentType, analyzer.CurrentRoutine,
                                                          out runtimeVisibilityCheck);

                if (constructor.ResolveOverload(analyzer, callSignature, position, out signature) == DRoutine.InvalidOverloadIndex)
                {
                    if (!error_reported)
                    {
                        analyzer.ErrorSink.Add(Errors.ClassHasNoVisibleCtor, analyzer.SourceUnit,
                                               position, type.FullName);
                    }
                }
            }
            else
            {
                signature = UnknownSignature.Default;
            }

            callSignature.Analyze(analyzer, signature, info, false);

            return(new Evaluation(this));
        }
Example #2
0
        internal override Evaluation Analyze(Analyzer /*!*/ analyzer, ExInfoFromParent info)
        {
            access = info.Access;

            typeArgsResolved = classNameRef.Analyze(analyzer);

            if (typeArgsResolved)
            {
                analyzer.AnalyzeConstructedType(classNameRef.ResolvedType);
            }

            return(new Evaluation(this));
        }