This commit is contained in:
2025-07-23 05:01:42 -04:00
parent 70c5858c94
commit 7708c479e8
4 changed files with 53 additions and 2 deletions

View File

@@ -10,6 +10,11 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
{
public TypeReference Type { get; }
public IReadOnlyList<AnnotationArgument> Arguments { get; }
/// <summary>
/// Gets the name of the annotation (e.g., "Override" for @Override).
/// </summary>
public string Name => Type.Name;
public Annotation(
SourceRange location,

View File

@@ -38,6 +38,11 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
{
public string PackageName { get; }
public IReadOnlyList<Annotation> Annotations { get; }
/// <summary>
/// Gets the package name. Alias for PackageName for consistency.
/// </summary>
public string Name => PackageName;
public PackageDeclaration(
SourceRange location,
@@ -61,6 +66,13 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
public string ImportPath { get; }
public bool IsStatic { get; }
public bool IsWildcard { get; }
/// <summary>
/// Gets the name of the imported type or package.
/// For "import java.util.List", returns "java.util.List"
/// For "import java.util.*", returns "java.util.*"
/// </summary>
public string Name => ImportPath;
public ImportDeclaration(
SourceRange location,

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using MarketAlly.IronJava.Core.AST.Visitors;
namespace MarketAlly.IronJava.Core.AST.Nodes
@@ -13,6 +14,11 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
public IReadOnlyList<Annotation> Annotations { get; }
public IReadOnlyList<TypeParameter> TypeParameters { get; }
public JavaDoc? JavaDoc { get; }
/// <summary>
/// Gets the body/members of this type declaration.
/// </summary>
public abstract IEnumerable<JavaNode> Body { get; }
protected TypeDeclaration(
SourceRange location,
@@ -67,6 +73,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
AddChildren(members);
}
public override IEnumerable<JavaNode> Body => Members;
public override T Accept<T>(IJavaVisitor<T> visitor) => visitor.VisitClassDeclaration(this);
public override void Accept(IJavaVisitor visitor) => visitor.VisitClassDeclaration(this);
}
@@ -97,6 +105,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
AddChildren(members);
}
public override IEnumerable<JavaNode> Body => Members;
public override T Accept<T>(IJavaVisitor<T> visitor) => visitor.VisitInterfaceDeclaration(this);
public override void Accept(IJavaVisitor visitor) => visitor.VisitInterfaceDeclaration(this);
}
@@ -130,6 +140,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
AddChildren(members);
}
public override IEnumerable<JavaNode> Body => Constants.Cast<JavaNode>().Concat(Members);
public override T Accept<T>(IJavaVisitor<T> visitor) => visitor.VisitEnumDeclaration(this);
public override void Accept(IJavaVisitor visitor) => visitor.VisitEnumDeclaration(this);
}
@@ -154,6 +166,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
AddChildren(members);
}
public override IEnumerable<JavaNode> Body => Members;
public override T Accept<T>(IJavaVisitor<T> visitor) => visitor.VisitAnnotationDeclaration(this);
public override void Accept(IJavaVisitor visitor) => visitor.VisitAnnotationDeclaration(this);
}

View File

@@ -9,6 +9,16 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
public abstract class TypeReference : JavaNode
{
protected TypeReference(SourceRange location) : base(location) { }
/// <summary>
/// Gets the simple name of the type.
/// </summary>
public abstract string Name { get; }
/// <summary>
/// Gets the fully qualified name of the type.
/// </summary>
public virtual string QualifiedName => Name;
}
/// <summary>
@@ -17,6 +27,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
public class PrimitiveType : TypeReference
{
public PrimitiveTypeKind Kind { get; }
public override string Name => Kind.ToString().ToLower();
public PrimitiveType(SourceRange location, PrimitiveTypeKind kind) : base(location)
{
@@ -45,7 +57,9 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
/// </summary>
public class ClassOrInterfaceType : TypeReference
{
public string Name { get; }
private readonly string _name;
public override string Name => _name;
public ClassOrInterfaceType? Scope { get; }
public IReadOnlyList<TypeArgument> TypeArguments { get; }
public IReadOnlyList<Annotation> Annotations { get; }
@@ -57,7 +71,7 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
IReadOnlyList<TypeArgument> typeArguments,
IReadOnlyList<Annotation> annotations) : base(location)
{
Name = name;
_name = name;
Scope = scope;
TypeArguments = typeArguments;
Annotations = annotations;
@@ -68,6 +82,8 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
}
public string FullName => Scope != null ? $"{Scope.FullName}.{Name}" : Name;
public override string QualifiedName => FullName;
public override T Accept<T>(IJavaVisitor<T> visitor) => visitor.VisitClassOrInterfaceType(this);
public override void Accept(IJavaVisitor visitor) => visitor.VisitClassOrInterfaceType(this);
@@ -80,6 +96,10 @@ namespace MarketAlly.IronJava.Core.AST.Nodes
{
public TypeReference ElementType { get; }
public int Dimensions { get; }
public override string Name => ElementType.Name + new string('[', Dimensions) + new string(']', Dimensions);
public override string QualifiedName => ElementType.QualifiedName + new string('[', Dimensions) + new string(']', Dimensions);
public ArrayType(
SourceRange location,