Giter Club home page Giter Club logo

igcc's People

Contributors

alexandru-dinu avatar andybalaam avatar kgashok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

igcc's Issues

PCH setup

One of the ways to cut down on the overhead of repeated compilation is to make a precompiled header. The current set up is basically ready: boilerplate.h is always included, and with bits/stdc++.h it's got almost the entire standard library.

In fact, bits/stdc++.h states plainly at the top:

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

That's how it's supposed to be used!


But how do we really do it?

  • The config file needs a new pch_command option to run gcc -x c++-header $header -o $pcheader. This helps interaction with #10.
  • Use -include (or -include-pch in clang) in the compiler invocation to get it to include. Doing it via command line lets us avoid writing to the igcc install directory, which can have permission issues. It does prevent users from opting out the boilerplate though.

C support

I would be interested to know how I can switch on pure C support. I managed to adjust the compiler settings in the config/config.yaml and adjusted the "sourcecode" which was weirdly not in a .yaml file under config but in libigcc/source_code.py

But after that there was weirdly zero output by the repl. I tried generic statements like 1+4 or foo() and also printf(foo) but none of theme produced any output. I guess this might be because I disabled the cryptic boilerplate.h?

boilerplate.h not found

When I try to run anything (after writing .h), I get the following error:

<stdin>:1:10: fatal error: boilerplate.h: No such file or directory
compilation terminated.

This happened when I ran #include <iostream> and printf( "h" );.

Steps to reproduce:

  1. run .h
  2. run #include <iostream>
  3. see error and run .e
  4. run printf( "any string" );
  5. same as 3

Add multi-line support

Right now, errors can be tolerated until the code compiles.
However, this is both ugly and inefficient (as gcc is invoked after each line).

Proposal:

  • add multi-line support, enabled by default
  • maybe enclosed in .{, .} - similar to ghci
$ ./igcc -I libigcc
[1] .{
 >    int x = 0;
 >    for (int i = 1; i < 5; ++i) {
 >        x += i;
 >    }
 >  .}
[2] cout << x << endl;
10

Don't accept new input until an error is resolved

[  1] igcc> 1/0
Compile error - type .e to see it OR disregard if multi-line statement(s)

[  2] igcc> .e
<stdin>: In function ‘int main()’:
<stdin>:6:6: warning: division by zero [-Wdiv-by-zero]
<stdin>:6:8: error: expected ‘;’ before ‘return’
<stdin>:6:6: warning: statement has no effect [-Wunused-value]


[  2] igcc> int x = 1;
Compile error - type .e to see it OR disregard if multi-line statement(s)

[  3] igcc> .e
<stdin>: In function ‘int main()’:
<stdin>:6:6: warning: division by zero [-Wdiv-by-zero]
<stdin>:6:8: error: expected ‘;’ before ‘int’
<stdin>:6:6: warning: statement has no effect [-Wunused-value]

Better testing

The original tests are a bit messy and disorganized.
We should switch to pytest and make it part of the CI GitHub workflow.

  • devise initial tests
  • integrate with the GitHub workflow
  • add coverage badge

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.