當前位置: 首頁>>代碼示例>>C#>>正文


C# CodeContext類代碼示例

本文整理匯總了C#中CodeContext的典型用法代碼示例。如果您正苦於以下問題:C# CodeContext類的具體用法?C# CodeContext怎麽用?C# CodeContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CodeContext類屬於命名空間,在下文中一共展示了CodeContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Build

 public override object Build(CodeContext context, object[] args) {
     SymbolDictionary res = new SymbolDictionary();
     for (int i = _argIndex; i < _argIndex + _names.Length; i++) {
         res.Add(_names[i - _argIndex], args[i]);
     }
     return res;
 }
開發者ID:JamesTryand,項目名稱:IronScheme,代碼行數:7,代碼來源:ParamsDictArgBuilder.cs

示例2: RuntimeScriptCode

        public RuntimeScriptCode(PythonAst/*!*/ ast, CodeContext/*!*/ codeContext)
            : base(ast) {
            Debug.Assert(codeContext.GlobalScope.GetExtension(codeContext.LanguageContext.ContextId) != null);
            Debug.Assert(ast.Type == typeof(MSAst.Expression<Func<FunctionCode, object>>));

            _optimizedContext = codeContext;
        }
開發者ID:jschementi,項目名稱:iron,代碼行數:7,代碼來源:RuntimeScriptCode.cs

示例3: PythonDynamicStackFrame

        public PythonDynamicStackFrame(CodeContext/*!*/ context, FunctionCode/*!*/ funcCode, int line)
            : base(GetMethod(context, funcCode), funcCode.co_name, funcCode.co_filename, line) {
            Assert.NotNull(context, funcCode);

            _context = context;
            _code = funcCode;
        }
開發者ID:CookieEaters,項目名稱:FireHTTP,代碼行數:7,代碼來源:PythonDynamicStackFrame.cs

示例4: field_size_limit

 public static int field_size_limit(CodeContext /*!*/ context, int new_limit)
 {
     PythonContext ctx = PythonContext.GetContext(context);
     int old_limit = (int)ctx.GetModuleState(_fieldSizeLimitKey);
     ctx.SetModuleState(_fieldSizeLimitKey, new_limit);
     return old_limit;
 }
開發者ID:robjperez,項目名稱:main,代碼行數:7,代碼來源:_csv.cs

示例5: Import

        /// <summary>
        /// Gateway into importing ... called from Ops.  Performs the initial import of
        /// a module and returns the module.
        /// </summary>
        public static object Import(CodeContext/*!*/ context, string fullName, PythonTuple from, int level) {
            PythonContext pc = PythonContext.GetContext(context);

            if (level == -1) {
                // no specific level provided, call the 4 param version so legacy code continues to work
                return pc.OldImportSite.Target(
                    pc.OldImportSite,
                    context,
                    FindImportFunction(context),
                    fullName,
                    Builtin.globals(context),
                    context.Dict,
                    from
                );
            }

            // relative import or absolute import, in other words:
            //
            // from . import xyz
            // or 
            // from __future__ import absolute_import

            return pc.ImportSite.Target(
                pc.ImportSite,
                context,
                FindImportFunction(context),
                fullName,
                Builtin.globals(context),
                context.Dict,
                from,
                level
            );
        }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:37,代碼來源:Importer.cs

示例6: proxy

 public static object proxy(CodeContext context, object @object, object callback) {
     if (PythonOps.IsCallable(context, @object)) {
         return weakcallableproxy.MakeNew(context, @object, callback);
     } else {
         return weakproxy.MakeNew(context, @object, callback);
     }
 }
開發者ID:jcteague,項目名稱:ironruby,代碼行數:7,代碼來源:_weakref.cs

示例7: load_module

        public static object load_module(CodeContext/*!*/ context, string name, PythonFile file, string filename, PythonTuple/*!*/ description) {
            if (description == null) {
                throw PythonOps.TypeError("load_module() argument 4 must be 3-item sequence, not None");
            }
            if (description.__len__() != 3) {
                throw PythonOps.TypeError("load_module() argument 4 must be sequence of length 3, not {0}", description.__len__());
            }

            PythonContext pythonContext = PythonContext.GetContext(context);

            // already loaded? do reload()
            PythonModule module = pythonContext.GetModuleByName(name);
            if (module != null) {
                Importer.ReloadModule(context, module.Scope);
                return module.Scope;
            }

            int type = PythonContext.GetContext(context).ConvertToInt32(description[2]);
            switch (type) {
                case PythonSource:
                    return LoadPythonSource(pythonContext, name, file, filename);
                case CBuiltin:
                    return LoadBuiltinModule(context, name);
                case PackageDirectory:
                    return LoadPackageDirectory(pythonContext, name, filename);
                default:
                    throw PythonOps.TypeError("don't know how to import {0}, (type code {1}", name, type);
            }
        }
開發者ID:jcteague,項目名稱:ironruby,代碼行數:29,代碼來源:imp.cs

示例8: CreatePipe

        public static PythonTuple CreatePipe(
            CodeContext context,
            object pSec /*Python passes None*/,
            int bufferSize) {
            IntPtr hReadPipe;
            IntPtr hWritePipe;
            
            SECURITY_ATTRIBUTES pSecA = new SECURITY_ATTRIBUTES();
            pSecA.nLength = Marshal.SizeOf(pSecA);
            if (pSec != null) {
                /* If pSec paseed in from Python is not NULL 
                 * there needs to be some conversion done here...*/
            }

            // TODO: handle failures
            CreatePipePI(
                out hReadPipe,
                out hWritePipe,
                ref pSecA,
                (uint)bufferSize);
            
            return PythonTuple.MakeTuple(
                new PythonSubprocessHandle(hReadPipe),
                new PythonSubprocessHandle(hWritePipe)
            );
        }
開發者ID:jschementi,項目名稱:iron,代碼行數:26,代碼來源:_subprocess.cs

示例9: Call

 public static object Call(CodeContext/*!*/ context, TypeGroup/*!*/ self, params object[] args) {
     return PythonCalls.Call(
         context,
         DynamicHelpers.GetPythonTypeFromType(self.NonGenericType),
         args ?? ArrayUtils.EmptyObjects
     );
 }
開發者ID:tnachen,項目名稱:ironruby,代碼行數:7,代碼來源:TypeGroupOps.cs

示例10: StringFormatter

 public StringFormatter(CodeContext/*!*/ context, string str, object data, bool isUnicode)
 {
     _str = str;
     _data = data;
     _context = context;
     _isUnicodeString = isUnicode;
 }
開發者ID:TerabyteX,項目名稱:main,代碼行數:7,代碼來源:StringFormatter.cs

示例11: _FileIO

            public _FileIO(CodeContext/*!*/ context, int fd, [DefaultParameterValue("r")]string mode, [DefaultParameterValue(true)]bool closefd) {
                if (fd < 0) {
                    throw PythonOps.ValueError("fd must be >= 0");
                }

                PythonContext pc = PythonContext.GetContext(context);
                _FileIO file = (_FileIO)pc.FileManager.GetObjectFromId(pc, fd);
                Console.WriteLine(file);

                _context = pc;
                switch (mode) {
                    case "r": _mode = "rb"; break;
                    case "w": _mode = "wb"; break;
                    case "a": _mode = "w"; break;
                    case "r+":
                    case "+r": _mode = "rb+"; break;
                    case "w+":
                    case "+w": _mode = "rb+"; break;
                    case "a+":
                    case "+a": _mode = "r+"; break;
                    default:
                        BadMode(mode);
                        break;
                }
                _readStream = file._readStream;
                _writeStream = file._writeStream;
                _closefd = closefd;
            }
開發者ID:andreakn,項目名稱:ironruby,代碼行數:28,代碼來源:_fileio.cs

示例12: LuaScriptCode

 public LuaScriptCode(CodeContext context, SourceUnit sourceUnit, Expression<Func<IDynamicMetaObjectProvider, dynamic>> chunk)
     : base(sourceUnit)
 {
     Contract.Requires(chunk != null);
     Context = context;
     _exprLambda = chunk;
 }
開發者ID:SPARTAN563,項目名稱:IronLua,代碼行數:7,代碼來源:LuaScriptCode.cs

示例13: PrintExpressionValue

 /// <summary>
 /// Called from generated code when we are supposed to print an expression value
 /// </summary>
 public static void PrintExpressionValue(CodeContext/*!*/ context, object value)
 {
     Console.WriteLine(value);
     //PythonContext pc = PythonContext.GetContext(context);
     //object dispHook = pc.GetSystemStateValue("displayhook");
     //pc.CallWithContext(context, dispHook, value);
 }
開發者ID:Alxandr,項目名稱:IronTotem-3.0,代碼行數:10,代碼來源:TotemOps.cs

示例14: __init__

            public void __init__(CodeContext context,
                string filename,
                [DefaultParameterValue("r")]string mode,
                [DefaultParameterValue(0)]int buffering,
                [DefaultParameterValue(DEFAULT_COMPRESSLEVEL)]int compresslevel) {

                var pythonContext = PythonContext.GetContext(context);

                this.buffering = buffering;
                this.compresslevel = compresslevel;

                if (!mode.Contains("b") && !mode.Contains("U")) {
                    // bz2 files are always written in binary mode, unless they are in univeral newline mode
                    mode = mode + 'b';
                }

                if (mode.Contains("w")) {
                    var underlyingStream = File.Open(filename, FileMode.Create, FileAccess.Write);

                    if (mode.Contains("p")) {
                        this.bz2Stream = new ParallelBZip2OutputStream(underlyingStream);
                    } else {
                        this.bz2Stream = new BZip2OutputStream(underlyingStream);
                    }
                } else {
                    this.bz2Stream = new BZip2InputStream(File.OpenRead(filename));
                }

                this.__init__(bz2Stream, pythonContext.DefaultEncoding, filename, mode);
            }
開發者ID:TerabyteX,項目名稱:ironpython3,代碼行數:30,代碼來源:BZ2File.cs

示例15: Error

 private static Exception Error(CodeContext/*!*/ context, int errno, string/*!*/ message) {
     return PythonExceptions.CreateThrowable(
         (PythonType)PythonContext.GetContext(context).GetModuleState(_mmapErrorKey),
         errno,
         message
     );
 }
開發者ID:jdhardy,項目名稱:ironpython,代碼行數:7,代碼來源:mmap.cs


注:本文中的CodeContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。