Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi-dimensional arrays #279

Closed
yulvil opened this issue Oct 26, 2017 · 1 comment
Closed

Add support for multi-dimensional arrays #279

yulvil opened this issue Oct 26, 2017 · 1 comment

Comments

@yulvil
Copy link
Contributor

yulvil commented Oct 26, 2017

main.c

int main() {
   //int a[][3] = {{10,20,30},{40,50,60},{70,80,90}};
   int a[2][2];
   a[0][0] = 10;
   a[0][1] = 20;
   a[1][0] = 40;
   a[1][1] = 50;
   return a[1][1];
}

Go output: (no main function, no panic/errors/warnings!)

package main

type __int128_t int64
type __uint128_t uint64
type __builtin_ms_va_list []byte

func __init() {
}
TranslationUnitDecl 0x5649c3ab2df0 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x5649c3ab32e8 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128'
| `-BuiltinType 0x5649c3ab3040 '__int128'
|-TypedefDecl 0x5649c3ab3348 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128'
| `-BuiltinType 0x5649c3ab3060 'unsigned __int128'
|-TypedefDecl 0x5649c3ab33d8 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *'
| `-PointerType 0x5649c3ab33a0 'char *'
|   `-BuiltinType 0x5649c3ab2e80 'char'
|-TypedefDecl 0x5649c3ab3688 <<invalid sloc>> <invalid sloc> implicit __builtin_va_list 'struct __va_list_tag [1]'
| `-ConstantArrayType 0x5649c3ab3630 'struct __va_list_tag [1]' 1 
|   `-RecordType 0x5649c3ab34b0 'struct __va_list_tag'
|     `-Record 0x5649c3ab3428 '__va_list_tag'
`-FunctionDecl 0x5649c3ab3728 <main.c:1:1, line:9:1> line:1:5 main 'int ()'
  `-CompoundStmt 0x5649c3aff628 <col:12, line:9:1>
    |-DeclStmt 0x5649c3ab3958 <line:3:4, col:15>
    | `-VarDecl 0x5649c3ab38f8 <col:4, col:14> col:8 used a 'int [2][2]'
    |-BinaryOperator 0x5649c3ab3ad8 <line:4:4, col:14> 'int' '='
    | |-ArraySubscriptExpr 0x5649c3ab3a90 <col:4, col:10> 'int' lvalue
    | | |-ImplicitCastExpr 0x5649c3ab3a78 <col:4, col:7> 'int *' <ArrayToPointerDecay>
    | | | `-ArraySubscriptExpr 0x5649c3ab3a00 <col:4, col:7> 'int [2]' lvalue
    | | |   |-ImplicitCastExpr 0x5649c3ab39e8 <col:4> 'int (*)[2]' <ArrayToPointerDecay>
    | | |   | `-DeclRefExpr 0x5649c3ab3970 <col:4> 'int [2][2]' lvalue Var 0x5649c3ab38f8 'a' 'int [2][2]'
    | | |   `-IntegerLiteral 0x5649c3ab3998 <col:6> 'int' 0
    | | `-IntegerLiteral 0x5649c3ab3a28 <col:9> 'int' 0
    | `-IntegerLiteral 0x5649c3ab3ab8 <col:14> 'int' 10
    |-BinaryOperator 0x5649c3aff288 <line:5:4, col:14> 'int' '='
    | |-ArraySubscriptExpr 0x5649c3aff240 <col:4, col:10> 'int' lvalue
    | | |-ImplicitCastExpr 0x5649c3aff228 <col:4, col:7> 'int *' <ArrayToPointerDecay>
    | | | `-ArraySubscriptExpr 0x5649c3aff1e0 <col:4, col:7> 'int [2]' lvalue
    | | |   |-ImplicitCastExpr 0x5649c3aff1c8 <col:4> 'int (*)[2]' <ArrayToPointerDecay>
    | | |   | `-DeclRefExpr 0x5649c3aff180 <col:4> 'int [2][2]' lvalue Var 0x5649c3ab38f8 'a' 'int [2][2]'
    | | |   `-IntegerLiteral 0x5649c3aff1a8 <col:6> 'int' 0
    | | `-IntegerLiteral 0x5649c3aff208 <col:9> 'int' 1
    | `-IntegerLiteral 0x5649c3aff268 <col:14> 'int' 20
    |-BinaryOperator 0x5649c3aff3b8 <line:6:4, col:14> 'int' '='
    | |-ArraySubscriptExpr 0x5649c3aff370 <col:4, col:10> 'int' lvalue
    | | |-ImplicitCastExpr 0x5649c3aff358 <col:4, col:7> 'int *' <ArrayToPointerDecay>
    | | | `-ArraySubscriptExpr 0x5649c3aff310 <col:4, col:7> 'int [2]' lvalue
    | | |   |-ImplicitCastExpr 0x5649c3aff2f8 <col:4> 'int (*)[2]' <ArrayToPointerDecay>
    | | |   | `-DeclRefExpr 0x5649c3aff2b0 <col:4> 'int [2][2]' lvalue Var 0x5649c3ab38f8 'a' 'int [2][2]'
    | | |   `-IntegerLiteral 0x5649c3aff2d8 <col:6> 'int' 1
    | | `-IntegerLiteral 0x5649c3aff338 <col:9> 'int' 0
    | `-IntegerLiteral 0x5649c3aff398 <col:14> 'int' 40
    |-BinaryOperator 0x5649c3aff4e8 <line:7:4, col:14> 'int' '='
    | |-ArraySubscriptExpr 0x5649c3aff4a0 <col:4, col:10> 'int' lvalue
    | | |-ImplicitCastExpr 0x5649c3aff488 <col:4, col:7> 'int *' <ArrayToPointerDecay>
    | | | `-ArraySubscriptExpr 0x5649c3aff440 <col:4, col:7> 'int [2]' lvalue
    | | |   |-ImplicitCastExpr 0x5649c3aff428 <col:4> 'int (*)[2]' <ArrayToPointerDecay>
    | | |   | `-DeclRefExpr 0x5649c3aff3e0 <col:4> 'int [2][2]' lvalue Var 0x5649c3ab38f8 'a' 'int [2][2]'
    | | |   `-IntegerLiteral 0x5649c3aff408 <col:6> 'int' 1
    | | `-IntegerLiteral 0x5649c3aff468 <col:9> 'int' 1
    | `-IntegerLiteral 0x5649c3aff4c8 <col:14> 'int' 50
    `-ReturnStmt 0x5649c3aff610 <line:8:4, col:17>
      `-ImplicitCastExpr 0x5649c3aff5f8 <col:11, col:17> 'int' <LValueToRValue>
        `-ArraySubscriptExpr 0x5649c3aff5d0 <col:11, col:17> 'int' lvalue
          |-ImplicitCastExpr 0x5649c3aff5b8 <col:11, col:14> 'int *' <ArrayToPointerDecay>
          | `-ArraySubscriptExpr 0x5649c3aff570 <col:11, col:14> 'int [2]' lvalue
          |   |-ImplicitCastExpr 0x5649c3aff558 <col:11> 'int (*)[2]' <ArrayToPointerDecay>
          |   | `-DeclRefExpr 0x5649c3aff510 <col:11> 'int [2][2]' lvalue Var 0x5649c3ab38f8 'a' 'int [2][2]'
          |   `-IntegerLiteral 0x5649c3aff538 <col:13> 'int' 1
          `-IntegerLiteral 0x5649c3aff598 <col:16> 'int' 1
@yulvil
Copy link
Contributor Author

yulvil commented Oct 28, 2017

@elliotchance I will be working on this one next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant