Giter Site home page Giter Site logo

rock's Introduction

Build Status

rock

rock is an ooc compiler written in ooc - in other words, it's where things begin to become really exciting.

it has been bootstrapping since April 22, 2010 under Gentoo, Ubuntu, Arch Linux, Win32, OSX...

Prerequisites

You need the following packages when building rock:

  • GNU Make (make or gmake, depending on your operating system)
  • boehm-gc
  • tar (for extracting the C sources)
  • bzip2 (used by tar)

Get started

Run make rescue and you're good.

Wait, what?

make rescue downloads a set of C sources, compiles them, uses them to compile your copy of rock, and then uses that copy to recompile itself

Then you'll have a 'rock' executable in bin/rock. Add it to your PATH, symlink it, copy it, just make sure it can find the SDK!

Install

See the INSTALL file

To switch to the most recent git, read ReleaseToGit

License

rock is distributed under the MIT license, see LICENSE for details.

Boehm GC sources are vendored, it is distributed under an X11/MIT-like license, see libs/sources/LICENSE for details.

rock's People

Contributors

nddrylliog avatar alexnask avatar fredreichbier avatar fasterthanlime avatar showstopper avatar horasal avatar mt2d2 avatar joshthecoder avatar roja avatar nilium avatar ycros avatar causal-agent avatar plichard avatar mickael9 avatar rofl0r avatar metal3d avatar nikobordx avatar danopia avatar micrypt avatar ahamid avatar davidhesselbom avatar ds84182 avatar einat avatar refi64 avatar

Stargazers

 avatar

rock's Issues

C-Callback function?

Now time it seems that we can noly define the callback function by

foo: func(w: window*, func(Int)->Int) -> func(Int)->Int

and it sucks with extern keyword. Rock will report need resolve args error.

SDK less depend on GC

SDK should also work when gc is disabled.

Providing a general memory API such as AllocMem/ReallocMem/FreeMem instead of directly using GC_Alloc?

Unexpected setter call in cover.

test/text/base64 reported in #8

someData := gc_malloc(Octet size*4) as Octet*
someData[0] = 0x55
someData[1] = 0xfa

leads segmental error. Fancy trace reported a setlength call after [1] is setted.

Unwrap Array in foreach?

for( (i,j) in [0,1,2]){
    (i==j) toString() println()
}

-> Error no such function iterator() for Int[]

Unwrap Array or just add iterator for array?

Generics as preprocess feature

equal: func<T>(a,b: T){
  c := (a==b)
  if(!c) exit(1)
}

equal(100,100)

c will always be false. We have to write the above function as

equal: func<T>(a,b: T){
  c: Bool
  match(T){
    case Int => c = a as Int == b as Int
    // string, Doule, Float, Int64...
    case => exit(1)
  }
  if(!c) exit(1)
}

Many duplicate codes have to be written to handle "generics" and make the function do not like a generics function. A better way is unwrap each function call:

equal(10,10)
->
equal: func~int(a,b: Int) ....

equal(10, "fo")
->
error, can not infer T

extern val from object?

See this

            match termSig {
                case SIGSEGV =>
                    message = message + " (Segmentation fault)"
                case SIGABRT =>
                    message = message + " (Abort)"
                case =>
                    // pffrt.
            }

SIGSEGV comes from extern. If we add matches? for int, this blowes up

Error infer for overloaded function?

add: func ~Int (a,b: Int) -> Int { a+b }
add: func Double (a,b: Double) -> Double { a+b }
"Explicitly: #{add
Double(1.324e-1,1)}" println()
"Auto infer: #{add(1.324e-1,1)}" println()

gives

Explicitly: 1.132400
Auto-infer: 1

Expected:

Explicitly: 1.132400
Auto-infer: 1.132400

Double vs double?

main: func(args: string[]) -> int
main: func(argc: int, argv: cstring*) -> int

main: func(args: String[]) -> Int
main: func(argc: Int, argv: CString*) -> Int

Most languages use int instead of Int, should OOC also use lower-case for types?

Improve hashmap

Instead of hard-coded hash funciton, we can defined a hash() for each object.

extern Int

everything can be declared as extarn Int regardless of the original declaration.
Consider we have a const val val1 in c.
Then declared it as val1: extern Int, it becomes an normal variable decl and can be referenced.

Can't use (type*) as type args

import structs/HashMap

foo: class{ init: func }

bar := HashMap<Int, foo*> new()

bar put(1, foo new())

baz: cover from foo{ init: func@ }

qux:= HashMap<Int, baz*> new()

qux add(1, baz new())
b := baz new() // b -> baz
qux add(2, b&) // no such function add<Int, baz> which should have been declared as <Int, bez*>

Directly using string in c function does not work

printf("%.2Lf\n", a)

Does not work any more. One should use

printf("%.2Lf\n" toCString(), a)

instead. Even though I do not think this is a bug, but it seems that directly using OOC string is expected to work in official repo.

Getter/Setter broken in cover

Again.

test: cover from Int*{
    new: static func() -> This{
        return 0 as This
    }

    title: String{
        set(tit){
            tit println()
        }
    }
}


t := test new()

t title = "111"

Compiler reports undefined symbol title

Error getter/setter generation in cover

Getter/Setter in Cover should be Ref Type, but the flag setted in PropertyDecl is not used in FunctionDecl.
Getter generated will come with __set((Type) &variable) which lead GCC compile error:
Conversion to non-scalar type requested.

Clean up code ?

Many code based on GC_malloc, and no free() comes with them.
These pieces exist in both sdk and compiler.
Cleanup the code?

Hello from mainline

I'm just now discovering all your work - already cherry-picked e9100a3 to fix ooc-lang#774 but I'm sure there's a lot of good stuff that we can merge back to mainline if you want to.

Can we discuss this here? Or on the mailing list? Let me know.

Cheers,

  • Amos

Implicit casts on array should be element-wise

Test:

foo: func~SizeT->SSizeT[]{
    return [1,2,3,4]
}

foo: func~Int->Int[]{
    return [1,2,3,4]
}

main: func(){
    foo~SizeT()[0] toString() println()
    foo~Int()[0] toString() println()
}

gives:

8589934593
1

instead of

1
1

8589934593 = 2<<32 + 1
This is easy to be understood because we casted on whole array. But this is an unexpected action

Convenient way for calling c function?

Now we have to declare function / structure(cover) etc. before using the function defined in c header file. Adding a more conventient way for using them? such as

main: func(args: String[]) -> Int{
   c.gtk_init(args length&, args data&)
   window: c.GtkWidget* = c.gtk_window_new(0)
   c.gtk_widget_show(window)
   c.gtk_main()
   0
}

Here "c" is not a structure, it can be treated as a prefix and unwraped during compile time.

Tests fail.

Affected test modules:

  • io/find
  • io/exists
  • io/fileexec
  • io/rm_rf
  • io/rm
  • text/base64

Still not sure which commit breaks these tests.

Nested-closure totally messed up

try compiling this

main: func{
    a : Int = 1
    b := func{
        a = 2
        c := func{
            a = 3
            d := func{
                a = 4
            }
            d()
        }
        c()
    }

    b()

    if(a != 4) Exception new("%d vs 4" format(a)) throw()
}

indexVariable is not handled in foreach

After create index variable for tuple, it is not handled in the following when collection type is RangeLiteral. This leads to the counter missing in for body.

Defer block?

some thing like this:

test := malloc(10)
defer test free()

Not like go, defer works block-wise, it means that we can use it in for loop:

for(name in fileNames){
    f := File new(name)
    defer f close()
    // do something
}

Safe Array Length?

arr := [1,2,3]
arr length = 5000
for(i in 0..arr length){
arr[i] = 1
}

generates randomly segmental error

arr length should be bound to setLength and getLength but not struct member?

Generics cause compilation failure

test: func<T>(a: T){ a println() }
main: func(){
    for(i in 0..10)
        test<Int>(i)
}

this cause segmentation fault.

Backtrace:
String toCString()
ac_X31_hash()
AstBuilder gotVarDecl_impl()

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.