public ISetUpResult <IBox <WeakTryAssignOperation>, Tpn.IValue> Run(Tpn.IStaticScope scope, ISetUpContext context) { var box = new Box <IReadOnlyList <IOrType <IBox <IFrontendCodeElement>, IError> > >(); // we create a new scope because the member we are assigning in to only exists in that scope // 5 is Cat c { ... } // is really // { 5 is Cat c { ... }} var myScope = context.TypeProblem.CreateScope(scope, new WeakBlockDefinitionConverter(box)); var nextLeft = left.TransformInner(x => x.Run(myScope, context.CreateChildContext(this))); var nextRight = right.TransformInner(x => x.Run(myScope, context.CreateChildContext(this))); var nextblock = block.TransformInner(x => x.Run(myScope, context.CreateChildContext(this))); if (nextLeft.Is1(out var nextLeft1) && nextLeft1.SetUpSideNode.Is1(out var node1) && nextRight.Is1(out var nextRight1) && nextRight1.SetUpSideNode.Is1(out var node2)) { if (node1 is not Tpn.ICanAssignFromMe canAssignFromMe) { // todo I need real error handling // probably I need somewhere to stuff additional errors throw new NotImplementedException($"can not assign from {nextLeft1.SetUpSideNode}"); } if (node2 is not Tpn.ICanBeAssignedTo canBeAssignedTo) { // todo I need real error handling throw new NotImplementedException($"can not assign to {nextRight1.SetUpSideNode}"); } }
public WeakRootScope(IOrType <HasMembersType, IError> returns, Box <IReadOnlyList <IOrType <IBox <WeakAssignOperation>, IError> > > assigns, Box <IOrType <IBox <WeakEntryPointDefinition>, IError> > EntryPoint) { this.returns = returns ?? throw new ArgumentNullException(nameof(returns)); Scope = returns.TransformInner(x => x.weakScope); this.EntryPoint = EntryPoint ?? throw new ArgumentNullException(nameof(EntryPoint)); Assignments = assigns ?? throw new ArgumentNullException(nameof(assigns)); }
public WeakObjectDefinition(IOrType <HasMembersType, IError> type, IBox <IReadOnlyList <IOrType <IBox <WeakAssignOperation>, IError> > > assigns) { Scope = type?.TransformInner(x => x.weakScope) ?? throw new ArgumentNullException(nameof(type)); Assignments = assigns ?? throw new ArgumentNullException(nameof(assigns)); returns = type; }
public IBox <TFrontendCodeElement> Run(Tpn.TypeSolution context, IEnumerable <Tpn.ITypeProblemNode> stack) { var res = make( left.TransformInner(x => x.Run(context, stack)), right.TransformInner(x => x.Run(context, stack))); return(res); }
public WeakGenericTypeDefinition( IIsPossibly <IOrType <NameKey, ImplicitKey> > key, IOrType <HasMembersType, IError> type, IOrType <IGenericTypeParameterPlacholder, IError>[] TypeParameterDefinitions) { this.TypeParameterDefinitions = TypeParameterDefinitions ?? throw new ArgumentNullException(nameof(TypeParameterDefinitions)); Key = key ?? throw new ArgumentNullException(nameof(key)); this.type = type ?? throw new ArgumentNullException(nameof(type)); Scope = type.TransformInner(x => x.weakScope); }
public ISetUpResult <IBox <WeakRootScope>, Tpn.TypeProblem2.Object> Run(Tpn.IStaticScope scope, ISetUpContext context) { //scope = scope.EnterInitizaionScopeIfNessisary(); //if (!(scope is Tpn.IScope runtimeScope)) //{ // throw new NotImplementedException("this should be an IError"); //} //var assignmentsBox = new Box<IReadOnlyList<IOrType<IResolve<IBox<WeakAssignOperation>>, IError>>>(); //var entryBox = new Box<IOrType<IResolve<IBox<WeakEntryPointDefinition>>, IError>>(); //var myScope = context.TypeProblem.CreateObjectOrModule(context.TypeProblem.ModuleRoot, key, new WeakRootConverter(assignmentsBox, entryBox), new WeakScopeConverter()); // {6B83A7F1-0E28-4D07-91C8-57E6878E97D9} // module has similar code //foreach (var element in elements) //{ // element.Switch( // y => // { // list.Add(OrType.Make<IResolve<IBox<IFrontendCodeElement>>, IError>(y.Run(myScope, context).Resolve)); // }, // y => // { // // it is a bit weird that types are not used at all // y.Run(myScope, context); // }, // y => // { // // this is also a bit wierd, these errors are anything that was not parsed // // they are not really related to the assignments they are bing placed next to // list.Add(OrType.Make<IResolve<IBox<IFrontendCodeElement>>, IError>(y)); // }); //} var nextElements = elements.Select(x => x.TransformInner(y => y.Run(myScope, context.CreateChildContext(this)).Resolve)).ToArray(); var nextEntry = entry.TransformInner(y => y.Run(myScope, context.CreateChildContext(this)).Resolve); var ranTypes = types.Select(x => x.TransformInner(y => y.Run(myScope, context.CreateChildContext(this)).Resolve)).ToArray(); var ranGenericTypes = genericTypes.Select(x => x.TransformInner(y => y.Run(myScope, context.CreateChildContext(this)).Resolve)).ToArray(); //var value = context.TypeProblem.CreateValue(runtimeScope, key, new PlaceholderValueConverter()); // ugh! an object is a type // return(new SetUpResult <IBox <WeakRootScope>, Tpn.TypeProblem2.Object>(new ResolveReferanceRootScope(myScope, ranTypes, ranGenericTypes, nextElements, nextEntry, assignmentsBox, entryBox), OrType.Make <Tpn.TypeProblem2.Object, IError>(myScope))); }
public ISetUpResult <IBox <TFrontendCodeElement>, Tpn.IValue> Run(Tpn.IStaticScope scope, ISetUpContext context) { // return should never be in an object init // but other trailing operations might if (intoInitScope) { scope = scope.EnterInitizaionScopeIfNessisary(); } var nextLeft = left.TransformInner(x => x.Run(scope, context.CreateChildContext(this))); return(new SetUpResult <IBox <TFrontendCodeElement>, Tpn.IValue>( new TrailingResolveReferance <TFrontendCodeElement, TCodeElement>(nextLeft.TransformInner(x => x.Resolve), make), getReturnedValue(scope, context, nextLeft))); }
// do these really need to be IBox? they seeme to generally be filled... // mayble IPossibly... public IBox <WeakRootScope> Run(Tpn.TypeSolution context, IEnumerable <Tpn.ITypeProblemNode> stack) { assignmentsBox.Fill(nextElements.Select(x => x.TransformInner(y => y.Run(context, stack.Add(myScope)))).ToArray()); entryBox.Fill(nextEntry.TransformInner(x => x.Run(context, stack.Add(myScope)))); ranTypes.Select(x => x.TransformInner(y => y.Run(context, stack.Add(myScope)))).ToArray(); ranGenericTypes.Select(x => x.TransformInner(y => y.Run(context, stack.Add(myScope)))).ToArray(); var objectOr = myScope.Converter.Convert(context, myScope, stack); if (objectOr.Is2(out var v2)) { return(new Box <WeakRootScope>(v2)); } throw new Exception("wrong or"); }
public ISetUpResult <IBox <TFrontendCodeElement>, Tpn.IValue> Run(Tpn.IStaticScope scope, ISetUpContext context) { if (intoInitScope) { scope = scope.EnterInitizaionScopeIfNessisary(); } var nextLeft = left.TransformInner(x => x.Run(scope, context.CreateChildContext(this))); var nextRight = right.TransformInner(x => x.Run(scope, context.CreateChildContext(this))); var value = keyMaker(scope, context.CreateChildContext(this), nextLeft, nextRight); return(new SetUpResult <IBox <TFrontendCodeElement>, Tpn.IValue>(new BinaryResolveReferance <TFrontendCodeElement, TCodeElement>( nextLeft.TransformInner(x => x.Resolve), nextRight.TransformInner(x => x.Resolve), make), value)); }
public ISetUpResult <IBox <WeakPathOperation>, Tpn.TypeProblem2.Member> Run(Tpn.IStaticScope scope, ISetUpContext context) { scope = scope.EnterInitizaionScopeIfNessisary(); var nextLeft = left.TransformInner(x => x.Run(scope, context.CreateChildContext(this))); var member = nextLeft.SwitchReturns( good => name.SwitchReturns( actualName => { if (good.SetUpSideNode.Is1(out var nodeLeft) && nodeLeft is Tpn.IValue value) { return(OrType.Make <Tpn.TypeProblem2.Member, IError>(context.TypeProblem.CreateHopefulMember( value, new NameKey(actualName)))); }
public IBox <WeakPathOperation> Run(Tpn.TypeSolution context, IEnumerable <Tpn.ITypeProblemNode> stack) { var leftRes = left.TransformInner(x => x.Run(context, stack)); var res = new Box <WeakPathOperation>(new WeakPathOperation( leftRes, member.SwitchReturns( x => OrType.Make <IBox <IFrontendCodeElement>, IError>(new FuncBox <IFrontendCodeElement>(() => { // TODO // I don't I should need to ask the solution for the member def, the left's return type should give me that // why doesn't TryGetMember return a member definition! // probably because of Ortypes // I thinkg TypeSolution TryGetMember is really just for TypeProblem2.Method and TypeProblem2.Scope // maybe I am thinking about this wrong and scopeCache only need to exist during TypeSolution's constructor var returns = leftRes.Is1OrThrow().GetValue().CastTo <IReturn>().Returns().Is1OrThrow(); // smells if (returns.SafeIs(out Tac.SyntaxModel.Elements.AtomicTypes.RefType refType)) { returns = refType.inner.Is1OrThrow(); } var memberDef = returns.TryGetMember(key, new List <(IFrontendType <IVerifiableType>, IFrontendType <IVerifiableType>)>()); //context.TryGetMember(,key) return(new WeakMemberReference(new Box <IOrType <WeakMemberDefinition, IError> >(memberDef.Is1OrThrow()))); //WeakMemberReference memberRef = leftRes.Is1OrThrow().GetValue().CastTo<WeakMemberReference>(); //var memberDef = memberRef.MemberDefinition.GetValue().Type.GetValue().Is1OrThrow().TryGetMember(key, new List<(IFrontendType<IVerifiableType>, IFrontendType<IVerifiableType>)>()); ////context.TryGetMember(,key) //return new WeakMemberReference(new Box<WeakMemberDefinition>(memberDef.Is1OrThrow().Is1OrThrow())); })), y => OrType.Make <IBox <IFrontendCodeElement>, IError>(Error.Cascaded("", y))))); return(res); }