* module/mes/M1.mes (object->M1): Add file-name parameter.
(define (stderr string . rest)
(apply logf (cons* (current-error-port) string rest)))
(define (stderr string . rest)
(apply logf (cons* (current-error-port) string rest)))
-(define (objects->M1 objects)
- ((compose object->M1 merge-objects) objects))
+(define (objects->M1 file-name objects)
+ ((compose (cut object->M1 file-name <>) merge-objects) objects))
-(define (object->elf o)
- ((compose M1->elf object->M1) o))
+(define (object->elf file-name o)
+ ((compose M1->elf (cut object->M1 file-name <>)) o))
-(define (objects->elf objects)
- ((compose M1->elf object->M1 merge-objects) objects))
+(define (objects->elf file-name objects)
+ ((compose M1->elf (cut object->M1 file-name <>) merge-objects) objects))
(define (merge-objects objects)
(let loop ((objects (cdr objects)) (object (car objects)))
(define (merge-objects objects)
(let loop ((objects (cdr objects)) (object (car objects)))
(display sep))
(loop (cdr o)))))
(display sep))
(loop (cdr o)))))
+(define (object->M1 file-name o)
(stderr "dumping M1: object\n")
(let* ((functions (assoc-ref o 'functions))
(function-names (map car functions))
(stderr "dumping M1: object\n")
(let* ((functions (assoc-ref o 'functions))
(function-names (map car functions))
- (file-name (car (or (assoc-ref o 'file-names) function-names)))
(globals (assoc-ref o 'globals))
(global-names (map car globals))
(strings (filter (lambda (g) (and (pair? g) (eq? (car g) #:string))) global-names)))
(globals (assoc-ref o 'globals))
(global-names (map car globals))
(strings (filter (lambda (g) (and (pair? g) (eq? (car g) #:string))) global-names)))
(let* ((options (parse-opts args))
(files (option-ref options '() '()))
(file (car files))
(let* ((options (parse-opts args))
(files (option-ref options '() '()))
(file (car files))
+ (file-name (car (string-split (basename file) #\.)))
(preprocess? (option-ref options 'E #f))
(compile? (option-ref options 'c #f))
(debug-info? (option-ref options 'g #f))
(preprocess? (option-ref options 'E #f))
(compile? (option-ref options 'c #f))
(debug-info? (option-ref options 'g #f))
(if (and (not compile?)
(not preprocess?)) (set-port-encoding! (current-output-port) "ISO-8859-1"))
(cond ((pair? objects) (let ((objects (map read-object objects)))
(if (and (not compile?)
(not preprocess?)) (set-port-encoding! (current-output-port) "ISO-8859-1"))
(cond ((pair? objects) (let ((objects (map read-object objects)))
- (if compile? (objects->M1 objects)
- (objects->elf objects))))
+ (if compile? (objects->M1 file-name objects)
+ (objects->elf file objects))))
((pair? asts) (let* ((infos (map main:ast->info asts))
(objects (map info->object infos)))
((pair? asts) (let* ((infos (map main:ast->info asts))
(objects (map info->object infos)))
- (if compile? (objects->M1 objects)
- (objects->elf objects))))
+ (if compile? (objects->M1 file-name objects)
+ (objects->elf file objects))))
((pair? sources) (if preprocess? (map (source->ast pretty-print/write defines includes) sources)
(let* ((infos (map (source->info defines includes) sources))
(objects (map info->object infos)))
((pair? sources) (if preprocess? (map (source->ast pretty-print/write defines includes) sources)
(let* ((infos (map (source->info defines includes) sources))
(objects (map info->object infos)))
- (if compile? (objects->M1 objects)
- (objects->elf objects))))))))))
+ (if compile? (objects->M1 file-name objects)
+ (objects->elf file objects))))))))))
(main (command-line))
'done
(main (command-line))
'done