[Gd-chatter] r11741 - trunk/fundev/sources/environment/dswank

hannes at gwydiondylan.org hannes at gwydiondylan.org
Sat Mar 22 02:31:02 CET 2008


Author: hannes
Date: Sat Mar 22 02:31:00 2008
New Revision: 11741

Added:
   trunk/fundev/sources/environment/dswank/dswank-console-compiler.dylan   (contents, props changed)
Modified:
   trunk/fundev/sources/environment/dswank/dswank-exports.dylan
   trunk/fundev/sources/environment/dswank/dswank.dylan
   trunk/fundev/sources/environment/dswank/dswank.lid
Log:
Job: fd
*dswank now talks to the compiler during listener-eval
*support for meta-dot (if a project has been opened manually)

thus:
meta-x slime-connect 127.0.0.1 3456
nil> open dswank
meta-x slime-mode
buffer dswank.dylan:
go anywhere, press meta-dot ~ voila, you're at the source of the definition


Added: trunk/fundev/sources/environment/dswank/dswank-console-compiler.dylan
==============================================================================
--- (empty file)
+++ trunk/fundev/sources/environment/dswank/dswank-console-compiler.dylan	Sat Mar 22 02:31:00 2008
@@ -0,0 +1,15 @@
+module: dswank
+
+define method start-compiler ()
+  let input-stream = make(<string-stream>, direction: #"input");
+  let output-stream = make(<string-stream>, direction: #"output");
+  make-environment-command-line-server
+    (input-stream:   input-stream,
+     output-stream:  output-stream);
+end;
+
+define function run-compiler (server, string :: <string>) => (res :: <collection>)
+  execute-command-line(server, string);
+  let res = stream-contents(server.server-output-stream);
+  split(res, '\n');
+end;

Modified: trunk/fundev/sources/environment/dswank/dswank-exports.dylan
==============================================================================
--- trunk/fundev/sources/environment/dswank/dswank-exports.dylan	(original)
+++ trunk/fundev/sources/environment/dswank/dswank-exports.dylan	Sat Mar 22 02:31:00 2008
@@ -5,6 +5,12 @@
   use io;
   use network;
   use lisp-reader;
+  use environment-commands;
+  use environment-protocols;
+  use commands;
+  use source-records;
+  use file-source-records;
+  use system;
 end library;
 
 define module dswank
@@ -14,4 +20,12 @@
   use streams;
   use standard-io;
   use sockets;
+  use environment-commands;
+  use environment-protocols;
+  use command-lines;
+  use commands;
+  use source-records;
+  use file-source-records;
+  use file-system;
+  use locators;
 end module;

Modified: trunk/fundev/sources/environment/dswank/dswank.dylan
==============================================================================
--- trunk/fundev/sources/environment/dswank/dswank.dylan	(original)
+++ trunk/fundev/sources/environment/dswank/dswank.dylan	Sat Mar 22 02:31:00 2008
@@ -3,6 +3,9 @@
 author: 
 copyright: 
 
+define thread variable *server* = start-compiler();
+define thread variable *package* = #f;
+
 define constant $emacs-commands = make(<table>);
 
 define macro emacs-command-definer
@@ -22,9 +25,11 @@
   // do funky stuff
   block()
     let function = $swank-functions[command.head];
+    *package* := package;
     let result = apply(function, command.tail);
     list(#":return", list(#":ok", result), request-id);
   exception(e :: <error>)
+    format(*standard-error*, "Received error during evalution:\n%=\n", e);
     list(#":return", #(#":abort"), request-id);
   end;
 end;
@@ -50,11 +55,56 @@
     #":lisp-implementation", #(#":type", "dylan",
                                #":name", "opendylan",
                                #":version", "1.0beta5"),
-    #":version", "2008-01-27");
+    #":version", "2008-03-18");
 end;
 
 define swank-function find-definitions-for-emacs (symbol-name)
-  list(list(symbol-name, #(#":file", "/home/andreas/trunk/fundev/sources/environment/dswank/dswank.dylan", #":position", 0)));
+  let project = open-projects()[0];
+  let library = #f;
+  let module = #f;
+  local method check-and-set-module (lib)
+          unless(module)
+            module := find-module(project, *package*, library: lib);
+            if (module)
+              library := lib;
+            end;
+          end;
+        end;
+  check-and-set-module(project-library(project));
+  do-project-used-libraries (check-and-set-module, project, project);
+
+  let env-obj = find-environment-object(project, symbol-name,
+                                        library: library,
+                                        module: module);
+
+  let location = environment-object-source-location(project, env-obj);
+
+  let source-name =
+    if (location)
+      let source-record = location.source-location-source-record;
+      select (source-record by instance?)
+        <file-source-record> =>
+          let location = source-record.source-record-location;
+          file-exists?(location) & locator-as-string(<byte-string>, location);
+        otherwise =>
+          source-record.source-record-name;
+      end;
+    end;
+  
+  let (name, lineno)
+    = source-line-location(location.source-location-source-record,
+                           location.source-location-start-line);
+  let column = location.source-location-start-column;
+
+  list(list(symbol-name,
+            list(#":location",
+                 list(#":file", as(<string>, source-name)),
+                 list(#":line", lineno, column),
+                 #())));
+end;
+
+define swank-function listener-eval (arg)
+  pair(#":values", run-compiler(*server*, arg))
 end;
 
 define function main()
@@ -64,14 +114,14 @@
   while(#t)
     let length = string-to-integer(read(stream, 6), base: 16);
     let line = read(stream, length);
-    format(*standard-error*, "%s\n", line);
+    format(*standard-error*, "read: %s", line);
     let expr = read-lisp(make(<string-stream>, direction: #"input", contents: line));
     let function = $emacs-commands[expr.head];
     let result = apply(function, expr.tail);
     let newstream = make(<string-stream>, direction: #"output");
     print-s-expression(newstream, result);
     let s-expression = stream-contents(newstream);
-    format(*standard-error*, "%s\n", s-expression);
+    format(*standard-error*, "write: %s\n", s-expression);
     let siz = integer-to-string(s-expression.size, base: 16, size: 6);
     format(stream, "%s%s", siz, s-expression);
   end;

Modified: trunk/fundev/sources/environment/dswank/dswank.lid
==============================================================================
--- trunk/fundev/sources/environment/dswank/dswank.lid	(original)
+++ trunk/fundev/sources/environment/dswank/dswank.lid	Sat Mar 22 02:31:00 2008
@@ -1,4 +1,5 @@
 library: dswank
 executable: dswank
 files: dswank-exports
+  dswank-console-compiler
   dswank



More information about the chatter mailing list