internal FunctionCode(PythonFunction f, FunctionInfo funcInfo) { _func = f; _filename = funcInfo.Path; object fn; if (_filename == null && f.Context.GlobalScope.Dict.TryGetValue(Symbols.File, out fn) && fn is string) { _filename = (string)fn; } _lineNo = funcInfo.LineNumber; _flags = funcInfo.Flags; _lambda = funcInfo.Code; _shouldInterpret = funcInfo.ShouldInterpret; _emitDebugSymbols = funcInfo.EmitDebugSymbols; }
internal PythonFunction(CodeContext/*!*/ context, Delegate target, FunctionInfo funcInfo, object modName, object[] defaults, Tuple closure) { Assert.NotNull(context, funcInfo); Assert.NotNull(context.Scope); _funcInfo = funcInfo; _context = context; _defaults = defaults ?? ArrayUtils.EmptyObjects; Target = target; Debug.Assert(_defaults.Length <= _funcInfo.ParameterCount); if (modName != Uninitialized.Instance) { _module = modName; } Closure = closure; _compat = CalculatedCachedCompat(); _code = new FunctionCode(this, funcInfo); }
public bool DeleteMember(CodeContext context, string name) { switch (name) { case "func_dict": case "__dict__": throw PythonOps.TypeError("function's dictionary may not be deleted"); case "__doc__": case "func_doc": _funcInfo = _funcInfo.SetDoc(null); return true; case "func_defaults": _defaults = ArrayUtils.EmptyObjects; _compat = CalculatedCachedCompat(); return true; } if (_dict == null) return false; return _dict.Remove(SymbolTable.StringToId(name)); }