Module: dfmc-projects Synopsis: DFMC project manager interface Author: Andy Armstrong, Roman Budzianowski Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND define class () constant slot context-interactive-sources-table :: = make(
); constant slot context-interactive-sources :: = make(); constant slot context-execution-context :: , required-init-keyword: execution-context:; slot context-last-transaction-id = #f; constant slot context-debug-target :: , required-init-keyword: debug-target:; end class ; define function project-target-execution-context (project :: , target :: ) => (ec :: false-or()); any?(method (c) target & c.context-debug-target == target & c end, project.project-execution-contexts) end function project-target-execution-context; define method project-canonical-source-records (project :: ) => (records :: ) let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; let context = project-target-execution-context(project, debug-target); if (context) let interactive-sources = context.context-interactive-sources; concatenate(#(), next-method(), interactive-sources) else next-method() end end method project-canonical-source-records; define method project-current-debug-target-setter (debug-target :: , project :: ) => (debug-target :: ) let workspace = project.project-workspace; if (debug-target = #f & ~project.%project-closed?) with-lock ($pm-lock) do(%project-close-interactive-context, project.all-used-projects); %project-close-interactive-context(p); end else debug-assert(project.ensure-project-database, "Cannot run application without %s.ddb present", p.project-library-name) end; workspace.workspace-debug-target := debug-target end method project-current-debug-target-setter; define function %project-close-interactive-context (project :: , #key context = #f) => () let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; let context = context | project-target-execution-context(project, debug-target); if (context) // TO DO: don't remove old records release-execution-context(context.context-execution-context); remove!(project.project-execution-contexts, context) end end function %project-close-interactive-context; define method project-close-compilation-contexts (project :: ) => () for (c :: in project.project-execution-contexts) %project-close-interactive-context(project, context: c); end; next-method() end method project-close-compilation-contexts; define function verify-execution-target (project :: ) => (context :: ) let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; debug-assert(debug-target, "Project Manager: No debug target set"); with-compiler-lock () project-target-execution-context(project, debug-target) | begin let context = project.project-current-compilation-context; let execution-context = establish-execution-context(context, debug-target); add!(project.project-execution-contexts, make(, execution-context: execution-context, debug-target: debug-target)); do(verify-execution-target, project.directly-used-projects); execution-context end; end end function verify-execution-target; define function project-execution-context (project :: ) => (context :: false-or()) let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; let context = project-target-execution-context(project, debug-target); context & context.context-execution-context end function project-execution-context; define function project-last-transaction-id (project :: ) => (id :: false-or()) let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; let context = project-target-execution-context(project, debug-target); context & context.context-last-transaction-id end function project-last-transaction-id; define method evaluate-expression (project :: , runtime-context :: , module :: , source :: ) => (id :: ) let context = verify-execution-target(project); let record = make(, project: project, module: module, source: as(, source)); let id = execute-source(context.context-execution-context, runtime-context, list(record)); // execution successful context.context-last-transaction-id := id; record.interactive-source-record-id := id; context.context-interactive-sources-table[id] := record; add!(context.context-interactive-sources, record); id end method evaluate-expression; define function parse-expression (project :: , runtime-context :: , module :: , source :: ) => (well? :: , warnings :: ) let context = verify-execution-target(project); let record = make(, project: project, module: module, source: as(, source)); source-complete?(context.context-execution-context, runtime-context, list(record)) end function parse-expression; define method project-id-interactive-record (project :: , id :: ) => (sr :: false-or()) any?(method (context :: ) element(context.context-interactive-sources-table, id, default: #f) end, project.project-execution-contexts) end method project-id-interactive-record; //--- What does this return? define method project-interactive-execution-notes (project :: , #key record-id) let workspace = project.project-workspace; let debug-target = workspace.workspace-debug-target; let context = project-target-execution-context(project, debug-target); context & execution-transaction-notes(context.context-execution-context, context.context-last-transaction-id) end method project-interactive-execution-notes; define method project-interaction-allowed? (project :: ) => (interactive? :: ) block () let context = verify-execution-target(project); execution-context-interactive?(context.context-execution-context) exception () #f end end method project-interaction-allowed?;