当前位置: 首页>>代码示例>>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;未经允许,请勿转载。