public GenericSignature(GenericParameter parameters, GenericConstraint constraints, TokenPosition position) : base(position) { this.parameters = parameters; this.constraints = constraints; }
public GenericSignature(GenericParameter parameters, GenericConstraint constraints, TokenPosition position) : base(position) { this.parameters = parameters; this.constraints = constraints; }
public void SetConstraints(GenericConstraint constraints) { this.constraints = constraints; }
public override AstNode Visit(GenericConstraint node) { // Find the parameter. GenericSignature signature = node.GetSignature(); AstNode current = signature.GetParameters(); GenericParameter parameter = null; while(current != null) { if(current.GetName() == node.GetName()) { // Found. parameter = (GenericParameter) current; break; } // Check the next parameter. current = current.GetNext(); } // Raise an error for unknown parameter. if(parameter == null) Error(node, "unknown generic parameter '{0}'", node.GetName()); // Fetch the bases. List<Structure> bases = new List<Structure> (); current = node.GetBases(); bool hasClass = false; while(current != null) { // Visit the base expression. current.Accept(this); // Get the base type. IChelaType nodeType = current.GetNodeType(); if(!nodeType.IsMetaType()) Error(current, "expected class/interface type."); // Remove the meta layer. nodeType = ExtractActualType(current, nodeType); // Make sure is a class or a structure. if(!nodeType.IsClass() && !nodeType.IsStructure() && !nodeType.IsInterface()) Error(current, "expected class/struct/interface type."); // Enforce single inheritance. if(nodeType.IsClass()) { if(hasClass) Error(current, "only single inheritance is supported."); hasClass = true; } // Store the base. bases.Add((Structure)nodeType); // Check the next base. current = current.GetNext(); } // Store the constraint data in the parameter. parameter.SetValueType(node.IsValueType()); parameter.SetBases(bases); return node; }
public virtual AstNode Visit(GenericConstraint node) { throw new System.NotImplementedException(); }
public virtual AstNode Visit(GenericConstraint node) { throw new System.NotImplementedException(); }
public void SetConstraints(GenericConstraint constraints) { this.constraints = constraints; }