Giter VIP home page Giter VIP logo

Comments (7)

elliotchance avatar elliotchance commented on August 23, 2024 1

Hi @yml that is a really good example to play with (I will definitely keep this in mind in the future), but unfortunately c2go does not have enough features to be able to process that codebase... at least not yet!

The AST (the structure that describes the C code) is ingested from the clang output. There are still particular lines, like this one from the error message...

FieldDecl 0x21391d8 <line:75:2, col:15> col:2 'unsigned int'

...that it cannot yet understand. Here are the test cases for FieldDecl. Once a new test case is added, and this regex is updated it should be able to understand this input.

Like I said, we are still far away from being able to compile kilo.c, but one step at a time...

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

I believe this is fixed with #31

from c2go.

yml avatar yml commented on August 23, 2024

There has been some progress on this front:

yml@kodi$ c2go transpile kilo.c
~/Devs/kilo master
yml@kodi$ ll
total 188
-rw-r--r-- 1 yml yml 40314 avril 14  2017 kilo.c
-rw-r--r-- 1 yml yml 57703 nov.  17 09:38 kilo.go
-rw-r--r-- 1 yml yml  1330 avril 14  2017 LICENSE
-rw-r--r-- 1 yml yml    91 avril 14  2017 Makefile
-rw-r--r-- 1 yml yml   828 avril 14  2017 README.md
-rw-r--r-- 1 yml yml   204 avril 14  2017 TODO
yml@kodi$ go run kilo.
kilo.c   kilo.go  
~/Devs/kilo master
yml@kodi$ go run kilo.go
# command-line-arguments
./kilo.go:1006:79: cannot use 0 (type int) as type []byte in array or slice literal
./kilo.go:1007: cannot use 0 (type int) as type []byte in array or slice literal
./kilo.go:1013:3: undefined: tcsetattr
./kilo.go:1025:19: undefined: isatty
./kilo.go:1028:2: undefined: atexit
./kilo.go:1029:5: undefined: tcgetattr
./kilo.go:1033:14: invalid operation: raw.c_iflag &= ^(2 | 256 | 16 | 32 | 1024) (mismatched types tcflag_t and int)
./kilo.go:1034:14: invalid operation: raw.c_oflag &= ^1 (mismatched types tcflag_t and int)
./kilo.go:1035:14: invalid operation: raw.c_cflag |= 48 (mismatched types tcflag_t and int)
./kilo.go:1036:14: invalid operation: raw.c_lflag &= ^(8 | 2 | 32768 | 1) (mismatched types tcflag_t and int)
./kilo.go:1036:14: too many errors

from c2go.

elliotchance avatar elliotchance commented on August 23, 2024

Thanks for the update @yml. There is still a lot of work to get kilo.c working, but we definitely are making progress 👍

from c2go.

Konstantin8105 avatar Konstantin8105 commented on August 23, 2024

Warnings for present version:

// Warning (FieldDecl): 69: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-l
inux-gnu/bits/waitstatus.h:69:5)'.
// Warning (FieldDecl): 84: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-l
inux-gnu/bits/waitstatus.h:84:5)'.
// Warning (RecordDecl): 66: could not determine the size of type `union wait` for that reason: cannot determine size of: `st
ruct (anonymous struct at /usr/include/x86_64-linux-gnu/bits/waitstatus.h:84:5)`
// Warning (TransparentUnionAttr): 71: could not parse &{43525168 {/usr/include/stdlib.h 71 0 35 0 } []}
// Warning (FieldDecl): 141: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-
linux-gnu/bits/pthreadtypes.h:141:3)'.
// Warning (FieldDecl): 177: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-
linux-gnu/bits/pthreadtypes.h:177:3)'.
// Warning (TypedefDecl): 741: function pointers are not supported : 'int ( void *, void *)'
// Warning (TypedefDecl): 748: function pointers are not supported : 'int ( void *, void *, void *)'
// Warning (FieldDecl): 85: probably an incorrect type translation 3
// Warning (TypedefDecl): 333: function pointers are not supported : '__ssize_t (void *, char *, size_t)'
// Warning (TypedefDecl): 341: function pointers are not supported : '__ssize_t (void *, char *, size_t)'
// Warning (TypedefDecl): 350: function pointers are not supported : 'int (void *, __off64_t *, int)'
// Warning (TypedefDecl): 353: function pointers are not supported : 'int (void *)'
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 71: Add support of continues counter for type : *ast.BinaryExpr
// Warning (EnumDecl): 533: Add support of continues counter for type : *ast.BasicLit
// Warning (EnumDecl): 533: Add support of continues counter for type : *ast.BasicLit
// Warning (CallExpr): 209: function pointers are not supported : 'void (void)'
// Warning (UnaryExprOrTypeTraitExpr): 522: cannot determine size of: `struct editorSyntax [1]`
// Warning (UnaryExprOrTypeTraitExpr): 522: cannot determine size of: `struct editorSyntax':'struct editorSyntax`
// Warning (UnaryExprOrTypeTraitExpr): 572: cannot determine size of: `erow`
// Warning (UnaryExprOrTypeTraitExpr): 572: cannot determine size of: `erow`
// Error (BinaryOperator): 572: cannot determine size of: `erow`
// Warning (UnaryExprOrTypeTraitExpr): 574: cannot determine size of: `erow':'struct erow`
// Warning (UnaryExprOrTypeTraitExpr): 605: cannot determine size of: `erow':'struct erow`
// Warning (BinaryOperator): 909: int
// Warning (CallExpr): 980: Cannot resolve function : I couldn't find an appropriate Go type for the C type '...'.
// Error (CallExpr): 980: I couldn't find an appropriate Go type for the C type '...'.
// Warning (CallExpr): 982: I couldn't find an appropriate Go type for the C type '[]__va_list_tag'.
// Warning (BinaryOperator): 1017: int
// Warning (BinaryOperator): 1029: int
// Warning (BinaryOperator): 1034: int

from c2go.

Konstantin8105 avatar Konstantin8105 commented on August 23, 2024

After #469:

// Warning (FieldDecl): 69: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-linux-gnu/bits/waitstatus.h:69:5)'.
// Warning (FieldDecl): 84: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-linux-gnu/bits/waitstatus.h:84:5)'.
// Warning (RecordDecl): 66: could not determine the size of type `union wait` for that reason: cannot determine size of: ``
// Warning (TransparentUnionAttr): 71: could not parse &{32060464 {/usr/include/stdlib.h 71 0 35 0 } []}
// Warning (FieldDecl): 141: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:141:3)'.
// Warning (FieldDecl): 177: I couldn't find an appropriate Go type for the C type '(anonymous struct at /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h:177:3)'.
// Warning (TypedefDecl): 741: function pointers are not supported [1] : 'int (*)( void *, void *)'
// Warning (TypedefDecl): 748: function pointers are not supported [1] : 'int (*)( void *, void *, void *)'
// Warning (FieldDecl): 85: probably an incorrect type translation 3
// Warning (TypedefDecl): 333: function pointers are not supported [2] : '__ssize_t (void *, char *, size_t)'
// Warning (TypedefDecl): 341: function pointers are not supported [2] : '__ssize_t (void *, char *, size_t)'
// Warning (TypedefDecl): 350: function pointers are not supported [2] : 'int (void *, __off64_t *, int)'
// Warning (TypedefDecl): 353: function pointers are not supported [2] : 'int (void *)'
// Warning (EnumDecl): 46: Add support of continues counter for type : *ast.ParenExpr
// Warning (EnumDecl): 71: Add support of continues counter for type : *ast.BinaryExpr
// Warning (CallExpr): 209: function pointers are not supported [2] : 'void (void)'
// Warning (UnaryExprOrTypeTraitExpr): 522: cannot determine size of: `struct editorSyntax [1]`
// Error (CallExpr): 547: Cannot found goast.Ident in operation <ToVoid> or function free
// Warning (UnaryExprOrTypeTraitExpr): 572: cannot determine size of: `erow`
// Error (BinaryOperator): 572: Cannot transpile BinaryOperator : result type = {unknown63}. Error: cannot determine size of: `erow`
// Warning (UnaryExprOrTypeTraitExpr): 574: cannot determine size of: `erow`
// Error (CallExpr): 592: Cannot found goast.Ident in operation <ToVoid> or function free
// Error (CallExpr): 593: Cannot found goast.Ident in operation <ToVoid> or function free
// Error (CallExpr): 594: Cannot found goast.Ident in operation <ToVoid> or function free
// Warning (UnaryExprOrTypeTraitExpr): 605: cannot determine size of: `erow`
// Error (CallExpr): 779: Cannot found goast.Ident in operation <ToVoid> or function free
// Error (CallExpr): 853: Cannot found goast.Ident in operation <ToVoid> or function free
// Warning (BinaryOperator): 909: int
// Warning (CallExpr): 980: I couldn't find an appropriate Go type for the C type '...'.
// Warning (BinaryOperator): 1017: int
// Warning (ParenExpr): 0: Cannot transpile ParenExpr. err = probably an incorrect type translation 1
// Warning (UnaryOperator): 0: Cannot transpile UnaryOperator: err = Cannot transpile ParenExpr. err = probably an incorrect type translation 1
// Error (IfStmt): 0: Cannot transpile UnaryOperator: err = Cannot transpile ParenExpr. err = probably an incorrect type translation 1
// Warning (BinaryOperator): 1029: int
// Warning (BinaryOperator): 1034: int
// Warning (ParenExpr): 0: Cannot transpile ParenExpr. err = probably an incorrect type translation 1
// Warning (UnaryOperator): 0: Cannot transpile UnaryOperator: err = Cannot transpile ParenExpr. err = probably an incorrect type translation 1
// Error (IfStmt): 0: Cannot transpile UnaryOperator: err = Cannot transpile ParenExpr. err = probably an incorrect type translation 1

from c2go.

Konstantin8105 avatar Konstantin8105 commented on August 23, 2024

result of go build:

± |master ?:1 ✗| → go build kilo.go
# command-line-arguments
./kilo.go:820:6: __itimer_which_t redeclared in this block
	previous declaration at ./kilo.go:816:6
./kilo.go:1327:3: undefined: tcsetattr
./kilo.go:1347:19: undefined: isatty
./kilo.go:1350:2: undefined: atexit
./kilo.go:1351:5: undefined: tcgetattr
./kilo.go:1355:23: constant -1331 overflows uint32
./kilo.go:1356:23: constant -2 overflows uint32
./kilo.go:1358:23: constant -32780 overflows uint32
./kilo.go:1361:5: undefined: tcsetattr
./kilo.go:1368:3: undefined: __errno_location
./kilo.go:1368:3: too many errors

Warning maybe from user source:

// Warning (ParenExpr):  :0 : Cannot transpile ParenExpr. err = Cannot casting {int -> }. err = Cannot resolve type '' : probably an incorrect type translation 1
// Warning (UnaryOperator):  :0 : Cannot transpile UnaryOperator: err = Cannot transpileToExpr. err = Cannot transpile ParenExpr. err = Cannot casting {int -> }. err = Cannot resolve type '' : probably an incorrect type translation 1
// Warning (ParenExpr):  :0 : Cannot transpile ParenExpr. err = Cannot casting {int -> }. err = Cannot resolve type '' : probably an incorrect type translation 1
// Warning (UnaryOperator):  :0 : Cannot transpile UnaryOperator: err = Cannot transpileToExpr. err = Cannot transpile ParenExpr. err = Cannot casting {int -> }. err = Cannot resolve type '' : probably an incorrect type translation 1

So, now problem of kilo is unsupported C libraries.

from c2go.

Related Issues (20)

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.