本文整理汇总了C#中IronPython.Compiler.Ast.PythonVariable类的典型用法代码示例。如果您正苦于以下问题:C# PythonVariable类的具体用法?C# PythonVariable怎么用?C# PythonVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PythonVariable类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了PythonVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClosureExpression
public ClosureExpression(Ast.PythonVariable/*!*/ variable, Expression/*!*/ closureCell, ParameterExpression parameter) {
Assert.NotNull(closureCell);
_variable = variable;
_closureCell = closureCell;
_parameter = parameter;
}
示例2: PythonGlobalVariableExpression
public PythonGlobalVariableExpression(Expression/*!*/ globalExpr, Ast.PythonVariable/*!*/ variable, PythonGlobal/*!*/ global) {
Assert.NotNull(globalExpr, variable);
_target = globalExpr;
_global = global;
_variable = variable;
}
示例3: GetGlobal
public override MSAst.Expression GetGlobal(MSAst.Expression globalContext, int arrayIndex, PythonVariable variable, PythonGlobal global) {
return new LookupGlobalVariable(
globalContext,
variable.Name,
variable.Kind == VariableKind.Local
);
}
示例4: PythonGlobalVariableExpression
internal PythonGlobalVariableExpression(Expression/*!*/ globalExpr, Ast.PythonVariable/*!*/ variable, PythonGlobal/*!*/ global, bool lightEh) {
Assert.NotNull(globalExpr, variable);
_target = globalExpr;
_global = global;
_variable = variable;
_lightEh = lightEh;
}
示例5: GetGlobal
public override MSAst.Expression GetGlobal(MSAst.Expression globalContext, int arrayIndex, PythonVariable variable, PythonGlobal global) {
Assert.NotNull(global);
return new PythonGlobalVariableExpression(
Ast.ArrayIndex(
PythonAst._globalArray,
Ast.Constant(arrayIndex)
),
variable,
global
);
}
示例6: LiftedParameter
internal ClosureExpression/*!*/ LiftedParameter(PythonVariable variable, string name) {
ParameterExpression result = Ast.Variable(typeof(object), name);
_params.Add(result);
ClosureExpression closureVar = new ClosureExpression(variable, HiddenVariable(typeof(ClosureCell), name), result);
EnsureLiftedVars();
_liftedVars.Add(new DefinitionClosureInfo(closureVar, true));
return closureVar;
}
示例7: LiftedVariable
internal ClosureExpression/*!*/ LiftedVariable(PythonVariable/*!*/ variable, string/*!*/ name, bool accessInNestedScope) {
ParameterExpression result = HiddenVariable(typeof(ClosureCell), name);
ClosureExpression closureVar = new ClosureExpression(variable, result, null);
EnsureLiftedVars();
_liftedVars.Add(new DefinitionClosureInfo(closureVar, true));
return closureVar;
}
示例8: GetGlobal
public abstract MSAst.Expression GetGlobal(MSAst.Expression globalContext, int arrayIndex, PythonVariable variable, PythonGlobal global);
示例9: Walk
// ImportStatement
public override bool Walk(ImportStatement node)
{
node.Parent = _currentScope;
PythonVariable[] variables = new PythonVariable[node.Names.Count];
for (int i = 0; i < node.Names.Count; i++) {
string name = node.AsNames[i] != null ? node.AsNames[i] : node.Names[i].Names[0];
variables[i] = DefineName(name);
node.Names[i].Parent = _currentScope;
}
node.Variables = variables;
return true;
}
示例10: SetAssigned
private void SetAssigned(PythonVariable/*!*/ variable, bool value) {
_bits.Set(variable.Index * 2, value);
}
示例11: TupleIndex
public int TupleIndex(PythonVariable var) {
Debug.Assert(_parent._liftedVars != null);
var vars = _parent._liftedVars;
for (int i = 0; i < vars.Count; i++) {
if (vars[i].PythonVariable == var) {
return i;
}
}
throw new InvalidOperationException();
}
示例12: SetParameter
public void SetParameter(PythonVariable/*!*/ variable, MSAst.Expression/*!*/ parameter) {
Assert.NotNull(variable, parameter);
_variables[variable] = parameter;
}
示例13: CreateVariable
public MSAst.Expression/*!*/ CreateVariable(AstGenerator/*!*/ ag, PythonVariable/*!*/ variable, bool emitDictionary) {
Assert.NotNull(ag, variable);
Debug.Assert(variable.Kind != VariableKind.Parameter);
string name = SymbolTable.IdToString(variable.Name);
switch (variable.Kind) {
case VariableKind.Global:
case VariableKind.GlobalLocal:
return _variables[variable] = GetGlobal(name, ag, false);
case VariableKind.Local:
case VariableKind.HiddenLocal:
if (ag.IsGlobal) {
return _variables[variable] = GetGlobal(name, ag, true);
} else if (variable.AccessedInNestedScope || (emitDictionary && variable.Kind != VariableKind.HiddenLocal)) {
return ag.SetLocalLiftedVariable(variable, ag.LiftedVariable(variable, name, variable.AccessedInNestedScope));
} else {
return _variables[variable] = ag.Variable(typeof(object), name);
}
default:
throw Assert.Unreachable;
}
}
示例14: TryBindOuter
internal override bool TryBindOuter(SymbolId name, out PythonVariable variable) {
// Functions expose their locals to direct access
ContainsNestedFreeVariables = true;
return TryGetVariable(name, out variable);
}
示例15: IsInitialized
private bool IsInitialized(PythonVariable/*!*/ variable) {
return _bits.Get(variable.Index * 2 + 1);
}