• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CodeContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CodeContext的典型用法代码示例。如果您正苦于以下问题:C# CodeContext类的具体用法?C# CodeContext怎么用?C# CodeContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CodeContext类属于命名空间,在下文中一共展示了CodeContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: TryLookup

		public object TryLookup(
			CodeContext mode, ImmutableLegacyPrefixList legacyPrefixes, Xex xex, byte opcode,
			out bool hasModRM, out int immediateSizeInBytes)
		{
			hasModRM = false;
			immediateSizeInBytes = 0;

			NasmInsnsEntry match = null;
			foreach (var entry in entries)
			{
				bool entryHasModRM;
				int entryImmediateSize;
				if (entry.Match(mode.GetDefaultAddressSize(), legacyPrefixes, xex, opcode, out entryHasModRM, out entryImmediateSize))
				{
					if (match != null)
					{
						// If we match multiple, we should have the same response for each
						if (entryHasModRM != hasModRM) return false;
						if (entryImmediateSize != immediateSizeInBytes) return false;
					}

					hasModRM = entryHasModRM;
					immediateSizeInBytes = entryImmediateSize;
					match = entry;
				}
			}

			return match;
		}
开发者ID:MrTrillian,项目名称:Asmuth,代码行数:29,代码来源:NasmInstructionDecoderLookup.cs


示例17: oct

        public static string oct(CodeContext context, object number) {
            if (number is int) {
                number = BigInteger.Create((int)number);
            } 
            if (number is BigInteger) {
                BigInteger x = (BigInteger)number;
                if (x == 0) {
                    return "0o0";
                } else if (x > 0) {
                    return "0o" + BigInteger.Create(x).ToString(8);
                } else {
                    return "-0o" + BigInteger.Create(-x).ToString(8);
                }
            }

            object value;
            if (PythonTypeOps.TryInvokeUnaryOperator(context,
                number,
                Symbols.Index,
                out value)) {
                if (!(value is int) && !(value is BigInteger))
                    throw PythonOps.TypeError("index returned non-(int, long), got '{0}'", PythonTypeOps.GetName(value));

                return oct(context, value);
            }
            throw PythonOps.TypeError("oct() argument cannot be interpreted as an index");
        }
开发者ID:xerxesb,项目名称:ironruby,代码行数:27,代码来源:FutureBuiltins.cs


示例18: PythonFunction

        /// <summary>
        /// Python ctor - maps to function.__new__
        /// 
        /// y = func(x.__code__, globals(), 'foo', None, (a, ))
        /// </summary>
        public PythonFunction(CodeContext context, FunctionCode code, PythonDictionary globals, string name, PythonTuple defaults, PythonTuple closure) {
            if (closure != null && closure.__len__() != 0) {
                throw new NotImplementedException("non empty closure argument is not supported");
            }

            if (globals == context.GlobalDict) {
                _module = context.Module.GetName();
                _context = context;
            } else {
                _module = null;
                _context = new CodeContext(new PythonDictionary(), new ModuleContext(globals, DefaultContext.DefaultPythonContext));
            }

            _defaults = defaults == null ? ArrayUtils.EmptyObjects : defaults.ToArray();
            _code = code;
            _name = name;
            _doc = code._initialDoc;
            Closure = null;

            var scopeStatement = _code.PythonCode;
            if (scopeStatement.IsClosure) {
                throw new NotImplementedException("code containing closures is not supported");
            }
            scopeStatement.RewriteBody(FunctionDefinition.ArbitraryGlobalsVisitorInstance);

            _compat = CalculatedCachedCompat();
        }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:32,代码来源:PythonFunction.cs


示例19: StructType

            public StructType(CodeContext/*!*/ context, string name, PythonTuple bases, IAttributesCollection members)
                : base(context, name, bases, members) {

                foreach (PythonType pt in ResolutionOrder) {
                    StructType st = pt as StructType;
                    if (st != this && st != null) {
                        st.EnsureFinal();
                    }

                    UnionType ut = pt as UnionType;
                    if (ut != null) {
                        ut.EnsureFinal();
                    }
                }

                object pack;
                if (members.TryGetValue(SymbolTable.StringToId("_pack_"), out pack)) {
                    if (!(pack is int) || ((int)pack < 0)) {
                        throw PythonOps.ValueError("pack must be a non-negative integer");
                    }
                    _pack = (int)pack;
                }

                object fields;
                if (members.TryGetValue(SymbolTable.StringToId("_fields_"), out fields)) {
                    SetFields(fields);
                }

                // TODO: _anonymous_
            }
开发者ID:joshholmes,项目名称:ironruby,代码行数:30,代码来源:StructType.cs


示例20: PythonDynamicStackFrame

        public PythonDynamicStackFrame(CodeContext/*!*/ context, FunctionCode/*!*/ funcCode, MethodBase method, string funcName, string filename, int line)
            : base(method, funcName, filename, line) {
            Assert.NotNull(context, funcCode);

            _context = context;
            _code = funcCode;
        }
开发者ID:rudimk,项目名称:dlr-dotnet,代码行数:7,代码来源:PythonDynamicStackFrame.cs



注:本文中的CodeContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CodeDomProvider类代码示例发布时间:2022-05-24
下一篇:
C# CodeCompileUnit类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap