本文整理汇总了C#中Microsoft.Scripting.CodeContext类的典型用法代码示例。如果您正苦于以下问题:C# CodeContext类的具体用法?C# CodeContext怎么用?C# CodeContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeContext类属于Microsoft.Scripting命名空间,在下文中一共展示了CodeContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
);
}
示例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");
}
示例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;
}
示例4: TraceBackFrame
internal TraceBackFrame(CodeContext context, TotemDictionary globals, object locals, FunctionCode code)
{
_globals = globals;
_locals = locals;
_code = code;
_context = context;
}
示例5: PythonTypeChangedEventArgs
public PythonTypeChangedEventArgs(CodeContext context, SymbolId changed, ChangeType type, object previous, object newValue) {
_context = context;
_changed = changed;
_type = type;
_previous = previous;
_newValue = newValue;
}
示例6: InvariantContext
static InvariantContext()
{
Instance = new InvariantContext();
ModuleContext moduleContext = new ModuleContext(null);
moduleContext.ShowCls = true;
CodeContext = new CodeContext(new Scope(null), Instance, moduleContext);
}
示例7: DynamicStackFrame
public DynamicStackFrame(CodeContext context, MethodBase method, string funcName, string filename, int line) {
_context = context;
_funcName = funcName;
_filename = filename;
_lineNo = line;
_method = method;
}
示例8: CheckCodeContext
protected static object CheckCodeContext(CodeContext cc)
{
if (cc != null && cc.Scope.Parent.Parent == null)
{
return null;
}
return cc;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
}
}
示例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);
}
示例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;
}
示例15: __repr__
public string/*!*/ __repr__(CodeContext/*!*/ context) {
return string.Format("<property# {0} on {1}>",
__name__,
DynamicHelpers.GetPythonTypeFromType(DeclaringType).Name);
}