public override void OnGenericParameterDeclaration(GenericParameterDeclaration node) { if (node.Entity == null) { node.Entity = new InternalGenericParameter(TypeSystemServices, node); } }
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); }
public static CompilerError InvalidTypeConstraint(GenericParameterDeclaration gpd, TypeReference type) { return Instantiate("BCE0162", type, gpd.Name, type); }
public GenericConstraintValidator(CompilerContext context, GenericParameterDeclaration gpd) { _context = context; _gpd = gpd; }
override public object Clone() { GenericParameterDeclaration clone = new GenericParameterDeclaration(); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._isSynthetic = _isSynthetic; clone._entity = _entity; if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone(); clone._name = _name; if (null != _baseTypes) { clone._baseTypes = _baseTypes.Clone() as TypeReferenceCollection; clone._baseTypes.InitializeParent(clone); } clone._constraints = _constraints; return clone; }
override public bool Replace(Node existing, Node newNode) { if (base.Replace(existing, newNode)) { return(true); } if (_attributes != null) { Attribute item = existing as Attribute; if (null != item) { Attribute newItem = (Attribute)newNode; if (_attributes.Replace(item, newItem)) { return(true); } } } if (_parameters != null) { ParameterDeclaration item = existing as ParameterDeclaration; if (null != item) { ParameterDeclaration newItem = (ParameterDeclaration)newNode; if (_parameters.Replace(item, newItem)) { return(true); } } } if (_genericParameters != null) { GenericParameterDeclaration item = existing as GenericParameterDeclaration; if (null != item) { GenericParameterDeclaration newItem = (GenericParameterDeclaration)newNode; if (_genericParameters.Replace(item, newItem)) { return(true); } } } if (_returnType == existing) { this.ReturnType = (TypeReference)newNode; return(true); } if (_returnTypeAttributes != null) { Attribute item = existing as Attribute; if (null != item) { Attribute newItem = (Attribute)newNode; if (_returnTypeAttributes.Replace(item, newItem)) { return(true); } } } if (_body == existing) { this.Body = (Block)newNode; return(true); } if (_locals != null) { Local item = existing as Local; if (null != item) { Local newItem = (Local)newNode; if (_locals.Replace(item, newItem)) { return(true); } } } if (_explicitInfo == existing) { this.ExplicitInfo = (ExplicitMemberInfo)newNode; return(true); } return(false); }
protected void generic_parameter_constraints( GenericParameterDeclaration gpd ) //throws RecognitionException, TokenStreamException { TypeReference tr = null; try { // for error handling { switch ( LA(1) ) { case CLASS: { match(CLASS); if (0==inputState.guessing) { gpd.Constraints |= GenericParameterConstraints.ReferenceType; } break; } case STRUCT: { match(STRUCT); if (0==inputState.guessing) { gpd.Constraints |= GenericParameterConstraints.ValueType; } break; } case CONSTRUCTOR: { match(CONSTRUCTOR); if (0==inputState.guessing) { gpd.Constraints |= GenericParameterConstraints.Constructable; } break; } case CALLABLE: case CHAR: case THEN: case LPAREN: case ID: case SPLICE_BEGIN: { tr=type_reference(); if (0==inputState.guessing) { gpd.BaseTypes.Add(tr); } break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } { switch ( LA(1) ) { case COMMA: { match(COMMA); generic_parameter_constraints(gpd); break; } case RPAREN: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "generic_parameter_constraints"); recover(ex,tokenSet_53_); } else { throw ex; } } }
void DefineGenericParameters(GenericTypeParameterBuilder[] builders, GenericParameterDeclaration[] declarations) { for (int i = 0; i < builders.Length; i++) { SetBuilder(declarations[i], builders[i]); DefineGenericParameter(((InternalGenericParameter)declarations[i].Entity), builders[i]); } }
public static CompilerError TypeConstraintConflictsWithSpecialConstraint(GenericParameterDeclaration gpd, TypeReference type, string constraint) { return Instantiate("BCE0161", type, gpd.Name, type, constraint); }
void DefineGenericParameters(GenericTypeParameterBuilder[] builders, GenericParameterDeclaration[] declarations) { // Set builders for (int i = 0; i < builders.Length; i++) { SetBuilder(declarations[i], builders[i]); } // TODO: Set constraints }
public override void OnGenericParameterDeclaration(GenericParameterDeclaration gp) { Write(gp.Name); }
public static CompilerError TypeConstraintConflictsWithSpecialConstraint(GenericParameterDeclaration gpd, TypeReference type, string constraint) { return new CompilerError("BCE0161", SafeLexicalInfo(type), gpd.Name, type, constraint); }
public static CompilerError StructAndConstructorConstraintsConflict(GenericParameterDeclaration gpd) { return new CompilerError("BCE0160", SafeLexicalInfo(gpd), gpd.Name); }
public static CompilerError MultipleBaseTypeConstraints(GenericParameterDeclaration gpd, TypeReference type, TypeReference other) { return new CompilerError("BCE0163", SafeLexicalInfo(type), gpd.Name, type, other); }
public static CompilerError InvalidTypeConstraint(GenericParameterDeclaration gpd, TypeReference type) { return new CompilerError("BCE0162", SafeLexicalInfo(type), gpd.Name, type); }
public static CompilerError MultipleBaseTypeConstraints(GenericParameterDeclaration gpd, TypeReference type, TypeReference other) { return Instantiate("BCE0163", type, gpd.Name, type, other); }
public static CompilerError StructAndConstructorConstraintsConflict(GenericParameterDeclaration gpd) { return Instantiate("BCE0160", gpd, gpd.Name); }
//throws RecognitionException, TokenStreamException protected void generic_parameter_declaration( GenericParameterDeclarationCollection c ) { IToken id = null; try { // for error handling id = LT(1); match(ID); if (0==inputState.guessing) { GenericParameterDeclaration gpd = new GenericParameterDeclaration(SourceLocationFactory.ToLexicalInfo(id)); gpd.Name = id.getText(); c.Add(gpd); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_25_); } else { throw ex; } } }
/// <summary> /// Defines the generic parameters of an internal generic method. /// </summary> void DefineGenericParameters(MethodBuilder builder, GenericParameterDeclaration[] parameters) { string[] names = Array.ConvertAll<GenericParameterDeclaration, string>( parameters, delegate(GenericParameterDeclaration gpd) { return gpd.Name; }); GenericTypeParameterBuilder[] builders = builder.DefineGenericParameters(names); DefineGenericParameters(builders, parameters); }
public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration) : base(tss) { _declaration = declaration; }
protected void generic_parameter_declaration( GenericParameterDeclarationCollection c ) //throws RecognitionException, TokenStreamException { IToken id = null; GenericParameterDeclaration gpd = null; try { // for error handling id = LT(1); match(ID); if (0==inputState.guessing) { gpd = new GenericParameterDeclaration(ToLexicalInfo(id)); gpd.Name = id.getText(); c.Add(gpd); } { if ((LA(1)==LPAREN) && (tokenSet_59_.member(LA(2)))) { match(LPAREN); generic_parameter_constraints(gpd); match(RPAREN); } else if ((LA(1)==LPAREN||LA(1)==RBRACK||LA(1)==COMMA) && (tokenSet_60_.member(LA(2)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "generic_parameter_declaration"); recover(ex,tokenSet_61_); } else { throw ex; } } }
public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration, int position) : this(tss, declaration) { _position = position; }
//TODO: >=0.9, support constraints here public GenericParameterDeclaration CreateGenericParameterDeclaration(int index, string name) { GenericParameterDeclaration p = new GenericParameterDeclaration(name); p.Entity = new InternalGenericParameter(_tss, p, index); return p; }
public InternalGenericParameter(TypeSystemServices tss, GenericParameterDeclaration declaration) { _tss = tss; _declaration = declaration; }