コード例 #1
0
        private PythonClassType CreateClass(ClassDefinition cd)
        {
            var cls = new PythonClassType(cd, _eval.GetLocationOfName(cd),
                                          _eval.SuppressBuiltinLookup ? BuiltinTypeId.Unknown : BuiltinTypeId.Type);

            _typeMap[cd] = cls;
            return(cls);
        }
コード例 #2
0
        private PythonClassType CreateClass(ClassDefinition cd)
        {
            PythonType declaringType = null;

            if (!(cd.Parent is PythonAst))
            {
                Debug.Assert(_typeMap.ContainsKey(cd.Parent));
                _typeMap.TryGetValue(cd.Parent, out declaringType);
            }
            var cls = new PythonClassType(cd, declaringType, _eval.GetLocationOfName(cd),
                                          _eval.SuppressBuiltinLookup ? BuiltinTypeId.Unknown : BuiltinTypeId.Type);

            _typeMap[cd] = cls;

            declaringType?.AddMember(cls.Name, cls, overwrite: true);
            return(cls);
        }
コード例 #3
0
        private PythonClassType CreateClass(ClassDefinition cd)
        {
            PythonType declaringType = null;

            if (!(cd.Parent is PythonAst))
            {
                if (!_typeMap.TryGetValue(cd.Parent, out declaringType))
                {
                    // we can get into this situation if parent is defined twice and we preserve
                    // only one of them.
                    // for example, code has function definition with exact same signature
                    // and class is defined under one of that function
                    return(null);
                }
            }
            var cls = new PythonClassType(cd, declaringType, _eval.GetLocationOfName(cd),
                                          _eval.SuppressBuiltinLookup ? BuiltinTypeId.Unknown : BuiltinTypeId.Type);

            _typeMap[cd] = cls;

            declaringType?.AddMember(cls.Name, cls, overwrite: true);
            return(cls);
        }