本文整理汇总了C#中Core.AddMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Core.AddMessage方法的具体用法?C# Core.AddMessage怎么用?C# Core.AddMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core
的用法示例。
在下文中一共展示了Core.AddMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckField
private static bool CheckField(
Core.Session session, int structIndex, int fieldIndex,
Core.Type innerType, Stack<int> seenStructs)
{
var fieldStruct = innerType as Core.TypeStruct;
if (fieldStruct == null)
return false;
var st = session.GetStruct(structIndex);
Core.Name fieldName;
st.fieldNames.FindByValue(fieldIndex, out fieldName);
session.PushContext(
"in struct '" + session.GetStructName(structIndex).GetString() + "', " +
"field '" + fieldName.GetString() + "'",
st.GetFieldNameSpan(fieldIndex));
var err = false;
if (seenStructs.Contains(fieldStruct.structIndex))
{
err = true;
session.AddMessage(
Diagnostics.MessageKind.Error,
Diagnostics.MessageCode.StructRecursion,
"struct recursion",
session.GetStruct(fieldStruct.structIndex).GetNameSpan(),
st.GetFieldNameSpan(fieldIndex));
}
if (!err)
CheckStruct(session, fieldStruct.structIndex, seenStructs);
session.PopContext();
return err;
}
示例2: Tokenize
public static TokenCollection Tokenize(Core.Session session, Core.TextInput input)
{
var output = new TokenCollection();
// Iterate through all characters in input.
var index = 0;
while (index < input.Length())
{
// Skip whitespace.
if (IsWhitespace(input[index]))
{
index++;
continue;
}
// Match next characters to a token, and add it to the output.
var match =
TryMatchModelToken(input, index) ??
TryMatchVaryingToken(input, index) ??
new TokenMatch(new string(input[index], 1), TokenKind.Error);
var span = new Span(input, index, index + match.representation.Length);
// Signal errors.
if (match.kind == TokenKind.Error)
{
session.AddMessage(MessageKind.Error, MessageCode.UnexpectedChar, "unexpected character", span);
}
// Skip line comments.
else if (match.kind == TokenKind.DoubleSlash)
{
while (index < input.Length() && input[index] != '\n')
index++;
continue;
}
// Skip multiline comments.
else if (match.kind == TokenKind.SlashAsterisk)
{
var nesting = 1;
index += 2;
while (index < input.Length() - 1)
{
if (input[index] == '*' && input[index + 1] == '/')
{
nesting--;
index += 2;
if (nesting == 0)
break;
}
else if (input[index] == '/' && input[index + 1] == '*')
{
nesting++;
index += 2;
}
else
index++;
}
if (nesting > 0)
session.AddMessage(MessageKind.Error, MessageCode.UnexpectedChar, "unterminated comment", span);
continue;
}
output.tokens.Add(new Token(match.kind, span));
index += match.representation.Length;
}
output.tokenAfterEnd =
new Token(TokenKind.Error, new Diagnostics.Span(input, index, index));
return output;
}
示例3: ResolveStruct
public static Core.Type ResolveStruct(
Core.Session session,
Grammar.ASTNodeExprName nameNode,
IList<Core.UseDirective> useDirectives,
bool mustBeResolved)
{
var nameConcreteNode = nameNode as Grammar.ASTNodeExprNameConcrete;
if (nameConcreteNode == null)
{
if (mustBeResolved)
{
session.AddMessage(
Diagnostics.MessageKind.Error,
Diagnostics.MessageCode.Expected,
"type must be known",
nameNode.GetSpan());
}
return new Core.TypeError();
}
return ResolveStruct(session, nameConcreteNode.name, useDirectives, mustBeResolved);
}
示例4: ValidateDataAccess
public static bool ValidateDataAccess(
Core.Session session,
Core.DeclFunct funct,
Core.DataAccess access)
{
var regDeref = access as Core.DataAccessDereference;
if (regDeref != null)
{
var innerType = GetDataAccessType(session, funct, regDeref.innerAccess);
var innerPtr = innerType as Core.TypePointer;
if (innerPtr == null)
{
session.AddMessage(
Diagnostics.MessageKind.Error,
Diagnostics.MessageCode.CannotDereferenceType,
"dereferencing '" + innerType.GetString(session) + "'",
access.span);
return false;
}
}
return true;
}
示例5: Resolve
public static Core.Type Resolve(
Core.Session session,
Grammar.ASTNodeType typeNode,
IList<Core.UseDirective> useDirectives,
bool mustBeResolved)
{
var typePlaceholderNode = typeNode as Grammar.ASTNodeTypePlaceholder;
if (typePlaceholderNode != null)
{
if (mustBeResolved)
{
session.AddMessage(
Diagnostics.MessageKind.Error,
Diagnostics.MessageCode.Expected,
"type must be known",
typeNode.GetSpan());
return new Core.TypeError();
}
return new Core.TypePlaceholder();
}
var typeStructNode = typeNode as Grammar.ASTNodeTypeStruct;
if (typeStructNode != null)
{
return ResolveStruct(session, typeStructNode.name, useDirectives, mustBeResolved);
}
var typeTupleNode = typeNode as Grammar.ASTNodeTypeTuple;
if (typeTupleNode != null)
{
var elementTypes = new Core.Type[typeTupleNode.elements.Count];
for (var i = 0; i < typeTupleNode.elements.Count; i++)
elementTypes[i] = Resolve(session, typeTupleNode.elements[i], useDirectives, mustBeResolved);
return Core.TypeTuple.Of(elementTypes);
}
var typeFunctNode = typeNode as Grammar.ASTNodeTypeFunct;
if (typeFunctNode != null)
{
var returnType = Resolve(session, typeFunctNode.returnType, useDirectives, mustBeResolved);
var parameterTypes = new Core.Type[typeFunctNode.parameters.Count];
for (var i = 0; i < typeFunctNode.parameters.Count; i++)
parameterTypes[i] = Resolve(session, typeFunctNode.parameters[i], useDirectives, mustBeResolved);
return Core.TypeFunct.Of(returnType, parameterTypes);
}
var typeRefNode = typeNode as Grammar.ASTNodeTypePointer;
if (typeRefNode != null)
{
return Core.TypePointer.Of(
typeRefNode.mutable,
Resolve(session, typeRefNode.referenced, useDirectives, mustBeResolved));
}
throw new System.NotImplementedException();
}