mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Replace [...] with [?]
This commit is contained in:
+13
-13
@@ -23,7 +23,7 @@ when ODIN_OS == "windows" {
|
|||||||
@(link_name="general_stuff")
|
@(link_name="general_stuff")
|
||||||
general_stuff :: proc() {
|
general_stuff :: proc() {
|
||||||
fmt.println("# general_stuff");
|
fmt.println("# general_stuff");
|
||||||
{ // `do` for inline statments rather than block
|
{ // `do` for inline statements rather than block
|
||||||
foo :: proc() do fmt.println("Foo!");
|
foo :: proc() do fmt.println("Foo!");
|
||||||
if false do foo();
|
if false do foo();
|
||||||
for false do foo();
|
for false do foo();
|
||||||
@@ -534,7 +534,7 @@ parametric_polymorphism :: proc() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
prefix_table := [...]string{
|
prefix_table := [?]string{
|
||||||
"White",
|
"White",
|
||||||
"Red",
|
"Red",
|
||||||
"Green",
|
"Green",
|
||||||
@@ -658,7 +658,7 @@ using_in :: proc() {
|
|||||||
f.x, f.y = 123, 321;
|
f.x, f.y = 123, 321;
|
||||||
println(f);
|
println(f);
|
||||||
using x, y in f;
|
using x, y in f;
|
||||||
f.x, f.y = 456, 654;
|
x, y = 456, 654;
|
||||||
println(f);
|
println(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,15 +731,15 @@ explicit_procedure_overloading :: proc() {
|
|||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
when true {
|
when true {
|
||||||
general_stuff();
|
// general_stuff();
|
||||||
default_struct_values();
|
// default_struct_values();
|
||||||
union_type();
|
// union_type();
|
||||||
parametric_polymorphism();
|
// parametric_polymorphism();
|
||||||
threading_example();
|
// threading_example();
|
||||||
array_programming();
|
// array_programming();
|
||||||
using_in();
|
// using_in();
|
||||||
named_proc_return_parameters();
|
// named_proc_return_parameters();
|
||||||
enum_export();
|
// enum_export();
|
||||||
explicit_procedure_overloading();
|
// explicit_procedure_overloading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ loops :: proc() {
|
|||||||
fmt.println(val, idx);
|
fmt.println(val, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
primes := [...]int{2, 3, 5, 7, 11, 13, 17, 19};
|
primes := [?]int{2, 3, 5, 7, 11, 13, 17, 19};
|
||||||
|
|
||||||
for p in primes {
|
for p in primes {
|
||||||
fmt.println(p);
|
fmt.println(p);
|
||||||
|
|||||||
+4
-4
@@ -5275,11 +5275,11 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
|
|||||||
if (cl->type != nullptr) {
|
if (cl->type != nullptr) {
|
||||||
type = nullptr;
|
type = nullptr;
|
||||||
|
|
||||||
// [...]Type
|
// [?]Type
|
||||||
if (cl->type->kind == AstNode_ArrayType && cl->type->ArrayType.count != nullptr) {
|
if (cl->type->kind == AstNode_ArrayType && cl->type->ArrayType.count != nullptr) {
|
||||||
AstNode *count = cl->type->ArrayType.count;
|
AstNode *count = cl->type->ArrayType.count;
|
||||||
if (count->kind == AstNode_UnaryExpr &&
|
if (count->kind == AstNode_UnaryExpr &&
|
||||||
count->UnaryExpr.op.kind == Token_Ellipsis) {
|
count->UnaryExpr.op.kind == Token_Question) {
|
||||||
type = make_type_array(c->allocator, check_type(c, cl->type->ArrayType.elem), -1);
|
type = make_type_array(c->allocator, check_type(c, cl->type->ArrayType.elem), -1);
|
||||||
is_to_be_determined_array_count = true;
|
is_to_be_determined_array_count = true;
|
||||||
}
|
}
|
||||||
@@ -6278,8 +6278,8 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
|
|||||||
str = gb_string_append_rune(str, '[');
|
str = gb_string_append_rune(str, '[');
|
||||||
if (at->count != nullptr &&
|
if (at->count != nullptr &&
|
||||||
at->count->kind == AstNode_UnaryExpr &&
|
at->count->kind == AstNode_UnaryExpr &&
|
||||||
at->count->UnaryExpr.op.kind == Token_Ellipsis) {
|
at->count->UnaryExpr.op.kind == Token_Question) {
|
||||||
str = gb_string_appendc(str, "...");
|
str = gb_string_appendc(str, "?");
|
||||||
} else {
|
} else {
|
||||||
str = write_expr_to_string(str, at->count);
|
str = write_expr_to_string(str, at->count);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1770,8 +1770,8 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
|
|||||||
AstNode *count_expr = nullptr;
|
AstNode *count_expr = nullptr;
|
||||||
bool is_vector = false;
|
bool is_vector = false;
|
||||||
|
|
||||||
if (f->curr_token.kind == Token_Ellipsis) {
|
if (f->curr_token.kind == Token_Question) {
|
||||||
count_expr = ast_unary_expr(f, expect_token(f, Token_Ellipsis), nullptr);
|
count_expr = ast_unary_expr(f, expect_token(f, Token_Question), nullptr);
|
||||||
} else if (allow_token(f, Token_dynamic)) {
|
} else if (allow_token(f, Token_dynamic)) {
|
||||||
expect_token(f, Token_CloseBracket);
|
expect_token(f, Token_CloseBracket);
|
||||||
return ast_dynamic_array_type(f, token, parse_type(f));
|
return ast_dynamic_array_type(f, token, parse_type(f));
|
||||||
|
|||||||
Reference in New Issue
Block a user