本文整理汇总了C#中IronPython.Compiler.Ast.Node类的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalysisUnit
private AnalysisUnit(Node ast, InterpreterScope[] scopes, AnalysisUnit parent, bool forEval)
{
_ast = ast;
_scopes = scopes;
_parent = parent;
_forEval = forEval;
}
示例2: Call
public override ISet<Namespace> Call(Node node, AnalysisUnit unit, ISet<Namespace>[] args, string[] keywordArgNames)
{
if (args.Length == 1) {
_list.AppendItem(args[0]);
}
return ProjectState._noneInst.SelfSet;
}
示例3: Call
public override ISet<Namespace> Call(Node node, AnalysisUnit unit, ISet<Namespace>[] args, string[] keywordArgNames)
{
if (args.Length == 1) {
_generator.AddSend(node, unit, args[0]);
}
return _generator.Yields;
}
示例4: GetMember
public override ISet<Namespace> GetMember(Node node, AnalysisUnit unit, string name)
{
var res = base.GetMember(node, unit, name);
if (res.Count > 0) {
_references.AddReference(node, unit, name);
}
return res;
}
示例5: Call
public override ISet<Namespace> Call(Node node, AnalysisUnit unit, ISet<Namespace>[] args, string[] keywordArgNames)
{
if (args.Length == 1) {
foreach (var type in args[0]) {
_list.AppendItem(type.GetEnumeratorTypes(node, unit));
}
}
return ProjectState._noneInst.SelfSet;
}
示例6: CreateVariable
public VariableDef CreateVariable(Node node, AnalysisUnit unit, string name, bool addRef = true)
{
var res = GetVariable(node, unit, name, addRef);
if (res == null) {
_variables[name] = res = new VariableDef();
if (addRef) {
res.AddReference(node, unit);
}
}
return res;
}
示例7: SetUpFixture
public void SetUpFixture()
{
componentCreator = new MockComponentCreator();
AssignmentStatement assignment = PythonParserHelper.GetAssignmentStatement(GetPythonCode());
rhsAssignmentNode = assignment.Right;
mockDesignerLoaderHost = new MockDesignerLoaderHost();
typeResolutionService = mockDesignerLoaderHost.TypeResolutionService;
PythonCodeDeserializer deserializer = new PythonCodeDeserializer(componentCreator);
deserializedObject = deserializer.Deserialize(rhsAssignmentNode);
}
示例8: GetIndex
public override ISet<Namespace> GetIndex(Node node, AnalysisUnit unit, ISet<Namespace> index)
{
// TODO: Return correct index value if we have a constant
/*int? constIndex = SequenceInfo.GetConstantIndex(index);
if (constIndex != null && constIndex.Value < _indexTypes.Count) {
// TODO: Warn if outside known index and no appends?
return _indexTypes[constIndex.Value];
}*/
return ProjectState._intType.SelfSet;
}
示例9: Call
/// <summary>
/// Performs a call operation propagating the argument types into any user defined functions
/// or classes and returns the set of types which result from the call.
/// </summary>
public static ISet<Namespace> Call(this ISet<Namespace> self, Node node, AnalysisUnit unit, ISet<Namespace>[] args, string[] keywordArgNames)
{
ISet<Namespace> res = EmptySet<Namespace>.Instance;
bool madeSet = false;
foreach (var ns in self) {
var call = ns.Call(node, unit, args, keywordArgNames);
Debug.Assert(call != null);
res = res.Union(call, ref madeSet);
}
return res;
}
示例10: BinaryOperation
public override ISet<Namespace> BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, ISet<Namespace> rhs)
{
switch (operation) {
case PythonOperator.GreaterThan:
case PythonOperator.LessThan:
case PythonOperator.LessThanOrEqual:
case PythonOperator.GreaterThanOrEqual:
case PythonOperator.Equal:
case PythonOperator.NotEqual:
case PythonOperator.Is:
case PythonOperator.IsNot:
return ProjectState._boolType.Instance;
}
return base.BinaryOperation(node, unit, operation, rhs);
}
示例11: BinaryOperation
public static ISet<Namespace> BinaryOperation(this ISet<Namespace> self, Node node, AnalysisUnit unit, PythonOperator operation, ISet<Namespace> rhs)
{
ISet<Namespace> res = null;
bool madeSet = false;
foreach (var ns in self) {
ISet<Namespace> got = ns.BinaryOperation(node, unit, operation, rhs);
if (res == null) {
res = got;
continue;
} else if (!madeSet) {
res = new HashSet<Namespace>(res);
madeSet = true;
}
res.UnionWith(got);
}
return res ?? EmptySet<Namespace>.Instance;
}
示例12: GetMember
public override ISet<Namespace> GetMember(Node node, AnalysisUnit unit, string name)
{
switch (name) {
case "append":
EnsureAppend();
return _appendMethod.SelfSet;
case "pop":
EnsurePop();
return _popMethod.SelfSet;
case "insert":
EnsureInsert();
return _insertMethod.SelfSet;
case "extend":
EnsureExtend();
return _extendMethod.SelfSet;
}
return base.GetMember(node, unit, name);
}
示例13: Deserialize
/// <summary>
/// Creates or gets the object specified in the python AST.
/// </summary>
/// <returns>
/// Null if the node cannot be deserialized.
/// </returns>
public object Deserialize(Node node)
{
if (node == null) {
throw new ArgumentNullException("node");
}
if (node is CallExpression) {
return Deserialize((CallExpression)node);
} else if (node is BinaryExpression) {
return Deserialize((BinaryExpression)node);
} else if (node is MemberExpression) {
return Deserialize((MemberExpression)node);
} else if (node is UnaryExpression) {
return Deserialize((UnaryExpression)node);
} else if (node is ConstantExpression) {
return Deserialize((ConstantExpression)node);
} else if (node is NameExpression) {
return Deserialize((NameExpression)node);
}
return null;
}
示例14: Locate
public bool Locate(int line, int column, out Node node, out Scope scope)
{
Locator locator = new Locator(line, column);
global.Walk(locator);
node = locator.Candidate;
scope = locator.Scope != null ? scopes[locator.Scope] : null;
#if DEBUG
if (node != null)
{
Debug.Print("Located {0} at {1}:{2}-{3}:{4}",
node,
node.Start.Line, node.Start.Column,
node.End.Line, node.End.Column
);
}
#endif
return node != null;
}
示例15: CommonWalk
private void CommonWalk(Node node)
{
tree.Push(node);
}