Coder Social home page Coder Social logo

rock's People

Contributors

ahamid avatar alexnask avatar causal-agent avatar danopia avatar davidhesselbom avatar ds84182 avatar einat avatar fasterthanlime avatar fredreichbier avatar horasal avatar joshthecoder avatar marcusnaslund avatar metal3d avatar mickael9 avatar micrypt avatar mt2d2 avatar nddrylliog avatar nikobordx avatar nilium avatar plichard avatar refi64 avatar rofl0r avatar roja avatar showstopper avatar ycros 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  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

rock's Issues

Can't create arrays of Func

It seems i can't create an array of Func
objects, either raw or by using an ArrayList.

Sample code:

// This works.
test: Float* = gc_malloc(10 * Float size)

// This doesn't work.
test:  Func* = gc_malloc(10 * Func size)

Output:

test.ooc: [ERROR] No such variable Func
test: Func* = gc_malloc(10 * Func size)

Sample code (using ArrayList)

import structs/ArrayList   
list := ArrayList<Func> new(10)

Output

test.ooc: [ERROR] Missing info for type argument T. 
Have you forgotten to qualify ArrayList.new~withCapacity: 
static func <T> (=capacity) -> ArrayList<T>, e.g. List<Int>?

Add -hardass flag

Not everyone likes a compiler soft and friendly.

Those who want tough love shouldn't be set apart.

You said on ooc's issue tracker that it won't be implemented there, so I took the liberty of copying the issue here. :D

Use the 'most derived type' to determine the type of raw array literals

Currently the documentation states that the type for the raw array literal is derived from the first element in the literal:
http://docs.ooc-lang.org/language/syntax.html#raw-arrays

A better rule will be to use the 'most derived type' - the type to which all the other types can be implicitly converted to. In no such type exists in the literal, it probably should be an error.

For example: [1, 2, 3.0] should be a raw array of Double (assuming that the "1" and "2" literals are 32-bit integers).
Similarly, having classes "Foo" and "Bar extends Foo", [Foo new(), Bar new()] should be a raw array of Foo.

Multi-assignment might be nice

e.g.

(a, b, c) = (1, 2, 3)

Maybe even multi-declassign?

(a, b, c) := (1, 2, 3)

(That makes declarations of a, b and c hard to search for though)

Issue with extending String coverage

i wanted to extend String coverage :

String: cover {

    wtrim: func -> This {
        if(length() == 0) return this

        start := 0
        while(this[start] isWhitespace()) start += 1;

        end := length()
        if(start >= end) return ""
        while(this[end - 1] isWhitespace()) end -= 1;

        if(start != 0 || end != length()) return substring(start, end)

        return this
    }
}

But in some case, it doesn't work :
Rock fails with "[ERROR] No such function String (lang/types [5161, 5167]).wtrim()"

Works :

main: func {
    id := "       aaaaaaaaa    \n   "
    id wtrim() println() // doesn't work    
}

Doesn't work :

main: func {
    id := String new(100)
    id = "       aaaaaaaaa    \n   "
    id wtrim() println()
}

but Works :

main: func {
    id := String new(100)
    id = "       aaaaaaaaa    \n   "
    id as String wtrim() println()
}

-r option is ignored

The -r option ("Run the exectuable after a successful compilation.") is ignored in rock 0.9.0.

git clone failed

