1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

register methods (wip)

This commit is contained in:
Alexander Medvednikov
2020-01-08 10:19:12 +01:00
parent 3425934c39
commit 3c0fca9258
9 changed files with 294 additions and 229 deletions

View File

@ -77,6 +77,18 @@ fn (p mut Parser) bool_expression() string {
}
p.cgen.set_placeholder(start_ph, '*($cast_typ*)')
p.gen('.obj')
// Make sure the sum type can be cast, otherwise throw a runtime error
/*
sum_type:= p.cgen.cur_line.all_after('*) (').replace('.obj', '.typ')
n := cast_typ.all_after('__')
p.cgen.insert_before('if (($sum_type != SumType_$n) {
puts("runtime error: $p.file_name:$p.scanner.line_nr cannot cast sum type `$typ` to `$n`");
exit(1);
}
')
*/
} else {
p.cgen.set_placeholder(start_ph, '($cast_typ)(')
p.gen(')')