本文整理汇总了C#中VariableDef.AddTypes方法的典型用法代码示例。如果您正苦于以下问题:C# VariableDef.AddTypes方法的具体用法?C# VariableDef.AddTypes怎么用?C# VariableDef.AddTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VariableDef
的用法示例。
在下文中一共展示了VariableDef.AddTypes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FunctionScope
public FunctionScope(
FunctionInfo function,
Node node,
InterpreterScope declScope,
IPythonProjectEntry declModule
)
: base(function, node, declScope) {
ReturnValue = new VariableDef();
if (Function.FunctionDefinition.IsCoroutine) {
Coroutine = new CoroutineInfo(function.ProjectState, declModule);
ReturnValue.AddTypes(function.ProjectEntry, Coroutine.SelfSet, false);
} else if (Function.FunctionDefinition.IsGenerator) {
Generator = new GeneratorInfo(function.ProjectState, declModule);
ReturnValue.AddTypes(function.ProjectEntry, Generator.SelfSet, false);
}
}
示例2: FunctionScope
public FunctionScope(FunctionInfo function, Node node, InterpreterScope declScope)
: base(function, node, declScope)
{
ReturnValue = new VariableDef();
if (Function.FunctionDefinition.IsGenerator) {
Generator = new GeneratorInfo(function.ProjectState, Function.FunctionDefinition);
ReturnValue.AddTypes(function.ProjectEntry, Generator.SelfSet, false);
}
}
示例3: PropagateIsInstanceTypes
private void PropagateIsInstanceTypes(Node node, AnalysisUnit unit, IAnalysisSet typeSet, VariableDef variable) {
foreach (var typeObj in typeSet) {
ClassInfo classInfo;
BuiltinClassInfo builtinClassInfo;
SequenceInfo seqInfo;
if ((classInfo = typeObj as ClassInfo) != null) {
variable.AddTypes(unit, classInfo.Instance, false);
} else if ((builtinClassInfo = typeObj as BuiltinClassInfo) != null) {
variable.AddTypes(unit, builtinClassInfo.Instance, false);
} else if ((seqInfo = typeObj as SequenceInfo) != null) {
if (seqInfo.Push()) {
try {
foreach (var indexVar in seqInfo.IndexTypes) {
PropagateIsInstanceTypes(node, unit, indexVar.Types, variable);
}
} finally {
seqInfo.Pop();
}
}
}
}
}
示例4: GetMember
public override IAnalysisSet GetMember(Node node, AnalysisUnit unit, string name) {
var res = AnalysisSet.Empty;
if (name == "func") {
AddReference(node, unit);
return _function;
} else if (name == "args") {
AddReference(node, unit);
if (_argsTuple == null) {
_argsTuple = new SequenceInfo(_args.Take(_args.Length - _keywordArgNames.Length)
.Select(v => {
var vd = new VariableDef();
vd.AddTypes(unit, v, false, DeclaringModule);
return vd;
}).ToArray(),
unit.ProjectState.ClassInfos[BuiltinTypeId.Tuple],
node,
unit.ProjectEntry
);
}
return _argsTuple;
} else if (name == "keywords") {
AddReference(node, unit);
if (_keywordsDict == null) {
var dict = new DictionaryInfo(unit.ProjectEntry, node);
_keywordsDict = dict;
for (int i = 0; i < _keywordArgNames.Length; ++i) {
int j = i + _args.Length - _keywordArgNames.Length;
if (j >= 0 && j < _args.Length) {
dict._keysAndValues.AddTypes(
unit,
unit.ProjectState.GetConstant(_keywordArgNames[i].Name),
_args[j],
false
);
}
}
}
return _keywordsDict;
}
return res;
}
示例5: SpecializeVariableDef
private static void SpecializeVariableDef(VariableDef def, CallDelegate callable, bool mergeOriginalAnalysis) {
List<AnalysisValue> items = new List<AnalysisValue>();
foreach (var v in def.TypesNoCopy) {
if (!(v is SpecializedNamespace) && v.DeclaringModule != null) {
items.Add(v);
}
}
def._dependencies = default(SingleDict<IVersioned, ReferenceableDependencyInfo>);
foreach (var item in items) {
def.AddTypes(item.DeclaringModule, new SpecializedCallable(item, callable, mergeOriginalAnalysis).SelfSet);
}
}
示例6: ReturnsListOfString
IAnalysisSet ReturnsListOfString(Node node, AnalysisUnit unit, IAnalysisSet[] args, NameExpression[] keywordArgNames) {
return unit.Scope.GetOrMakeNodeValue(node, n => {
var vars = new VariableDef();
vars.AddTypes(unit, unit.ProjectState.ClassInfos[BuiltinTypeId.Str].Instance);
return new ListInfo(
new[] { vars },
unit.ProjectState.ClassInfos[BuiltinTypeId.List],
node,
unit.ProjectEntry
);
});
}
示例7: AssignVariableWorker
/// <summary>
/// Handles the base assignment case for assign to a variable, minus variable creation.
/// </summary>
protected static bool AssignVariableWorker(Node location, AnalysisUnit unit, IAnalysisSet values, VariableDef vars) {
vars.AddAssignment(location, unit);
vars.MakeUnionStrongerIfMoreThan(unit.ProjectState.Limits.AssignedTypes, values);
return vars.AddTypes(unit, values);
}
示例8: SpecializeVariableDef
private static void SpecializeVariableDef(Func<CallExpression, AnalysisUnit, INamespaceSet[], NameExpression[], INamespaceSet> dlg, VariableDef def, bool analyze)
{
List<Namespace> items = new List<Namespace>();
foreach (var v in def.TypesNoCopy) {
if (!(v is SpecializedNamespace) && v.DeclaringModule != null) {
items.Add(v);
}
}
def._dependencies = default(SingleDict<IProjectEntry, TypedDependencyInfo<Namespace>>);
foreach (var item in items) {
def.AddTypes(item.DeclaringModule, SpecializedCallable.MakeSpecializedCallable(dlg, analyze, item).SelfSet);
}
}