本文整理汇总了C#中Microsoft.Scripting.CodeContext类的典型用法代码示例。如果您正苦于以下问题:C# CodeContext类的具体用法?C# CodeContext怎么用?C# CodeContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeContext类属于Microsoft.Scripting命名空间,在下文中一共展示了CodeContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Call
public static object Call(CodeContext/*!*/ context, TypeGroup/*!*/ self, params object[] args) {
return PythonCalls.Call(
context,
DynamicHelpers.GetPythonTypeFromType(self.NonGenericType),
args ?? ArrayUtils.EmptyObjects
);
}
开发者ID:nieve,项目名称:ironruby,代码行数:7,代码来源:TypeGroupOps.cs
示例2: GetValue
/// <summary>
/// Convenience function for users to call directly
/// </summary>
public object GetValue(CodeContext context, object instance) {
object value;
if (TryGetValue(context, instance, DynamicHelpers.GetPythonType(instance), out value)) {
return value;
}
throw new InvalidOperationException("cannot get field");
}
开发者ID:techarch,项目名称:ironruby,代码行数:10,代码来源:ReflectedField.cs
示例3: CreateCodeContext
public static CodeContext CreateCodeContext(Type[] extensionTypes)
{
DefaultLanguageContext dlc = new DefaultLanguageContext();
CodeContext cc = new CodeContext(new Scope(), dlc, new ModuleContext(null));
dlc._binder = new DefaultActionBinder(cc, extensionTypes);
return cc;
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:DefaultLanguageContext.cs
示例4: TraceBackFrame
internal TraceBackFrame(CodeContext context, TotemDictionary globals, object locals, FunctionCode code)
{
_globals = globals;
_locals = locals;
_code = code;
_context = context;
}
开发者ID:Alxandr,项目名称:IronTotem-3.0,代码行数:7,代码来源:TraceBack.cs
示例5: PythonTypeChangedEventArgs
public PythonTypeChangedEventArgs(CodeContext context, SymbolId changed, ChangeType type, object previous, object newValue) {
_context = context;
_changed = changed;
_type = type;
_previous = previous;
_newValue = newValue;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:PythonTypeChangedEventArgs.cs
示例6: InvariantContext
static InvariantContext()
{
Instance = new InvariantContext();
ModuleContext moduleContext = new ModuleContext(null);
moduleContext.ShowCls = true;
CodeContext = new CodeContext(new Scope(null), Instance, moduleContext);
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:InvariantContext.cs
示例7: DynamicStackFrame
public DynamicStackFrame(CodeContext context, MethodBase method, string funcName, string filename, int line) {
_context = context;
_funcName = funcName;
_filename = filename;
_lineNo = line;
_method = method;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:DynamicStackFrame.cs
示例8: CheckCodeContext
protected static object CheckCodeContext(CodeContext cc)
{
if (cc != null && cc.Scope.Parent.Parent == null)
{
return null;
}
return cc;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:8,代码来源:Closure.cs
示例9: TryGetValue
internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) {
if (instance != null || owner == TypeCache.Null) {
CheckSelf(context, instance);
value = UncheckedGetAttribute(instance);
return true;
}
value = this;
return true;
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:9,代码来源:BuiltinMethodDescriptor.cs
示例10: Build
public override object Build(CodeContext context, object[] args, object[] parameters, object ret)
{
if (_returnArgs.Count == 1) {
return GetValue(args, ret, _returnArgs[0]);
} else {
object[] retValues = new object[_returnArgs.Count];
int rIndex = 0;
foreach (int index in _returnArgs) {
retValues[rIndex++] = GetValue(args, ret, index);
}
return _binder.GetByRefArray(retValues);
}
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:13,代码来源:ByRefReturnBuilder.cs
示例11: Initialize
internal static void Initialize(IronSchemeLanguageProvider ironSchemeLanguageProvider)
{
lp = ironSchemeLanguageProvider;
se = lp.GetEngine() as IronSchemeScriptEngine;
scriptmodule = ScriptDomainManager.CurrentManager.Host.DefaultModule as ScriptModule;
ModuleContext mc = new ModuleContext(scriptmodule);
mc.CompilerContext = new CompilerContext(SourceUnit.CreateSnippet(se, ""));
cc = new CodeContext(scriptmodule.Scope, se.GetLanguageContext(), mc);
binder = new IronScheme.Actions.IronSchemeActionBinder(cc);
Generator.initme = true;
}
开发者ID:kkirstein,项目名称:IronScheme,代码行数:17,代码来源:Generator.Helpers.cs
示例12: AddGenerators
public static void AddGenerators(CodeContext cc, Assembly assembly)
{
foreach (Type t in assembly.GetExportedTypes())
{
if (Attribute.IsDefined(t, typeof(GeneratorAttribute)))
{
IGenerator g = Activator.CreateInstance(t) as IGenerator;
foreach (GeneratorAttribute ga in t.GetCustomAttributes(typeof(GeneratorAttribute), false))
{
string name = ga.Name;
object s = SymbolTable.StringToObject(name);
cc.Scope.SetName((SymbolId)s, g);
}
}
}
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:17,代码来源:Generator.Handlers.cs
示例13: TrySetValue
internal override bool TrySetValue(CodeContext context, object instance, PythonType owner, object value) {
if (Setter.Length == 0) {
return false;
}
if (instance == null) {
foreach (MethodInfo mi in Setter) {
if(mi.IsStatic && DeclaringType != owner.UnderlyingSystemType) {
return false;
} else if (mi.IsProtected()) {
throw PythonOps.TypeErrorForProtectedMember(owner.UnderlyingSystemType, _info.Name);
}
}
} else if (instance != null) {
foreach (MethodInfo mi in Setter) {
if (mi.IsStatic) {
return false;
}
}
}
return CallSetter(context, PythonContext.GetContext(context).GetGenericCallSiteStorage(), instance, ArrayUtils.EmptyObjects, value);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:23,代码来源:ReflectedProperty.cs
示例14: TryGetValue
internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) {
PerfTrack.NoteEvent(PerfTrack.Categories.Properties, this);
value = CallGetter(context, owner, PythonContext.GetContext(context).GetGenericCallSiteStorage0(), instance);
return true;
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:6,代码来源:ReflectedProperty.cs
示例15: __repr__
public string/*!*/ __repr__(CodeContext/*!*/ context) {
return string.Format("<property# {0} on {1}>",
__name__,
DynamicHelpers.GetPythonTypeFromType(DeclaringType).Name);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:5,代码来源:ReflectedProperty.cs
示例16: __set__
public void __set__(CodeContext context, object instance, object value) {
// TODO: Throw? currently we have a test that verifies we never throw when this is called directly.
TrySetValue(context, instance, DynamicHelpers.GetPythonType(instance), value);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:4,代码来源:ReflectedProperty.cs
示例17: SetValue
public void SetValue(CodeContext context, object instance, object value) {
if (!TrySetValue(context, instance, DynamicHelpers.GetPythonType(instance), value)) {
throw new InvalidOperationException("cannot set property");
}
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:5,代码来源:ReflectedProperty.cs
示例18: DefaultActionBinder
public DefaultActionBinder(CodeContext context, Type[] extensionTypes)
: base(context)
{
this._extensionTypes = extensionTypes;
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:5,代码来源:DefaultLanguageContext.cs
示例19: GetCustomMemberNames
public IList<object> GetCustomMemberNames(CodeContext context) {
List<object> ret;
if (!context.ModuleContext.ShowCls) {
ret = new List<object>();
foreach (KeyValuePair<object, object> kvp in Scope.GetAllItems(context.LanguageContext)) {
if(kvp.Value != Uninitialized.Instance) {
if (kvp.Key is SymbolId) {
ret.Add(SymbolTable.IdToString((SymbolId)kvp.Key));
} else {
ret.Add(kvp.Key);
}
}
}
} else {
ret = new List<object>(Scope.GetAllKeys(context.LanguageContext));
}
return ret;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:19,代码来源:ScriptModule.cs
示例20: CallGetter
private object CallGetter(CodeContext context, PythonType owner, SiteLocalStorage<CallSite<Func<CallSite, CodeContext, object, object>>> storage, object instance) {
if (NeedToReturnProperty(instance, Getter)) {
return this;
}
if (Getter.Length == 0) {
throw new MissingMemberException("unreadable property");
}
if (owner == null) {
owner = DynamicHelpers.GetPythonType(instance);
}
// this matches the logic in the default binder when it does a property get. We
// need to duplicate it here to be consistent for all gets.
MethodInfo[] members = Getter;
Type type = owner.UnderlyingSystemType;
if (Getter.Length > 1) {
// if we were given multiple members pick the member closest to the type...
Type bestMemberDeclaringType = Getter[0].DeclaringType;
MethodInfo bestMember = Getter[0];
for (int i = 1; i < Getter.Length; i++) {
MethodInfo mt = Getter[i];
if (!IsApplicableForType(type, mt)) {
continue;
}
if (Getter[i].DeclaringType.IsSubclassOf(bestMemberDeclaringType) ||
!IsApplicableForType(type, bestMember)) {
bestMember = Getter[i];
bestMemberDeclaringType = Getter[i].DeclaringType;
}
}
members = new MethodInfo[] { bestMember };
}
BuiltinFunction target = PythonTypeOps.GetBuiltinFunction(type, __name__, members);
return target.Call0(context, storage, instance);
}
开发者ID:joshholmes,项目名称:ironruby,代码行数:42,代码来源:ReflectedProperty.cs
注:本文中的Microsoft.Scripting.CodeContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论