public Nothing EntryPoint(IEntryPointDefinition entryPointDefinition) { if (entryPointDefinition.Scope.Members.Values.Any(x => x.Static)) { throw new Exception("cant be static at this time"); } var next = Push(entryPointDefinition); entryPointDefinition.ParameterDefinition.Convert(next); if (entryPointDefinition.OutputType.SafeIs(out IInterfaceType type)) { type.Convert(next); } foreach (var entry in entryPointDefinition.Scope.Members.Values.Select(x => x.Value).Except(new[] { entryPointDefinition.ParameterDefinition })) { lookup.AddLocal(OrType.Make <IEntryPointDefinition, IImplementationDefinition, IInternalMethodDefinition, IRootScope>(entryPointDefinition), entry); } lookup.AddArgument(OrType.Make <IImplementationDefinition, IInternalMethodDefinition, IEntryPointDefinition>(entryPointDefinition), entryPointDefinition.ParameterDefinition); if (extensionLookup.entryPointLookup.TryGetValue(entryPointDefinition, out var found)) { foreach (var member in found.closureMember.Keys) { lookup.AddField(OrType.Make <IEntryPointDefinition, IImplementationDefinition, IInternalMethodDefinition>(entryPointDefinition), member); } } next.Walk(entryPointDefinition.Body); return(new Nothing()); }
public IReadOnlyList <IMemberDefinition> EntryPoint(IEntryPointDefinition entryPointDefinition) { UpdateDefinedBy(entryPointDefinition.Scope, OrType.Make <IInternalMethodDefinition, IImplementationDefinition, IEntryPointDefinition, IBlockDefinition, IRootScope, IObjectDefiniton>(entryPointDefinition)); // an entry point totally has a closure: // x := 2; // entrypoint { // x + 1 > some-method; // } return(extensionLookup.entryPointLookup.GetOrAdd(entryPointDefinition, () => { var implementationClosure = Walk(entryPointDefinition.Body); return new WhoDefinedMember(implementationClosure .Except(staticMembers) .Except(entryPointDefinition.Scope.Members.Select(x => x.Value.Value)) .ToDictionary(x => x, x => definedBy[x])); }).closureMember.Keys.ToArray()); }
IInterpetedOperation IOpenBoxesContext <IInterpetedOperation> .EntryPoint(IEntryPointDefinition codeElement) { if (backing.TryGetValue(codeElement, out var res)) { return(res); } else { var op = new InterpetedEntryPointDefinition(); backing.Add(codeElement, op); op.Init( codeElement.Body.Select(x => x.Convert(this)).ToArray(), new InterpetedScopeTemplate(codeElement.Scope, codeElement.Scope.ToVerifiableType())); if (EntryPoint == null) { EntryPoint = op; } else { throw new Exception("entry point already defined"); } return(op); } }
public static IRootScope CreateAndBuild(IFinalizedScope scope, IReadOnlyList <IAssignOperation> assignments, IEntryPointDefinition entryPoint) { var(x, y) = Create(); y.Build(scope, assignments, entryPoint); return(x); }
public void Build(IFinalizedScope scope, IReadOnlyList <IAssignOperation> assignments, IEntryPointDefinition entryPoint) { buildableScope.Set(scope); buildableAssignments.Set(assignments); buildableEntryPoint.Set(entryPoint); type = InterfaceType.CreateAndBuild(scope.Members.Values.Select(x => MemberDefinition.CreateAndBuild(x.Value.Key, x.Value.Type, x.Value.Access)).ToList()); }