mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
C string literals (c'str'); bare builtin module; bare println()
This commit is contained in:
@ -161,7 +161,7 @@ fn (p mut Parser) name_expr() string {
|
||||
|
||||
mut name := p.lit
|
||||
// Raw string (`s := r'hello \n ')
|
||||
if name == 'r' && p.peek() == .str {
|
||||
if (name == 'r' || name == 'c') && p.peek() == .str {
|
||||
p.string_expr()
|
||||
return 'string'
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ pub fn (v &V) v_files_from_dir(dir string) []string {
|
||||
pub fn (v mut V) add_v_files_to_compile() {
|
||||
mut builtin_files := v.get_builtin_files()
|
||||
if v.pref.is_bare {
|
||||
builtin_files = []
|
||||
//builtin_files = []
|
||||
}
|
||||
// Builtin cache exists? Use it.
|
||||
builtin_vh := '$v_modules_path${os.path_separator}vlib${os.path_separator}builtin.vh'
|
||||
@ -651,6 +651,9 @@ pub fn (v mut V) add_v_files_to_compile() {
|
||||
|
||||
pub fn (v &V) get_builtin_files() []string {
|
||||
// .vh cache exists? Use it
|
||||
if v.pref.is_bare {
|
||||
return v.v_files_from_dir(filepath.join(v.vroot, 'vlib', 'builtin', 'bare'))
|
||||
}
|
||||
$if js {
|
||||
return v.v_files_from_dir('$v.vroot${os.path_separator}vlib${os.path_separator}builtin${os.path_separator}js')
|
||||
}
|
||||
|
@ -2125,7 +2125,8 @@ fn format_str(_str string) string {
|
||||
|
||||
fn (p mut Parser) string_expr() {
|
||||
is_raw := p.tok == .name && p.lit == 'r'
|
||||
if is_raw {
|
||||
is_cstr := p.tok == .name && p.lit == 'c'
|
||||
if is_raw || is_cstr {
|
||||
p.next()
|
||||
}
|
||||
str := p.lit
|
||||
@ -2137,7 +2138,7 @@ fn (p mut Parser) string_expr() {
|
||||
Calling a C function sometimes requires a call to a string method
|
||||
C.fun('ssss'.to_wide()) => fun(string_to_wide(tos3("ssss")))
|
||||
*/
|
||||
if (p.calling_c && p.peek() != .dot) || p.pref.is_bare || (p.pref.translated && p.mod == 'main') {
|
||||
if (p.calling_c && p.peek() != .dot) || is_cstr || (p.pref.translated && p.mod == 'main') {
|
||||
p.gen('"$f"')
|
||||
}
|
||||
else if p.is_sql {
|
||||
|
Reference in New Issue
Block a user