mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
minor V.js fixes
This commit is contained in:
parent
97096e4e6c
commit
4e21e9ed44
@ -19,7 +19,7 @@ pub fn panic(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn println(s string) {
|
pub fn println(s string) {
|
||||||
#console.log(s)
|
#console.log(s.str)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn eprintln(s string) {
|
pub fn eprintln(s string) {
|
||||||
|
@ -17,6 +17,15 @@ fn C.strlen(s byteptr) int
|
|||||||
|
|
||||||
fn todo() { }
|
fn todo() { }
|
||||||
|
|
||||||
|
pub fn tos(s byteptr) string {
|
||||||
|
len := 0
|
||||||
|
#len = s.length;
|
||||||
|
return string{
|
||||||
|
str: s
|
||||||
|
len: len
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn (a string) clone() string {
|
pub fn (a string) clone() string {
|
||||||
return a
|
return a
|
||||||
|
@ -214,22 +214,22 @@ fn type_default(typ string) string {
|
|||||||
return '{}'
|
return '{}'
|
||||||
}
|
}
|
||||||
// Default values for other types are not needed because of mandatory initialization
|
// Default values for other types are not needed because of mandatory initialization
|
||||||
switch typ {
|
match typ {
|
||||||
case 'bool': return '0'
|
'bool'{ return '0'}
|
||||||
case 'string': return '""'
|
'string'{ return 'tos("")'}
|
||||||
case 'i8': return '0'
|
'i8'{ return '0'}
|
||||||
case 'i16': return '0'
|
'i16'{ return '0'}
|
||||||
case 'i64': return '0'
|
'i64'{ return '0'}
|
||||||
case 'u16': return '0'
|
'u16'{ return '0'}
|
||||||
case 'u32': return '0'
|
'u32'{ return '0'}
|
||||||
case 'u64': return '0'
|
'u64'{ return '0'}
|
||||||
case 'byte': return '0'
|
'byte'{ return '0'}
|
||||||
case 'int': return '0'
|
'int'{ return '0'}
|
||||||
case 'rune': return '0'
|
'rune'{ return '0'}
|
||||||
case 'f32': return '0.0'
|
'f32'{ return '0.0'}
|
||||||
case 'f64': return '0.0'
|
'f64'{ return '0.0'}
|
||||||
case 'byteptr': return '0'
|
'byteptr'{ return '0'}
|
||||||
case 'voidptr': return '0'
|
'voidptr'{ return '0'}
|
||||||
}
|
}
|
||||||
return '{}'
|
return '{}'
|
||||||
}
|
}
|
||||||
|
@ -2688,7 +2688,7 @@ fn (p mut Parser) string_expr() {
|
|||||||
p.gen("'$str'")
|
p.gen("'$str'")
|
||||||
}
|
}
|
||||||
else if p.is_js {
|
else if p.is_js {
|
||||||
p.gen('"$f"')
|
p.gen('tos("$f")')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
p.gen('tos3("$f")')
|
p.gen('tos3("$f")')
|
||||||
|
Loading…
Reference in New Issue
Block a user