=============
function call
=============

void Test() {
    MyFunc();
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments)
        )
      )
    )
  )
)


============================
function call with arguments
============================

void Test() {
    MyFunc1("test");
    MyFunc2("test", 2, &ref, myVar, 0.0, 0xFE, 0b01, 0o13);
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments
            (string_literal)
          )
        )
      )
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments
            (string_literal)
            (int_literal)
            (unary_expression
              argument: (identifier)
            )
            (identifier)
            (float_literal)
            (int_literal)
            (int_literal)
            (int_literal)
          )
        )
      )
    )
  )
)


==================================
function call with named arguments
==================================

void Test() {
    MyFunc("test", .c = 2, .f = 2.13, .o = &outVar);
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments
            (string_literal)
            (named_arg
              arg_name: (identifier)
              value: (int_literal)
            )
            (named_arg
              arg_name: (identifier)
              value: (float_literal)
            )
            (named_arg
              arg_name: (identifier)
              value: (unary_expression
                argument: (identifier)
              )
            )
          )
        )
      )
    )
  )
)


===================================
function call with irgnore argument
===================================

void Test() {
    MyFunc("test", _, 2.13, _);
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments
            (string_literal)
            (ignore_argument)
            (float_literal)
            (ignore_argument)
          )
        )
      )
    )
  )
)


===========================
function call as expression
===========================

bool Test() {
    return 10 > CurrentCount();
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (return_statement
        expression: (binary_expression
          left: (int_literal)
          right: (call_expression
            function: (identifier)
            arguments: (call_arguments)
          )
        )
      )
    )
  )
)


=======================================
function call as function call argument
=======================================

void Test() {
    IncreaseCounter(CurrentCount());
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (identifier)
          arguments: (call_arguments
            (call_expression
              function: (identifier)
              arguments: (call_arguments)
            )
          )
        )
      )
    )
  )
)


==============================
function call as initial value
==============================

int CurrentCount() {
  int count = CurrentCount();
  return 1;
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (variable_declaration_statement
        type: (type
          (builtin_type)
        )
        (variable_declaration
          name: (identifier)
          initialValue: (call_expression
            function: (identifier)
            arguments: (call_arguments)
          )
        )
      )
      (return_statement
        expression: (int_literal)
      )
    )
  )
)


===============================
function call from field access
===============================

void Test() {
    event.GetInt("userid");
}

---

(source_file
  (function_definition
    returnType: (type
      (builtin_type)
    )
    name: (identifier)
    parameters: (parameter_declarations)
    body: (block
      (expression_statement
        (call_expression
          function: (field_access
            target: (identifier)
            field: (identifier)
          )
          arguments: (call_arguments
            (string_literal)
          )
        )
      )
    )
  )
)