╰─(☹) ✘ git clone http://github.com/nddrylliog/rock.git
Initialized empty Git repository in /home/xinuc/sandbox/rock/.git/
got d8514be
walk d8514be
got a7df4ad
got eb200e5
Getting alternates list for http://github.com/nddrylliog/rock.git
got 8cc2d1688ccdfb6dda7bede964e8b2826b6c695f
got a0aaf28
Getting pack list for http://github.com/nddrylliog/rock.git
got 284c8f6591f912541501af7cf5084df8ab5db731
Getting index for pack e7604c54e6204e4edf532aa29de279ad1a02f654
Getting index for pack 8dfb1981a63d0bf2cdc69d9999972ce7e028f828
Getting index for pack 2ff0a2805b129546f48621f28e71486b9ae0a866
Getting pack e7604c54e6204e4edf532aa29de279ad1a02f654
which contains 9a40acd
error: Unable to get pack file http://github.com/nddrylliog/rock.git/objects/pack/pack-e7604c54e6204e4edf532aa29de279ad1a02f654.pack
transfer closed with 2434386 bytes remaining to read
error: Unable to find 9a40acd under http://github.com/nddrylliog/rock.git
Cannot obtain needed object 9a40acd
while processing commit d8514be.
fatal: Fetch failed.

can you give me some hint about this thing?

Super constructors not being called

I have uncovered the cause of current segfaulting when trying to use the self-hosted rock. It seems the HashMap hashKey function is never set for Module functions. OrderedMultiMap is never calling the HashMap constructor, thus hashKey is never set leading to the segfault.

Should we automatically be calling the super constructor when no init is provided (much like jooc does now) or should the developer be forced to declare an init and call super()?

WE NEED YOU

Dear nddrylliog,

please come into the IRC. We desperately need you.
Yours,

showstopper

custom_sdk pthread type mismatch

rock_tmp/custom-sdk/threading/native/ThreadUnix.c: In function ‘threading_native_ThreadUnix__ThreadUnix_start_impl’:
rock_tmp/custom-sdk/threading/native/ThreadUnix.c:39: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
/usr/include/pthread.h:227: note: expected ‘void * (*)(void *)’ but argument is of type ‘void **’

Rock refuses to allow pulling values out of Yajl maps

Results vary from rock crashing to the program crashing.

Specimen 1

use yajl
import yajl/Yajl // into JSON

main: func {
  packet := parse("{\"mode\":\"test\"}", ValueMap)
  value := packet["mode", String]
}

Note the packet[key, class] syntax. This is taken from the ooc-yajl README. Rock fails to compile this:

error.ooc:6:3 [ERROR] Expected statement or a closing bracket
  value := packet["mode", String]
  ^                              
[FAIL]

Specimen 2

