ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Ivan Zakharyaschev <imz@altlinux.org>
To: devel@lists.altlinux.org
Subject: Re: [devel] re-writing GNU C extensions (part1)
Date: Mon, 11 Jan 2016 21:21:45 +0300 (MSK)
Message-ID: <alpine.LFD.2.20.1601112119330.4319@ovicaa.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.20.1601111147090.4319@ovicaa.localdomain>

[-- Attachment #1: Type: text/plain, Size: 6180 bytes --]

Вот продолжение -- промежуточный этап (пока не очень полезный)
создания переписывателя GNU C extensions.

На этом этапе он должен ставить вложенные функции на верхний уровень
(без какой-либо проверки и переписывания параметров и т.п.; но с точки
зрения внутреннего устройства это приближает к реализации цели).

Представлен в репозитории:

http://hub.darcs.net/imz/language-c_1_process_analyze-printAST

(1 -- по номеру сообщения; в предыдущем сообщении уже было в основном
описано, как производить его запуск и пр. это сообщение сохранено как
[ann1.md](http://hub.darcs.net/imz/cuglify/browse/ann1.md).)

Сборка:
=======

На этот раз изменённую библиотеку стоит поставить в свой отдельный
sandbox, собрать с ней examples/Process (в этом случае такой порядок
действий darcs проверен, а при другом можно наткнуться на
неприятности, к сожаленью):

     [imz@vb2 ~]$ cd public/cuglify-WIP/
     [imz@vb2 cuglify-WIP]$ darcs clone language-c_process_analyze-printAST 
language-c_1_process_analyze-printAST
     [imz@vb2 cuglify-WIP]$ cd language-c_1_process_analyze-printAST
     [imz@vb2 language-c_1_process_analyze-printAST]$ darcs pull -a 
http://hub.darcs.net/imz/language-c_1_process_analyze-printAST
     [imz@vb2 language-c_1_process_analyze-printAST]$ cabal sandbox init
     [imz@vb2 language-c_1_process_analyze-printAST]$ cabal install
     [imz@vb2 language-c_1_process_analyze-printAST]$ cabal exec -- make -C 
examples Process

Тестирование:
=============

     [imz@vb2 language-c_1_process_analyze-printAST]$ cd ../cuglify/
     [imz@vb2 cuglify]$ ./run-tests.sh 
../language-c_1_process_analyze-printAST/examples/Process
     PROCESSING ex-nested.c...
     * with gcc -c:
     0
     * with ../language-c_1_process_analyze-printAST/examples/Process:
     int g(int x)
     {
         return b + x + a;
     }
     void f(int a)
     {
         int b = 5;
         g(0);
         g(1);
         g(2);
     }
     0
     * diff against gcc -E:
     --- /dev/fd/63	2016-01-11 21:09:08.920889328 +0300
     +++ /dev/fd/62	2016-01-11 21:09:08.920889328 +0300
     @@ -1,11 +1,10 @@
     -# 1 "ex-nested.c"
     -# 1 "<command-line>"
     -# 1 "ex-nested.c"
     -void f(int a) {
     -  int b = 5;
     -  int g(int x) {
     +int g(int x)
     +{
          return b + x + a;
     -  }
     +}
     +void f(int a)
     +{
     +    int b = 5;
        g(0);
        g(1);
        g(2);
     TEST OK on ex-nested.c
     PROCESSING ex-nested_typemismatch.c...
     * with gcc -c:
     ex-nested_typemismatch.c: In function ‘f’:
     ex-nested_typemismatch.c:7:4: error: called object ‘b’ is not a 
function
     1
     * with ../language-c_1_process_analyze-printAST/examples/Process:
     Process: user error (ex-nested_typemismatch.c:7: (column 3) [ERROR] 
>>> AST invariant violated
       attempt to call non-function of type int
     )
     1
     TEST OK on ex-nested_typemismatch.c
     PROCESSING ex-nested_undef.c...
     * with gcc -c:
     0
     * with ../language-c_1_process_analyze-printAST/examples/Process:
     ex-nested_undef.c:7: (column 3) [WARNING]  >>> AST invariant violated
       unknown function: h

     int g(int x)
     {
         return b + x + a;
     }
     void f(int a)
     {
         int b = 5;
         g(0);
         h(1);
         g(2);
     }
     0
     * diff against gcc -E:
     ex-nested_undef.c:7: (column 3) [WARNING]  >>> AST invariant violated
       unknown function: h

     --- /dev/fd/63	2016-01-11 21:09:09.069878241 +0300
     +++ /dev/fd/62	2016-01-11 21:09:09.070878166 +0300
     @@ -1,11 +1,10 @@
     -# 1 "ex-nested_undef.c"
     -# 1 "<command-line>"
     -# 1 "ex-nested_undef.c"
     -void f(int a) {
     -  int b = 5;
     -  int g(int x) {
     +int g(int x)
     +{
          return b + x + a;
     -  }
     +}
     +void f(int a)
     +{
     +    int b = 5;
        g(0);
        h(1);
        g(2);
     TEST OK on ex-nested_undef.c
     PROCESSING ex-nested-with-id-collisions.c...
     * with gcc -c:
     ex-nested-with-id-collisions.c: In function ‘g’:
     ex-nested-with-id-collisions.c:10:5: warning: return makes integer 
from pointer without a cast [enabled by default]
     0
     * with ../language-c_1_process_analyze-printAST/examples/Process:
     void f(int x);
     void g(int x);
     void h(int x);
     int b = 11;
     int g(int x)
     {
         return f + x + a;
     }
     void f(int a)
     {
         int b = 5;
         g(0);
         g(1);
         g(2);
     }
     void f(int y);
     void g(int y);
     void h(int y);
     0
     * diff against gcc -E:
     --- /dev/fd/63	2016-01-11 21:09:09.178870130 +0300
     +++ /dev/fd/62	2016-01-11 21:09:09.178870130 +0300
     @@ -1,23 +1,18 @@
     -# 1 "ex-nested-with-id-collisions.c"
     -# 1 "<command-line>"
     -# 1 "ex-nested-with-id-collisions.c"
      void f(int x);
      void g(int x);
      void h(int x);
     -
      int b = 11;
     -
     -void f(int a) {
     -  int b = 5;
     -  int g(int x) {
     +int g(int x)
     +{
          return f + x + a;
     -  }
     -
     +}
     +void f(int a)
     +{
     +    int b = 5;
        g(0);
        g(1);
        g(2);
      }
     -
      void f(int y);
      void g(int y);
      void h(int y);
     TEST OK on ex-nested-with-id-collisions.c
     [imz@vb2 cuglify]$

Вопросы:
========

Остаются вопросы помимо реализации задуманного преобразования, как я
писал, про встройку программы с таким интерфейсом в gcc, clang и т.п.,
обнаружение ошибок.

Best regards,
Ivan

  reply	other threads:[~2016-01-11 18:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  8:48 [devel] re-writing GNU C extensions (part0) Ivan Zakharyaschev
2016-01-11 18:21 ` Ivan Zakharyaschev [this message]
2016-01-12 20:28   ` [devel] re-writing GNU C extensions (part1) imz
2016-01-20 10:28     ` imz
2016-01-27 17:59   ` [devel] re-writing GNU C; part1.3.1: how to apply Ivan Zakharyaschev
2016-01-27 18:04     ` [devel] re-writing GNU C; part1.3.2: how to apply (WIP) Ivan Zakharyaschev
2016-02-09 18:29   ` [devel] re-writing GNU C; part1.4: .i bug fixed Ivan Zakharyaschev
2016-02-10 10:30     ` Ivan Zakharyaschev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.20.1601112119330.4319@ovicaa.localdomain \
    --to=imz@altlinux.org \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git