Giter Club home page Giter Club logo

roo's Introduction

Roo

Build Status

Roo is a imperitive programming language that takes concepts from functional programming. Its central goal is to avoid the kitchen-sink-esque hodgepodge of languages like C++, instead expressing logic through fewer, more powerful features.

Aims

  • No separation of definition and implementation (no headers)
  • Easier build process - nice source and dependency management
  • Safety - strong type-checking and powerful expression of programmer intent
  • Terse, expressive syntax - no extranious punctuation

It looks something like this:

#[Name(example)]

import Prelude

type color
{
  r : float
  g : float
  b : float
  a : float
}

fn PrintColor(color : color&)
{
  PrintFmt("Color: ({}, {}, {}, {})\n", color.r, color.g, color.b, color.a)
}

#[Entry]
fn Main() -> int
{
  #[Debug]
  Print("Hello, World!\n")

  // Make and print a color
  myColor : color{1.0f, 0.0f, 1.0f, 1.0f}
  PrintColor(myColor)

  return 0
}

Using the compiler

  • At the moment, The compiler can only produce executables usable on x86_64, System-V, ELF-compatible systems
  • (Temporary step) Run make prelude to build Prelude (our standard library)
  • Run ./roo to compile and link all the files in the current directory
  • Various DOT files will also be produced, which may be converted to PNG with dot -Tpng -o {file}.png {file}.dot

Contributing

Contributions are welcome. Current tasks and long-term goals can be found on the Trello. Please keep to the style of the existing code.

roo's People

Contributors

isaacwoods avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

Forkers

ajunlonglive

roo's Issues

Revamping the slot system

The slot system is a bit of a mess. We need to make the point and usage of slots clearer and add support for new, more powerful analysis techniques to aid register allocation.

  • Globalise control of DOT generation
  • Ensure only one slot per variable_def. Referenced by that variable_def and by the function_def
  • Get rid of tagging - it was badly thought out and no longer needed
  • Centralise creation, not left up to the AIR generation for individual nodes
  • Easier control of colorization (based on type, not on the shouldBeColored flag)
  • Easy access from a variable_def to its slot

Linking to external object files

We should be able to link against other ELF object files, handling relocations properly etc.

  • Open an external object file and validate that it can be linked against
  • Parse the section header
  • Read symbols from it and add them to our symbol table
  • Add any relocations in the object file to the list of relocations to be completed
  • Coalesce SYM_UNDs with their defined partners
  • Alter any relocations that made use of undefined symbols, pointing them towards the real definitions
  • Throw fatal errors for unresolved symbols
  • Create elf_things from parts of .text mapped as SYM_TYPE_FUNCTION
  • Update the old relocatable offsets into real virtual addresses in the symbols of linked-in functions
  • Find the parent elf_thing for external relocations
  • Correct external relocation offsets relative to their parent thing
  • Correctly do external relocations

Emitting ELF files is quite slow

Rewrite the process for writing ELFs:

  • Work out the final size for the ELF beforehand
  • mmap the output ELF and allocate the correct size for writing
  • memcpy the correct structures into place
  • Unmap and write the file

Printing strings

Print a string from Roo code using the bootstrap Print method.

  • Emit a .rodata section
  • Emit string constants into the .rodata section
  • Emit a symbol pointing to .rodata (Ndx = index of .rodata, value = 0)
  • Emit relocations into .rodata to fill in the addresses of strings

Our own linker

ld is being a bit of a pain in the ass. While this is almost definitely our fault, instead of being responsible and debugging it, we're going to build an entire linker instead.

  • Move ELF stuff into its own header

Working with the AST is a bit of a mess

Tagged unions has left the code less readable than desired, so it may be interesting to see if using an inheritance structure with dynamic dispatch would be better. Obviously this problem will be fixed in Roo by using templated variants, but in C++ this is obviously not possible.

This might also help with the problem of altering the AST being less than ideal (as highlighted in the mess that is the constant folder).

External Language Bindings

We should be able to link against C and other languages, as long as they are System-V compliant. We need a way of specifying how these functions should behave in Roo, which I'm thinking could be achieved with something a bit like a function prototype, marked with the #[Prototype] attribute. They'd look something like this:

#[Prototype]
fn Print(str : &string)
  • Parse a Prototype attribute
  • Parse a function prototype instead of a full function if attribute detected
  • Store function prototypes (like normal functions tho)
  • Emit correct function calls (much ado about mangling?) for prototypes
  • Emit a relocation for statically-linked function calls
  • Find the correct symbol to jump to in I_CALL handling

Fancy Error and Warning System

  • Define errors and warnings by code in the spec
  • Emit a warning or error by code in the parser etc.
  • Have standardized printing of errors and warnings
  • Turn off warnings by code with the program attribute #[IgnoreWarning({code})]

Proper register allocation

We need to write a proper register allocation algorithm now that we need to manage ABI calls etc. We are already doing a basic coloring of the interference graph, but it is neither optimized or guaranteed to be always correct.

December 4th 2016 - It's actually just totally broken. The actual algorithm routine is fairly okay, but in many non-trivial cases, the interference graph is totally wrong. We probably need to do full register allocation to get a decent solution.

  • Do liveness analysis on slots that are going to be colored
  • Add interferences based on whether variables are live at the same time

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.