本文整理汇总了C#中Microsoft.PythonTools.Parsing.Ast.Node类的典型用法代码示例。如果您正苦于以下问题:C# Node类的具体用法?C# Node怎么用?C# Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于Microsoft.PythonTools.Parsing.Ast命名空间,在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BinaryOperation
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) {
var res = AnalysisSet.Empty;
foreach (var member in _members) {
res = res.Union(member.BinaryOperation(node, unit, operation, rhs));
}
return res;
}
示例2: BinaryOperation
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet 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.ClassInfos[BuiltinTypeId.Bool].Instance;
case PythonOperator.TrueDivide:
case PythonOperator.Add:
case PythonOperator.Subtract:
case PythonOperator.Multiply:
case PythonOperator.MatMultiply:
case PythonOperator.Divide:
case PythonOperator.Mod:
case PythonOperator.BitwiseAnd:
case PythonOperator.BitwiseOr:
case PythonOperator.Xor:
case PythonOperator.LeftShift:
case PythonOperator.RightShift:
case PythonOperator.Power:
case PythonOperator.FloorDivide:
return ConstantInfo.NumericOp(node, this, unit, operation, rhs) ?? CallReverseBinaryOp(node, unit, operation, rhs);
}
return CallReverseBinaryOp(node, unit, operation, rhs);
}
示例3: AddTypes
internal bool AddTypes(Node node, AnalysisUnit unit, IAnalysisSet key, IAnalysisSet value, bool enqueue = true) {
if (_keysAndValues.AddTypes(unit, key, value, enqueue)) {
if (_keysVariable != null) {
_keysVariable.MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictKeyTypes, value);
if (_keysVariable.AddTypes(unit, key, enqueue)) {
if (_keysIter != null) {
_keysIter.UnionType = null;
}
if (_keysList != null) {
_keysList.UnionType = null;
}
}
}
if (_valuesVariable != null) {
_valuesVariable.MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictValueTypes, value);
if (_valuesVariable.AddTypes(unit, value, enqueue)) {
if (_valuesIter != null) {
_valuesIter.UnionType = null;
}
if (_valuesList != null) {
_valuesList.UnionType = null;
}
}
}
if (_keyValueTuple != null) {
_keyValueTuple.IndexTypes[0].MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictKeyTypes, key);
_keyValueTuple.IndexTypes[1].MakeUnionStrongerIfMoreThan(ProjectState.Limits.DictValueTypes, value);
_keyValueTuple.IndexTypes[0].AddTypes(unit, key, enqueue);
_keyValueTuple.IndexTypes[1].AddTypes(unit, value, enqueue);
}
return true;
}
return false;
}
示例4: DictionaryInfo
public DictionaryInfo(ProjectEntry declaringModule, Node node)
: base(declaringModule.ProjectState.ClassInfos[BuiltinTypeId.Dict]) {
_keysAndValues = new DependentKeyValue();
_declaringModule = declaringModule;
_declVersion = declaringModule.AnalysisVersion;
_node = node;
}
示例5: GetMember
public override IAnalysisSet GetMember(Node node, AnalysisUnit unit, string name) {
// Must unconditionally call the base implementation of GetMember
var res = base.GetMember(node, unit, name);
switch(name) {
case "next":
if (unit.ProjectState.LanguageVersion.Is2x()) {
return _nextMethod = _nextMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
GeneratorNext,
false
);
}
break;
case "__next__":
if (unit.ProjectState.LanguageVersion.Is3x()) {
return _nextMethod = _nextMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
GeneratorNext,
false
);
}
break;
case "send":
return _sendMethod = _sendMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
GeneratorSend,
false
);
}
return res;
}
示例6: BinaryOperation
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, Parsing.PythonOperator operation, IAnalysisSet rhs) {
if (_original == null) {
return base.BinaryOperation(node, unit, operation, rhs);
}
return _original.BinaryOperation(node, unit, operation, rhs);
}
示例7: Call
public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
var res = AnalysisSet.Empty;
foreach (var member in _members) {
res = res.Union(member.Call(node, unit, args, keywordArgNames));
}
return res;
}
示例8: Call
public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
if (_original == null) {
return base.Call(node, unit, args, keywordArgNames);
}
return _original.Call(node, unit, args, keywordArgNames);
}
示例9: Call
public override ISet<Namespace> Call(Node node, AnalysisUnit unit, ISet<Namespace>[] args, NameExpression[] keywordArgNames) {
_generator.Callers.AddDependency(unit);
_generator.AddReturn(node, unit, base.Call(node, unit, args, keywordArgNames));
return _generator.SelfSet;
}
示例10: ShouldWalkWorker
private bool ShouldWalkWorker(Node node) {
if (node is ScopeStatement) {
_suites.Add(null); // marker for a function/class boundary
_parents.Add((ScopeStatement)node);
}
return _selectedSpan.IntersectsWith(Span.FromBounds(node.StartIndex, node.EndIndex));
}
示例11: DeleteMember
/// <summary>
/// Performs a delete index operation propagating the index types into
/// the provided object.
/// </summary>
public static void DeleteMember(this IAnalysisSet self, Node node, AnalysisUnit unit, string name) {
if (name != null && name.Length > 0) {
foreach (var ns in self) {
ns.DeleteMember(node, unit, name);
}
}
}
示例12: ListInsert
private IAnalysisSet ListInsert(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
if (args.Length == 2) {
AppendItem(node, unit, args[1]);
}
return unit.ProjectState._noneInst;
}
示例13: GetMember
public override IAnalysisSet GetMember(Node node, AnalysisUnit unit, string name) {
// Must unconditionally call the base implementation of GetMember
var res = base.GetMember(node, unit, name);
switch (name) {
case "append":
return _appendMethod = _appendMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
ListAppend,
false
);
case "pop":
return _popMethod = _popMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
ListPop,
false
);
case "insert":
return _insertMethod = _insertMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
ListInsert,
false
);
case "extend":
return _extendMethod = _extendMethod ?? new SpecializedCallable(
res.OfType<BuiltinNamespace<IPythonType>>().FirstOrDefault(),
ListExtend,
false
);
}
return res;
}
示例14: BinaryOperation
public override IAnalysisSet BinaryOperation(Node node, AnalysisUnit unit, PythonOperator operation, IAnalysisSet rhs) {
IAnalysisSet res;
switch (operation) {
case PythonOperator.BitwiseOr:
var seq = (SetInfo)unit.Scope.GetOrMakeNodeValue(
node,
_ => new SetInfo(ProjectState, node, unit.ProjectEntry)
);
seq.AddTypes(unit, GetEnumeratorTypes(node, unit));
foreach (var type in rhs.Where(t => t.IsOfType(ClassInfo))) {
seq.AddTypes(unit, type.GetEnumeratorTypes(node, unit));
}
res = seq;
break;
case PythonOperator.BitwiseAnd:
case PythonOperator.ExclusiveOr:
case PythonOperator.Subtract:
res = this;
break;
default:
res = CallReverseBinaryOp(node, unit, operation, rhs);
break;
}
return res;
}
示例15: Call
public override IAnalysisSet Call(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
var res = (DictionaryInfo)unit.Scope.GetOrMakeNodeValue(
node,
NodeValueKind.Dictionary,
(node_) => new DictionaryInfo(unit.ProjectEntry, node)
);
if (keywordArgNames.Length > 0) {
for (int i = 0; i < keywordArgNames.Length; i++) {
var curName = keywordArgNames[i].Name;
var curArg = args[args.Length - keywordArgNames.Length + i];
if (curName == "**") {
foreach (var value in curArg) {
CopyFrom(args, res);
}
} else if (curName != "*") {
res.AddTypes(
node,
unit,
ProjectState.GetConstant(curName),
curArg
);
}
}
} else if (args.Length == 1) {
foreach (var value in args[0]) {
CopyFrom(args, res);
}
}
return res;
}