public void MergeWith(CodeWorkspaceImpl ws, IFunctionDefinerScope h, FunctionDefiner other) { foreach (var kv in other._funcs) { if (!_funcs.TryGetValue(kv.Key, out var my)) { my = new FunctionScopeImpl(ws, h); _funcs.Add(kv.Key, my); } my.MergeWith(kv.Value); } }
public FunctionScopeImpl Create(CodeWorkspaceImpl ws, IFunctionDefinerScope h, Action <IFunctionScope> header) { if (header == null) { throw new ArgumentNullException(nameof(header)); } FunctionScopeImpl f = new FunctionScopeImpl(ws, h); header(f); f.Initialize(); _funcs.Add(f.Name, f); ws.OnFunctionCreated(f); return(f); }
public FunctionScopeImpl Create(CodeWorkspaceImpl ws, IFunctionDefinerScope h, FunctionDefinition def) { if (def == null) { throw new ArgumentNullException(nameof(def)); } if (_funcs.ContainsKey(def.Key)) { throw new ArgumentException($"Funcion or constructor with key {def.Key} already exists.", nameof(def)); } FunctionScopeImpl f = new FunctionScopeImpl(ws, h, def); _funcs.Add(f.Name, f); return(f); }
internal void MergeWith(FunctionScopeImpl other) { Debug.Assert(other != null); CodePart.MergeWith(other.CodePart); _funcs.MergeWith(Workspace, this, other._funcs); }
internal void OnFunctionCreated(FunctionScopeImpl f) => FunctionCreated?.Invoke(f);