本文整理汇总了C#中Boo.Lang.Compiler.Ast.TypeDefinition类的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition类的具体用法?C# TypeDefinition怎么用?C# TypeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDefinition类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了TypeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiftGenericTypeDefinition
private static TypeReference LiftGenericTypeDefinition(TypeDefinition node)
{
var typeRef = new GenericTypeReference(node.LexicalInfo, node.QualifiedName);
foreach (GenericParameterDeclaration parameter in node.GenericParameters)
typeRef.GenericArguments.Add(Lift(parameter.Name));
return typeRef;
}
示例2: LeaveTypeDefinition
void LeaveTypeDefinition(TypeDefinition node)
{
if (!node.IsVisibilitySet)
node.Modifiers |= Context.Parameters.DefaultTypeVisibility;
node.Name = NormalizeName(node.Name);
}
示例3: OnCandidatePartialDefinition
private void OnCandidatePartialDefinition(TypeDefinition node)
{
if (!node.IsPartial)
return;
var typeName = node.FullName;
TypeDefinition originalDefinition;
if (_partials.TryGetValue(typeName, out originalDefinition))
{
if (node == originalDefinition) // MergePartialTypes can be executed more than once
return;
if (originalDefinition.NodeType != node.NodeType)
{
Errors.Add(CompilerErrorFactory.IncompatiblePartialDefinition(node, typeName, AstUtil.TypeKeywordFor(originalDefinition), AstUtil.TypeKeywordFor(node)));
return;
}
MergeImports(node, originalDefinition);
originalDefinition.Merge(node);
RemoveCurrentNode();
}
else
_partials[typeName] = node;
}
示例4: BuildUniqueTypeMemberName
//use this to build a type member name unique in the inheritance hierarchy.
public static string BuildUniqueTypeMemberName(TypeDefinition type, string name)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
StringBuilder nameBuilder = new StringBuilder("$");
nameBuilder.Append(name);
nameBuilder.Append("__");
nameBuilder.Append(type.QualifiedName);
if (type.HasGenericParameters)
{
nameBuilder.Append("_");
string[] parameterNames = Array.ConvertAll<GenericParameterDeclaration, string>(
type.GenericParameters.ToArray(),
delegate(GenericParameterDeclaration gpd) { return gpd.Name; });
foreach (string parameterName in parameterNames)
{
nameBuilder.Append("_");
nameBuilder.Append(parameterName);
}
}
nameBuilder.Replace('.', '_');
nameBuilder.Append("$");
return nameBuilder.ToString();
}
示例5: EnterTypeDefinition
void EnterTypeDefinition(TypeDefinition node)
{
List<Field> list = new List<Field>();
fieldStack.Push(list);
foreach (TypeMember member in node.Members) {
if (member is Field)
list.Add((Field)member);
}
}
示例6: BindMembers
public static void BindMembers(string cacheName,TypeDefinition type){
if (!cache.ContainsKey(cacheName)) return;
foreach (var member in cache[cacheName]){
type.Members.Add(member);
}
cache.Remove(cacheName);
new Method().Parameters.Add(new ParameterDeclaration("name",new SimpleTypeReference("string")));
}
示例7: OnTypeDefinition
private void OnTypeDefinition(TypeDefinition node)
{
var old = _currentType;
_currentType = (IType)node.Entity;
Visit(node.Attributes);
Visit(node.BaseTypes);
Visit(node.Members);
Visit(node.GenericParameters);
_currentType = old;
}
示例8: InternalGenericParameter
public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration)
{
_tss = tss;
_declaration = declaration;
// Determine and remember declaring type and declaring method (if applicable)
_declaringMethod = declaration.ParentNode as Method;
_declaringType = (
_declaringMethod == null ?
declaration.ParentNode as TypeDefinition : _declaringMethod.DeclaringType);
}
示例9: ExtendBaseClass
protected override void ExtendBaseClass(TypeDefinition definition)
{
Property property = new Property("Environment");
property.Getter = new Method("getter_Environment");
property.Getter.Body.Add(
new ReturnStatement(
new StringLiteralExpression(environment ?? "")
)
);
definition.Members.Add(property);
}
示例10: CheckMembers
void CheckMembers(TypeDefinition node)
{
_members.Clear();
foreach (TypeMember member in node.Members)
{
if (member.NodeType == NodeType.StatementTypeMember)
continue;
var list = GetMemberList(member.Name);
CheckMember(list, member);
list.Add(member);
}
}
示例11: MergeImports
static void MergeImports(TypeDefinition from, TypeDefinition to)
{
Module fromModule = from.EnclosingModule;
Module toModule = to.EnclosingModule;
if (fromModule == toModule) return;
if (toModule.ContainsAnnotation(fromModule)) return;
toModule.Imports.ExtendWithClones(fromModule.Imports.Where(i => !toModule.Imports.Any(i2 => i.Matches(i2))));
// annotate so we remember not to merge the imports
// again in the future
toModule.Annotate(fromModule);
//annotate so that we know these modules have been merged
//this is used by checkneverusedmembers step
if (!fromModule.ContainsAnnotation("merged-module"))
fromModule.Annotate("merged-module");
if (!toModule.ContainsAnnotation("merged-module"))
toModule.Annotate("merged-module");
}
示例12: LeaveTypeDefinition
override public void LeaveTypeDefinition(TypeDefinition node)
{
_safeVars.Clear(); //clear type var cache (CheckAmbiguousVariableNames)
if (node.NodeType == NodeType.Module)
return;
string qualifiedName = node.QualifiedName;
if (node.HasGenericParameters)
{
qualifiedName += "`" + node.GenericParameters.Count;
}
if (_types.ContainsKey(qualifiedName))
{
Errors.Add(CompilerErrorFactory.NamespaceAlreadyContainsMember(node, GetNamespace(node), node.Name));
return;
}
_types.Add(qualifiedName, node);
}
示例13: BaseTypeResolution
public BaseTypeResolution(CompilerContext context, TypeDefinition typeDefinition, List<TypeDefinition> visited) : base(context)
{
_typeDefinition = typeDefinition;
_visited = visited;
_visited.Add(_typeDefinition);
_removed = 0;
_index = -1;
NameResolutionService nameResolution = NameResolutionService;
INamespace previous = nameResolution.CurrentNamespace;
nameResolution.EnterNamespace(ParentNamespaceOf(_typeDefinition));
try
{
Run();
}
finally
{
nameResolution.EnterNamespace(previous);
}
}
示例14: GenerateConstructors
private void GenerateConstructors(TypeDefinition definition)
{
ConstructorInfo[] ctors =
baseClass.GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (ConstructorInfo ctor in ctors)
{
if (ctor.IsPrivate)
continue;
Constructor constructor = new Constructor(definition.LexicalInfo);
definition.Members.Add(constructor);
MethodInvocationExpression super = new MethodInvocationExpression(new SuperLiteralExpression());
constructor.Body.Add(super);
foreach (ParameterInfo info in ctor.GetParameters())
{
SimpleTypeReference typeReference =
new SimpleTypeReference(TypeUtilities.GetFullName(info.ParameterType));
constructor.Parameters.Add(new ParameterDeclaration(info.Name,
typeReference)
);
super.Arguments.Add(new ReferenceExpression(info.Name));
}
}
}
示例15: GetStaticConstructor
Constructor GetStaticConstructor(TypeDefinition type)
{
return CodeBuilder.GetOrCreateStaticConstructorFor(type);
}