mescc: Add dir to include path.

* module/mescc/mescc.scm (preprocess): Add dir to include path.
(c->info): Likewise.
* scaffold/tests/08-assign.c: New file.
This commit is contained in:
Jan Nieuwenhuizen 2018-08-15 19:11:54 +02:00
parent 3f45b7f92b
commit fe60c924dd
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
7 changed files with 54 additions and 10 deletions

View file

@ -135,6 +135,9 @@ clean-go:
check:
./check.sh
check-mescc:
./pre-inst-env build-aux/check-mescc.sh
# Mes does not feature post-install checks yet, so we're great!
installcheck:
true

View file

@ -49,6 +49,8 @@ t
04-call-0
05-call-1
06-call-!1
07-include
08-assign
10-if-0
11-if-1
12-if-==

View file

@ -26,15 +26,16 @@ fi
export CC
export CC CFLAGS
export CC32
export CC32_CPPFLAGS
export CC64
export CC64_CPPFLAGS
export CC_CFLAGS
export CC_CFLAGS
export CC_CPPFLAGS
export CC_CPPFLAGS
export CFLAGS
export CPPFLAGS
export CPPFLAGS
export GUILE
export GUILE_LOAD_COMPILED_PATH
export GUILE_LOAD_PATH
export HEX2
export HEX2FLAGS
export LIBC
@ -42,6 +43,7 @@ export M1
export M1FLAGS
export MES
export MES_CFLAGS
export MES_CPPFLAGS
export MES_LIBS
export TCC

View file

@ -26,7 +26,7 @@ prefix=${prefix-@prefix@}
MES_PREFIX=${MES_PREFIX-${srcdest}mes}
export MES_PREFIX
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/module${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_COMPILED_PATH="$abs_top_builddir/scripts:$abs_top_builddir/module${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
GUILE_LOAD_PATH="module:mes:$abs_top_srcdir/guix${GUILE_LOAD_PATH:+:}$GUILE_LOAD_PATH"
if [ -n "$srcdest" ]; then
GUILE_LOAD_PATH="${srcdest}module:${srcdest}mes:$GUILE_LOAD_PATH"

View file

@ -38,15 +38,17 @@
(GUILE-with-output-to-file file-name thunk)))
(define (mescc:preprocess options)
(let* ((defines (reverse (filter-map (multi-opt 'define) options)))
(includes (reverse (filter-map (multi-opt 'include) options)))
(pretty-print/write (string->symbol (option-ref options 'write (if guile? "pretty-print" "write"))))
(let* ((pretty-print/write (string->symbol (option-ref options 'write (if guile? "pretty-print" "write"))))
(pretty-print/write (if (eq? pretty-print/write 'pretty-print) pretty-print write))
(files (option-ref options '() '("a.c")))
(input-file-name (car files))
(ast-file-name (cond ((and (option-ref options 'preprocess #f)
(option-ref options 'output #f)))
(else (replace-suffix input-file-name ".E"))))
(dir (dirname input-file-name))
(defines (reverse (filter-map (multi-opt 'define) options)))
(includes (reverse (filter-map (multi-opt 'include) options)))
(includes (cons dir includes))
(prefix (option-ref options 'prefix "")))
(with-output-to-file ast-file-name
(lambda _ (for-each (cut c->ast prefix defines includes write <>) files)))))
@ -74,9 +76,11 @@
((.E? file-name) (E->info options file-name))))
(define (c->info options file-name)
(let ((defines (reverse (filter-map (multi-opt 'define) options)))
(includes (reverse (filter-map (multi-opt 'include) options)))
(prefix (option-ref options 'prefix "")))
(let* ((defines (reverse (filter-map (multi-opt 'define) options)))
(includes (reverse (filter-map (multi-opt 'include) options)))
(dir (dirname file-name))
(includes (cons dir includes))
(prefix (option-ref options 'prefix "")))
(with-input-from-file file-name
(cut c99-input->info #:prefix prefix #:defines defines #:includes includes))))

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,32 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int a;
int b;
int c;
a = 2;
b = -2;
c = a + b;
asm ("nop");
return c;
}