// ResMemberDecl public override IResMemberDecl CreateInheritedDeclImpl( ResolveContext resContext, IResContainerBuilderRef resContainer, ILazy <IResMemberLineDecl> resLine, SourceRange range, IResMemberRef memberRef) { var firstRef = (ResMethodRef)memberRef; var firstDecl = firstRef.Decl; var result = ResMethodDecl.Build( resContext.LazyFactory, resLine, range, firstDecl.Name, (builder) => { // \todo: More substitution needed? // \todo: Add back in inheritance-related validation checks? /* * if (firstRef.Body == null * && memberRefs.OfType<IResMethodRef>().Any((mr) => (mr.Body != null))) * { * throw new NotImplementedException(); * } */ var subst = new Substitution(); var newParams = new List <ResVarDecl>(); foreach (var oldParam in firstRef.Parameters) { var newParam = new ResVarDecl( range, oldParam.Name, oldParam.Type, oldParam.Decl.Flags); subst.Insert(oldParam.Decl, newParam); newParams.Add(newParam); } builder.Parameters = newParams; builder.ResultType = firstRef.ResultType; builder.LazyBody = resContext.LazyFactory.New(() => firstRef.Body == null ? null : firstRef.Body.Substitute(subst)); }); return(result); }
public ResMemberBind( SourceRange range, IResExp obj, IResMemberSpec memberSpec) { _range = range; _obj = obj; _memberSpec = memberSpec; _subst = new Substitution( memberSpec.Container.MemberTerm.Subst ); // \todo: Need to ensure "obj" is clone-able... // \todo: Need to iteratively re-subst... _subst.Insert( memberSpec.Container.ThisParameter, (r) => obj); }
public override IResExp Substitute(Substitution subst) { var newLabel = new ResLabel( _label.Range, _label.Name, _label.Type.Substitute(subst)); var newSubst = new Substitution(subst); newSubst.Insert(_label, newLabel); return new ResLabelExp( this.Range, newLabel, this.Body.Substitute(newSubst)); throw new NotImplementedException(); }
// ResMemberDecl public override IResMemberDecl CreateInheritedDeclImpl( ResolveContext resContext, IResContainerBuilderRef resContainer, ILazy <IResMemberLineDecl> resLine, SourceRange range, IResMemberRef memberRef) { var firstRef = (IResGenericRef)memberRef; var result = ResGenericDecl.Build( resContext.LazyFactory, resLine, range, firstRef.Decl.Name, (builder) => { var newParameters = new List <IResGenericParamDecl>(); var subst = new Substitution(); foreach (var p in firstRef.Parameters) { if (p is IResTypeParamRef) { var oldParameter = (IResTypeParamRef)p; var newParameter = new ResTypeParamDecl( oldParameter.Decl.Range, oldParameter.Name, oldParameter.Kind); newParameters.Add(newParameter); subst.Insert(oldParameter.Decl, (r) => new ResTypeVarRef(r, newParameter)); } else if (p is IResVarSpec) { var oldParameter = (IResVarSpec)p; var newParameter = new ResVarDecl( oldParameter.Decl.Range, oldParameter.Name, resContext.LazyFactory.New(() => oldParameter.Type.Substitute(subst)), oldParameter.Decl.Flags); newParameters.Add(newParameter); subst.Insert(oldParameter.Decl, (r) => new ResVarRef(r, newParameter)); } else { throw new NotImplementedException(); } } builder.Parameters = newParameters; var args = (from p in newParameters select p.MakeGenericArg()).ToArray(); var innerRef = firstRef.App(range, args); /* * var innerCategoryGroup = new ResMemberCategoryGroup( * result, * new ResMemberNameGroup(result, result.Name), * new ResMethodCategory()); * var innerLine = new ResMemberDeclLine( * innerCategoryGroup, * new ResLexicalID()); */ var thisGenericBuilderRef = new ResGenericBuilderRef( range, builder, resContainer); var innerDecl = CreateInheritedDecl( resContext, thisGenericBuilderRef, resLine, range, innerRef); builder.InnerDecl = innerDecl; }); return(result); }