Here is a second code sample which I tried before I looked at ooc-yajl docs. The ooc-yajl docs do not document what this should do. (j/ooc gives gcc some strange code, which causes a C build error, so it doesn't help me figure out what I should expect)

use yajl
import yajl/Yajl // into JSON

main: func {
  packet := parse("{\"mode\":\"test\"}", ValueMap)
  value := packet["mode"]
}

Rock crashes with not much helpful info:

danopia@danopia:~/Dev/fbi/ooc$ rock error.ooc 
[Exception in ArrayList]: Index too big! 2 >= 2
Floating point exception
danopia@danopia:~/Dev/fbi/ooc$ 

I had a backtrace, and I can post it if you would like. I consider this crash "bad" because it is not helpful in any way.

Specimen 3

use yajl
import yajl/Yajl // into JSON

main: func {
  packet := parse("{\"mode\":\"test\"}", ValueMap)
  value := packet getValue("mode", String)
}

This snippit compiles under rock but segfaults when ran, after parsing but before printing the value. I know this because ooc-yajl has time to print a debug line and taking out the getValue call stops the segfault. J/ooc compiles/runs this properly, so until this bug is fixed I might dev under that.

for loop seg fault

The following code causes a segmentation fault in rock but is compiled successfully by ooc. It seems to be the for loop causing the problem...


import structs/ArrayList

main : func {

  addition := "+"
  subtraction := "-"
  multiplication := "*"
  division := "/"

  operations := ArrayList<String> new()
  operations add( addition ) . add( subtraction ) . add( multiplication ) . add( division )

  for ( oper in operations ) {
    oper println()
  }

}

Impossible to use C keywords for function names.

In ooc-llvm I have a Type cover that has static functions called 'int', 'float', 'double', and some other C keywords. Rock doesn't catch this, instead I get confusing gcc errors. I would be most happy if these names were allowed somehow, but in the least, Rock should catch them and make it's own error instead of gcc errors.

Properties on covers

They ain't working.

either rock is not defining the cover's metaclass correctly or it's not writing the variable access correctly

That oughta be fixed.

Access to static extern-named members calls _class()

E.g.

MPD: cover from MpdObj* {
  verzion: extern(libmpd_version) static String
}

when I try to access that, it ends up like: lang_types__String_println(mpd__MPD_class()>libmpd_version);
either mpd__MPD_class()-> should be gone, or it should add libmpd_version to the struct

in which case it should actually be a member named verzion.

And indeed, mpd__MPD_class()-> should be gone.

rock doesn't have extern enums yet!

I believe the propsed syntax was:

ImageFormat: enum {
    unknown: extern(FIF_UNKNOWN)
    jpeg:    extern(FIF_JPEG)
    // ...
}

This would be consistent with other things that always have the name first, and with properties, which do get { ... } for non-extern and get: extern(...) for extern.

func cover covers generate wrong code

This code:

A: cover from Func
B: cover from A

fails with:

In file included from rock_tmp/./cover-vol2.h:6:0,
                 from rock_tmp/./cover-vol2.c:3:
rock_tmp/./cover-vol2-fwd.h:14:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cover_vol2__B'
rock_tmp/./cover-vol2.c: In function 'cover_vol2__B_class':
rock_tmp/./cover-vol2.c:36:44: error: 'cover_vol2__B' undeclared (first use in this function)
rock_tmp/./cover-vol2.c:36:44: note: each undeclared identifier is reported only once for each function it appears in
C compiler failed, aborting compilation process
[FAIL]

and rock_tmp/cover-vol2-fwd.h is http://bpaste.net/show/6118/

Match with only a "catchall" fails with C errors

ooc snippit

match(2) {
  case =>
    "hello" println()
}

Generated C

 else {
    lang_types__String_println("hello");
};

Note that there's no "if" there.

Rock error

rock_tmp/./test.c: In function ‘test_load’:
rock_tmp/./test.c:22: error: expected ‘}’ before ‘else’
rock_tmp/./test.c: At top level:
rock_tmp/./test.c:26: error: expected identifier or ‘(’ before ‘}’ token

Raw arrays in rock

Things like

a : Int* = [1, 2, 3]

Should work, and not create an ArrayList and casting i (O_o).

Simple TCP server socket code fails with '[SocketError]: Invalid argument'

import net/ServerSocket

main: func {
    server := ServerSocket new()
    server bind(8080)
    server listen(5)

    client := server accept()
    client writer() write("Hello World", 11)
    client close()
}


./main 
[SocketError]: Invalid argument
[1]    12165 floating point exception  ./main

The code seems to stop on server bind(8080). Any idea?

Operator Overloading within a class

Mostly a reminder to nddrylliog that class should have operator overloading internally for instance

operator + (right: Bignum) -> Bignum {
    this + right
}

Overloading "as" operator doesn't work

Example 1

Test: class {}

operator as (t: Test) -> String {
    "Hi there"
}

main: func {
    t := Test new()
    t as String println()
}

Outputs :

��b

Example 2

operator as (t: Float) -> String {
    "Hi there"
}

main: func {
    t := 1.2
    t as String println()
}

Refuses to compile :
rock_tmp/./test.c: In function ‘main’:
rock_tmp/./test.c:30: error: cannot convert to a pointer type
C compiler failed, aborting compilation process
[FAIL]

Details

Rock 0.9.0 bootstrapped

#gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) 

methods on enums

