using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Serein.Script.Node { /// /// 类型创建 /// public class ObjectInstantiationNode : ASTNode { /// /// 类型来源 /// public TypeNode Type { get; } /// /// 构造方法的参数来源 /// public List Arguments { get; } /// /// 构造器赋值 /// public List CtorAssignments { get; private set; } = []; public ObjectInstantiationNode(TypeNode type, List arguments) { this.Type = type; this.Arguments = arguments; } public ObjectInstantiationNode SetCtorAssignments(List ctorAssignments) { CtorAssignments = ctorAssignments; return this; } public override string ToString() { var arg = string.Join(",", Arguments.Select(p => $"{p}")); var ctor_arg = string.Join(",", CtorAssignments.Select(p => $"{p}")); return $"new {Type}({arg}){ctor_arg}"; } } }