本文整理汇总了C#中D_Parser.Resolver.AbstractType类的典型用法代码示例。如果您正苦于以下问题:C# AbstractType类的具体用法?C# AbstractType怎么用?C# AbstractType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractType类属于D_Parser.Resolver命名空间,在下文中一共展示了AbstractType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenTooltipSignature
public string GenTooltipSignature(AbstractType t, bool templateParamCompletion = false, int currentMethodParam = -1)
{
var ds = t as DSymbol;
if (ds != null)
{
if (currentMethodParam >= 0 && !templateParamCompletion && ds.Definition is DVariable && ds.Base != null)
return GenTooltipSignature(ds.Base, false, currentMethodParam);
var aliasedSymbol = ds.Tag<TypeDeclarationResolver.AliasTag>(TypeDeclarationResolver.AliasTag.Id);
return GenTooltipSignature(aliasedSymbol == null || currentMethodParam >= 0 ? ds.Definition : aliasedSymbol.aliasDefinition, templateParamCompletion, currentMethodParam, DTypeToTypeDeclVisitor.GenerateTypeDecl(ds.Base), new DeducedTypeDictionary(ds));
}
if (t is PackageSymbol)
{
var pack = (t as PackageSymbol).Package;
return "<i>(Package)</i> " + pack.ToString();
}
if (t is DelegateType)
{
var sb = new StringBuilder();
GenDelegateSignature(t as DelegateType, sb, templateParamCompletion, currentMethodParam);
return sb.ToString();
}
return DCodeToMarkup(t != null ? t.ToCode(true) : "null");
}
示例2: GenerateCode
public static string GenerateCode(AbstractType t, bool pretty = false)
{
var vis = new DTypeToCodeVisitor(pretty);
vis.AcceptType(t);
return vis.sb.ToString();
}
示例3: GenerateCode
public static string GenerateCode(AbstractType t)
{
var vis = new DTypeToCodeVisitor();
vis.AcceptType(t);
return vis.sb.ToString();
}
示例4: ObjectCacheNode
public ObjectCacheNode(string n, AbstractType t, ulong address) {
if(string.IsNullOrEmpty(n))
throw new ArgumentNullException("name","Child name must not be empty!");
if(t == null)
throw new ArgumentNullException("t","Abstract type of '"+n+"' must not be null!");
Name = n;
NodeType = t;
this.address = address;
}
示例5: ObjectCacheNode
public ObjectCacheNode(string n, AbstractType t, string exp) {
if(string.IsNullOrEmpty(n))
throw new ArgumentNullException("name","Child name must not be empty!");
if(t == null)
throw new ArgumentNullException("t","Abstract type of '"+n+"' must not be null!");
if(string.IsNullOrEmpty(exp))
throw new ArgumentNullException("exp","Address expression must not be empty!");
Name = n;
NodeType = t;
addressExpression = exp;
}
示例6: GenerateRepresentativeNode
public DNode GenerateRepresentativeNode(AbstractType t, ResolutionContext ctxt)
{
if (NodeGetter != null)
return NodeGetter(t, ctxt);
return new DVariable()
{
Attributes = !RequireThis ? StaticAttributeList : null,
Name = Name,
Description = Description,
Type = GetPropertyType(t, ctxt)
};
}
示例7: Create
//TODO: Für semantisches Highlighting den TypeRefFinder benutzen und einfach pauschal alle Ids entsprechend highlighten
public static TooltipInformation Create(AbstractType t, ColorScheme st, bool templateParamCompletion = false, int currentMethodParam = -1)
{
var markupGen = new TooltipMarkupGen (st);
var tti = new TooltipInformation {
SignatureMarkup = markupGen.GenTooltipSignature (t, templateParamCompletion, currentMethodParam)
};
var ds = t as DSymbol;
DNode n;
if (ds != null && (n = ds.Definition) != null)
CreateTooltipBody (markupGen, n, tti);
return tti;
}
示例8: GenTooltipSignature
public string GenTooltipSignature(AbstractType t, bool templateParamCompletion = false, int currentMethodParam = -1)
{
var ds = t as DSymbol;
if (ds != null)
{
var aliasedSymbol = ds.Tag as D_Parser.Resolver.TypeResolution.TypeDeclarationResolver.AliasTag;
return GenTooltipSignature(aliasedSymbol == null ? ds.Definition : aliasedSymbol.aliasDefinition, templateParamCompletion, currentMethodParam, DTypeToTypeDeclVisitor.GenerateTypeDecl(ds.Base), ds.DeducedTypes != null ? new DeducedTypeDictionary(ds) : null);
}
if (t is PackageSymbol) {
var pack = (t as PackageSymbol).Package;
return "<i>(Package)</i> "+pack.ToString();
}
return DCodeToMarkup (t != null ? t.ToCode () : "null");
}
示例9: GenUfcsAndStaticProperties
void GenUfcsAndStaticProperties(AbstractType t)
{
if (t.NonStaticAccess && CompletionOptions.Instance.ShowUFCSItems)
CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () =>
{
try
{
foreach (var ufcsItem in UFCSResolver.TryResolveUFCS(t, 0, ed.CaretLocation, ctxt))
CompletionDataGenerator.Add((ufcsItem as DSymbol).Definition);
}
catch(Exception ex)
{
Logger.LogWarn("Error during ufcs completion resolution", ex);
}
});
StaticProperties.ListProperties(CompletionDataGenerator, ctxt, MemberFilter, t, t.NonStaticAccess);
}
示例10: Generate
public static TooltipInformation Generate(AbstractType t, int currentParameter = -1, bool isInTemplateArgInsight = false)
{
var ms = t as MemberSymbol;
if (ms != null)
{
if (ms.Definition is DVariable)
{
var bt = DResolver.StripAliasSymbol(ms.Base);
if (bt is DelegateType)
return TooltipInfoGenerator.Generate(bt as DelegateType, currentParameter);
}
else if (ms.Definition is DMethod)
return TooltipInfoGenerator.Generate(ms.Definition as DMethod, isInTemplateArgInsight, currentParameter);
}
else if (t is TemplateIntermediateType)
return Generate(t as TemplateIntermediateType, currentParameter);
return new TooltipInformation();
}
示例11: AcceptType
void AcceptType(AbstractType t)
{
if (t == null)
return;
if (pretty)
{
var aliasTag = t.Tag<TypeDeclarationResolver.AliasTag>(TypeDeclarationResolver.AliasTag.Id);
if (aliasTag != null)
sb.Append(aliasTag.typeBase != null ? aliasTag.typeBase.ToString() : aliasTag.aliasDefinition.ToString(false, false)).Append('=');
}
if (t.Modifier != 0)
sb.Append(DTokens.GetTokenString(t.Modifier)).Append('(');
t.Accept(this);
if (t.Modifier != 0)
sb.Append(')');
}
示例12: GetReferenceUrl
public static string GetReferenceUrl(AbstractType result, ResolutionContext ctxt, CodeLocation caret)
{
if (result != null) {
var n = DResolver.GetResultMember (result);
if (n != null && n.NodeRoot is DModule) {
if (IsPhobosModule (n.NodeRoot as DModule)) {
var phobos_url = "phobos/" + (n.NodeRoot as DModule).ModuleName.Replace ('.', '_') + ".html";
if (!(n is DModule))
phobos_url += "#" + n.Name;
return phobos_url;
}
} else if (result is PrimitiveType || result is DelegateType || result is AssocArrayType) {
if (result.DeclarationOrExpressionBase is ITypeDeclaration)
return GetRefUrlFor ((ITypeDeclaration)result.DeclarationOrExpressionBase);
else if (result.DeclarationOrExpressionBase is IExpression)
return GetRefUrlFor ((IExpression)result.DeclarationOrExpressionBase);
}
}
if (ctxt.ScopedStatement != null) {
return GetRefUrlFor (ctxt.ScopedStatement, caret);
} else if (ctxt.ScopedBlock is DClassLike) {
var dc = ctxt.ScopedBlock as DClassLike;
if (dc.ClassType == DTokens.Class)
return "class.html";
else if (dc.ClassType == DTokens.Interface)
return "interface.html";
else if (dc.ClassType == DTokens.Struct || dc.ClassType == DTokens.Union)
return "struct.html";
else if (dc.ClassType == DTokens.Template)
return "template.html";
} else if (ctxt.ScopedBlock is DEnum)
return "enum.html";
return null;
}
示例13: DSymbol
public DSymbol(DNode Node, AbstractType BaseType, IEnumerable<TemplateParameterSymbol> deducedTypes, ISyntaxRegion td)
: base(BaseType, td)
{
if(deducedTypes!=null)
this.DeducedTypes = new ReadOnlyCollection<TemplateParameterSymbol>(deducedTypes.ToArray());
if (Node == null)
throw new ArgumentNullException ("Node");
this.definition = new WeakReference(Node);
NameHash = Node.NameHash;
}
示例14: Type
AbstractType Type(char type = '\0')
{
if(type == '\0')
type = (char)r.Read();
switch(type)
{
case 'O':
var t = Type();
t.Modifier = DTokens.Shared;
return t;
case 'x':
t = Type();
t.Modifier = DTokens.Const;
return t;
case 'y':
t = Type();
t.Modifier = DTokens.Immutable;
return t;
case 'N':
switch(r.Read())
{
case 'g':
t = Type();
t.Modifier = DTokens.InOut;
return t;
case 'e': // TypeNewArray ?
Type();
return null;
}
break;
case 'A':
return new ArrayType(Type());
case 'G':
var len = (int)Number();
return new ArrayType(Type(), len);
case 'H':
var keyType = Type();
t = Type();
return new AssocArrayType(t, keyType);
case 'P':
return new PointerType(Type());
case 'F':
case 'U':
case 'W':
case 'V':
case 'R':
AbstractType ret;
List<DAttribute> attrs;
Dictionary<INode,AbstractType> pars;
Function(out ret, out attrs, out pars, type);
var dm = new DMethod(){ Parameters = pars.Keys.ToList(), Attributes = attrs };
return new MemberSymbol(dm, ret, null);
case 'C':
case 'S':
case 'E':
case 'T':
case 'I':
return TypeDeclarationResolver.ResolveSingle (QualifiedName (), ctxt);
/*
return new MemberSymbol(null,null, QualifiedName());
case 'C':
return new ClassType(new DClassLike(DTokens.Class), QualifiedName(), null);
case 'S':
return new StructType(new DClassLike(DTokens.Struct), QualifiedName());
case 'E':
return new EnumType(new DEnum(), null, QualifiedName());
case 'T':
return new AliasedType(null, null, QualifiedName());
*/case 'D':
Function(out ret, out attrs, out pars, type);
var dgArgs = new List<AbstractType>();
foreach(var kv in pars)
dgArgs.Add(new MemberSymbol(kv.Key as DNode, kv.Value, null));
return new DelegateType(ret,new DelegateDeclaration{ Parameters = pars.Keys.ToList() }, dgArgs);
case 'v': return new PrimitiveType(DTokens.Void);
case 'g': return new PrimitiveType(DTokens.Byte);
case 'h': return new PrimitiveType(DTokens.Ubyte);
case 's': return new PrimitiveType(DTokens.Short);
case 't': return new PrimitiveType(DTokens.Ushort);
case 'i': return new PrimitiveType(DTokens.Int);
case 'k': return new PrimitiveType(DTokens.Uint);
case 'l': return new PrimitiveType(DTokens.Long);
case 'm': return new PrimitiveType(DTokens.Ulong);
case 'f': return new PrimitiveType(DTokens.Float);
case 'd': return new PrimitiveType(DTokens.Double);
case 'e': return new PrimitiveType(DTokens.Real);
case 'o': return new PrimitiveType(DTokens.Ifloat);
case 'p': return new PrimitiveType(DTokens.Idouble);
case 'j': return new PrimitiveType(DTokens.Ireal);
case 'q': return new PrimitiveType(DTokens.Cfloat);
case 'r': return new PrimitiveType(DTokens.Cdouble);
case 'c': return new PrimitiveType(DTokens.Creal);
case 'b': return new PrimitiveType(DTokens.Bool);
case 'a': return new PrimitiveType(DTokens.Char);
case 'u': return new PrimitiveType(DTokens.Wchar);
case 'w': return new PrimitiveType(DTokens.Dchar);
case 'n': return null;
//.........这里部分代码省略.........
示例15: Function
void Function(out AbstractType returnType,
out List<DAttribute> attributes,
out Dictionary<INode,AbstractType> parameters,
char callConvention = 'F')
{
attributes = new List<DAttribute>();
// Create artificial extern attribute
var conv = "D";
switch(callConvention)
{
case 'U':
conv = "C";
break;
case 'W':
conv = "Windows";
break;
case 'V':
conv = "Pascal";
break;
case 'R':
conv = "C++";
break;
}
attributes.Add(new Modifier(DTokens.Extern,conv));
var nextChar = '\0';
do
{
nextChar = (char)r.Read();
if(nextChar == 'N')
{
switch(r.Peek())
{
case 'a':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new Modifier(DTokens.Pure));
continue;
case 'b':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new Modifier(DTokens.Nothrow));
continue;
case 'c':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new Modifier(DTokens.Ref));
continue;
case 'd':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new BuiltInAtAttribute(BuiltInAtAttribute.BuiltInAttributes.Property));
continue;
case 'e':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new BuiltInAtAttribute(BuiltInAtAttribute.BuiltInAttributes.Trusted));
continue;
case 'f':
r.Read();
nextChar = (char)r.Read();
attributes.Add(new BuiltInAtAttribute(BuiltInAtAttribute.BuiltInAttributes.Safe));
continue;
}
}
}
while(false);
parameters = Arguments(ref nextChar);
if(nextChar == 'X') // variadic T t...) style
{
var lastParam = parameters.Keys.Last();
lastParam.Type = new VarArgDecl(lastParam.Type);
}
else if(nextChar == 'Y') // variadic T t,...) style
parameters.Add(new DVariable{ Type = new VarArgDecl() }, null);
else if(nextChar != 'Z')
throw new ArgumentException("Expected 'X','Y' or 'Z' at the end of a function type.");
returnType = Type();
}