本文整理汇总了C#中System.Compiler.Identifier.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Identifier.ToString方法的具体用法?C# Identifier.ToString怎么用?C# Identifier.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.Identifier
的用法示例。
在下文中一共展示了Identifier.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplicitInterfaceImplementationIsAllowable
private bool ExplicitInterfaceImplementationIsAllowable(TypeNode parentType, Identifier id){
if (parentType is Class || parentType is Struct) return true;
this.HandleError(id.SourceContext, Error.ExplicitInterfaceImplementationInNonClassOrStruct,
id.ToString()+"."+this.scanner.GetTokenSource());
return false;
}
示例2: AddWriteElement
void AddWriteElement(StatementList statements, TypeNode referringType, Identifier writer, Identifier name, Expression src, TypeNode mt, bool emptyElementOnNull) {
if (mt.Template == SystemTypes.GenericBoxed) {
statements = AddCheckForNull(statements, Duplicate(src, referringType), mt);
mt = Checker.GetCollectionElementType(mt); // check for null and unbox
src = CastTo(src, mt); //unbox it
}
Literal nameLit = new Literal(name.ToString(), SystemTypes.String);
Literal nsLit = (name.Prefix != null) ? new Literal(name.Prefix.Name, SystemTypes.String) : Literal.Null;
if (!emptyElementOnNull) {
statements = AddCheckForNull(statements, Duplicate(src, referringType), mt);
}
if (!AddWriteSimpleType(mt, statements, referringType, writer, src, nameLit, nsLit)) {
AddCallSerializer(mt, statements, src, writer, nameLit, nsLit);
}
}
示例3: CheckAttribute
public Member CheckAttribute(Identifier attrName, out TypeNode mType) {
mType = null;
if (attributes != null) {
for (int j = 0, m = attributes.Length; j < m; j++) {
SchemaAttDef attdef = attributes[j];
if (attdef.Name.UniqueKey != attrName.UniqueKey) continue;
if (attrSpecified[j]) {
context.HandleError(this.RootNode, attrName, Error.DuplicateAttributeSpecified, ErrorHandler.GetTypeNameFor(element.Type), attrName.ToString());
return null;
}
attrSpecified[j] = true;
Member mem = attdef.Member;
//TODO: skip over mem if it is not visible from the current context
mType = (mem.NodeType == NodeType.Field) ? ((Field)mem).Type : ((Property)mem).Type;
return mem;
}
}
return null;
}
示例4: ParseProperty
private void ParseProperty(TypeNode parentType, AttributeList attributes, TokenList modifierTokens,
SourceContextList modifierContexts, object sctx, TypeNode type, TypeNode interfaceType, Identifier name, TokenSet followers){
SourceContext ctx = (SourceContext)sctx;
ctx.EndPos = this.scanner.endPos;
bool isIndexer = this.currentToken == Token.This && name.UniqueIdKey == StandardIds.Item.UniqueIdKey;
Debug.Assert(this.currentToken == Token.LeftBrace || isIndexer);
this.GetNextToken();
ParameterList paramList = null;
if (isIndexer){
if (interfaceType == null){
AttributeNode defaultMember = new AttributeNode();
defaultMember.Constructor = new Literal(TypeExpressionFor("System", "Reflection", "DefaultMemberAttribute"));
defaultMember.Expressions = new ExpressionList(1);
defaultMember.Expressions.Add(new Literal("Item"));
if (parentType.Attributes == null) parentType.Attributes = new AttributeList(1);
parentType.Attributes.Add(defaultMember);
}
paramList = this.ParseParameters(Token.RightBracket, followers|Token.LeftBrace);
this.Skip(Token.LeftBrace);
}
Property p = new Property(parentType, attributes, PropertyFlags.None, name, null, null);
parentType.Members.Add(p);
p.SourceContext = ctx;
p.Documentation = this.LastDocComment;
p.Type = p.TypeExpression = type;
MethodFlags mflags;
if (interfaceType != null){
p.ImplementedTypeExpressions = p.ImplementedTypes = new TypeNodeList(interfaceType);
mflags = MethodFlags.Private|MethodFlags.HideBySig|MethodFlags.NewSlot|MethodFlags.Final|MethodFlags.Virtual|MethodFlags.SpecialName;
for (int i = 0, n = modifierContexts == null ? 0 : modifierContexts.Length; i < n; i++) {
if (modifierTokens[i] == Token.Extern)
mflags |= MethodFlags.PInvokeImpl;
else if (modifierTokens[i] == Token.Unsafe) {
if (!this.allowUnsafeCode) {
this.allowUnsafeCode = true;
this.HandleError(modifierContexts[i], Error.IllegalUnsafe);
}
this.inUnsafeCode = true;
} else
this.HandleError(modifierContexts[i], Error.InvalidModifier, modifierContexts[i].SourceText);
}
}else
mflags = this.GetMethodFlags(modifierTokens, modifierContexts, parentType, p)|MethodFlags.SpecialName;
if ((mflags & MethodFlags.Static) != 0 && parentType is Interface){
this.HandleError(name.SourceContext, Error.InvalidModifier, "static");
mflags &= ~MethodFlags.Static;
mflags |= MethodFlags.Abstract;
}
TokenSet followersOrRightBrace = followers|Token.RightBrace;
bool accessorModifiersAlreadySpecified = false;
MethodFlags accessorFlags = mflags;
while (Parser.GetOrLeftBracketOrSetOrModifier[this.currentToken]){
SourceContext sc = this.scanner.CurrentSourceContext;
AttributeList accessorAttrs = this.ParseAttributes(null, followers|Token.Get|Token.Set|Token.LeftBrace);
switch (this.currentToken){
case Token.Get:{
if (p.Getter != null)
this.HandleError(Error.DuplicateAccessor);
SourceContext scntx = this.scanner.CurrentSourceContext;
this.GetNextToken();
Method m = new Method(parentType, accessorAttrs, new Identifier("get_"+name.ToString()), paramList, type, null);
m.SourceContext = sc;
m.ReturnTypeExpression = type;
m.Name.SourceContext = scntx;
if ((accessorFlags & MethodFlags.Static) == 0)
m.CallingConvention = CallingConventionFlags.HasThis;
parentType.Members.Add(m);
m.Flags = accessorFlags|MethodFlags.HideBySig;
if (interfaceType != null)
m.ImplementedTypeExpressions = m.ImplementedTypes = new TypeNodeList(interfaceType);
bool swallowedSemicolonAlready = false;
bool bodyAllowed = true;
if (this.currentToken == Token.Semicolon){
m.SourceContext.EndPos = this.scanner.endPos;
this.GetNextToken();
bodyAllowed = false;
swallowedSemicolonAlready = true;
}
this.ParseMethodContract(m, followers|Token.LeftBrace|Token.Semicolon, ref swallowedSemicolonAlready);
if (bodyAllowed)
m.Body = this.ParseBody(m, sc, followersOrRightBrace|Token.Set, swallowedSemicolonAlready);
else if (!swallowedSemicolonAlready)
this.SkipSemiColon(followersOrRightBrace|Token.Set);
p.Getter = m;
m.DeclaringMember = p;
accessorFlags = mflags;
break;}
case Token.Set:{
if (p.Setter != null)
this.HandleError(Error.DuplicateAccessor);
SourceContext scntx = this.scanner.CurrentSourceContext;
this.GetNextToken();
ParameterList parList = new ParameterList();
if (paramList != null)
for (int i = 0, n = paramList.Count; i < n; i++) parList.Add((Parameter)paramList[i].Clone());
parList.Add(new Parameter(null, ParameterFlags.None, Identifier.For("value"), type, null, null));
Method m = new Method(parentType, accessorAttrs, new Identifier("set_"+name.ToString()), parList, this.TypeExpressionFor(Token.Void), null);
m.SourceContext = sc;
m.Name.SourceContext = scntx;
if ((accessorFlags & MethodFlags.Static) == 0)
//.........这里部分代码省略.........
示例5: ValidateElementError
protected void ValidateElementError(Identifier name, ValidationState context) {
ArrayList names = ExpectedElements(context, false, true);
if (names == null) {
context.HandleError(this.RootNode, name, Error.InvalidElementContentNone, context.Name.ToString(), name.ToString());
}
else {
Debug.Assert(names.Count > 0);
context.HandleError(this.RootNode, name, Error.InvalidContentExpecting, context.Name.ToString(), name.ToString(), GetExpectedElements(names));
}
}
示例6: ValidateElement
public virtual int ValidateElement(Identifier name, ValidationState context) {
Debug.Assert(contentType != XmlSchemaContentType.ElementOnly);
if (contentType == XmlSchemaContentType.Empty) {
context.HandleError(this.RootNode, context.Name, Error.InvalidElementInEmpty, name.ToString(), context.Name.ToString());
}
else if (contentType == XmlSchemaContentType.TextOnly || !anyElement) {
context.HandleError(this.RootNode, context.Name, Error.InvalidElementInTextOnly, name.ToString(), context.Name.ToString());
}
// we treat Mixed as Any
return -1;
}
示例7: Namespace
public Namespace(Identifier name, Identifier fullName, AliasDefinitionList aliasDefinitions, UsedNamespaceList usedNamespaces,
NamespaceList nestedNamespaces, TypeNodeList types)
: base(NodeType.Namespace)
{
this.Name = name;
this.FullNameId = fullName;
if(fullName != null)
this.fullName = fullName.ToString();
this.AliasDefinitions = aliasDefinitions;
this.NestedNamespaces = nestedNamespaces;
this.Types = types;
this.UsedNamespaces = usedNamespaces;
}