pull/2532/head
Alexander Medvednikov 2019-10-24 14:51:22 +03:00
parent 98c016b41d
commit dca49e43d9
4 changed files with 20 additions and 9 deletions

View File

@ -17,11 +17,6 @@ fn init() {
}
}
fn C.memcpy(byteptr, byteptr, int)
fn C.memmove(byteptr, byteptr, int)
//fn C.malloc(int) byteptr
fn C.realloc(byteptr, int) byteptr
pub fn exit(code int) {
C.exit(code)
}

View File

@ -0,0 +1,13 @@
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module builtin
fn C.memcpy(byteptr, byteptr, int)
fn C.memmove(byteptr, byteptr, int)
//fn C.malloc(int) byteptr
fn C.realloc(byteptr, int) byteptr
//fn C.qsort()

View File

@ -49,7 +49,6 @@ fn (p mut Parser) enum_decl(_enum_name string) {
if p.tok == .comma {
p.next()
}
// TODO free name [memory]
val++
}
p.table.register_type2(Type {

View File

@ -1264,6 +1264,7 @@ fn (p mut Parser) gen(s string) {
// Generate V header from V source
fn (p mut Parser) statement(add_semi bool) string {
//p.expected_type = ''
if p.returns && !p.is_vweb {
p.error('unreachable code')
}
@ -1982,6 +1983,8 @@ fn (p mut Parser) get_const_type(name string, is_ptr bool) string {
}
fn (p mut Parser) get_c_func_type(name string) string {
//p.warn(name + ' ' + p.expected_type)
//}
f := Fn {
name: name
is_c: true
@ -1994,9 +1997,10 @@ fn (p mut Parser) get_c_func_type(name string) string {
cfn := p.table.find_fn(name) or {
// Not Found? Return 'void*'
//return 'cvoid' //'void*'
if false {
p.warn('\ndefine imported C function with ' +
'`fn C.$name([args]) [return_type]`\n')
//if false {
if p.expected_type != '' && p.expected_type != 'void' {
p.warn('\ndefine imported C function with ' +
'`fn C.$name([args]) [return_type]`\n')
}
return 'void*'
}