It would be very handy to be able to write methods and static functions on enums. For example, in ooc-freeimage with j/ooc I had a cover of FREE_IMAGE_FORMAT with some extern methods like toString: extern(FreeImage_GetFormatFromFIF) func -> String which took a FREE_IMAGE_FORMAT as argument. It's much nicer to be able to do fif toString() instead of FreeImage_GetFormatFromFIF(fif), so I think we should be able to add methods to enums.

Issue with named imports?

It seems like this code fails under rock:

use yajl
import yajl/Yajl into JSON

...

info := JSON ValueMap new()
info["real_name"] = "John Doe"
info["age"] = 56
info["is_cool"] = true

secretNames := JSON ValueList new()
secretNames addValue("Herbert YouHaveNoIdeaWhoIAmCauseIGotACoupleOfSecretNames") .addValue("Dohn Joe") .addValue(009)
info["secret_names"] = secretNames

// and now, generate it!
string := JSON generate(info)

string println()

The same code works in j/ooc.

danopia@danopia:~/Dev/fbi/middle$ OOC_DIST=~/Dev/ooc/ooc ooc -r test.ooc
ooc_tmp/sdk/structs/LinkedList.c: In function ‘structs_LinkedList__LinkedList_print_impl’:
ooc_tmp/sdk/structs/LinkedList.c:210: warning: cast from pointer to integer of different size
ooc_tmp/sdk/structs/LinkedList.c:223: warning: cast from pointer to integer of different size
ooc_tmp/sdk/structs/LinkedList.c:233: warning: cast from pointer to integer of different size
ooc_tmp/yajl/yajl/Yajl.c: In function ‘yajl_Yajl__Value_getType_impl’:
ooc_tmp/yajl/yajl/Yajl.c:755: warning: ‘match’ may be used uninitialized in this function
[ OK ]
^C>> KEYS: 0x1761fa0
{"real_name":"John Doe","age":56,"is_cool":true}
KEYS: 0x1766e88

danopia@danopia:~/Dev/fbi/middle$ rock -r test.ooc
trail = 
\_, Module client
  \_, ClassDecl Nick
    \_, ClassDecl NickClass
      \_, Nick.toString: func  -> String
        \_, {info : ValueMap = ValueMap new(), __genArg104 : String = "John Doe", __OP_IDX_ASS_ValueMap_String_T(info, "real_name", __genArg104&), __genArg105 : Int = 56, __OP_IDX_ASS_ValueMap_String_T(info, "age", __genArg105&), __genArg106 : Bool = true, __OP_IDX_ASS_ValueMap_String_T(info, "is_cool", __genArg106&), string : String = JSON generate(info&), return string}
          \_, string : String = JSON generate(info&)
            \_, JSON generate(info&)

[Exception in Token]: From unknown source [[ERROR]] No such variable ValueMap
Floating point exception

If I take out "into JSON" from the import and "JSON" from the code, it works under rock.

Can't use files in root drives in Windows systems.

E:\>rock helloworld.ooc
[Exception in PathList]: Classpath element cannot be found: .
E:\>cd Code
E:\Code>rock helloworld.ooc
Launching gcc.exe -O2 -std=gnu99...

Not only this problem prevents the user from running code in
files in the root folder of a given drive but it also affects
any OOC code that tries to use root folders in Windows systems.

The reason seems to be in that custom-sdk\io\native\FileWin32
uses FindFirstFile in the Windows API to search for files,
but as stated in the MSDN documentation, one can't use it for
root drives, instead "DRIVE:*" and FindNextFile should be used.

Func covers generate wrong code

F: cover from Func

throws:

In file included from rock_tmp/./cover.h:6:0,
                 from rock_tmp/./cover.c:3:
rock_tmp/./cover-fwd.h:6:18: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'cover__F'
rock_tmp/./cover.c: In function 'cover__F_class':
rock_tmp/./cover.c:18:44: error: 'cover__F' undeclared (first use in this function)
rock_tmp/./cover.c:18:44: note: each undeclared identifier is reported only once for each function it appears in
C compiler failed, aborting compilation process
[FAIL]

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.