@@ -68,6 +68,7 @@ BCType MetaCCodegen_GetBCType(metac_bytecode_ctx_t* ctx, metac_type_index_t type
6868 result .type = BCTypeEnum_i32 ;
6969 break ;
7070 case type_long :
71+ case type_long_long :
7172 result .type = BCTypeEnum_i64 ;
7273 break ;
7374 case type_size_t :
@@ -82,9 +83,6 @@ BCType MetaCCodegen_GetBCType(metac_bytecode_ctx_t* ctx, metac_type_index_t type
8283 result .type = BCTypeEnum_f52 ;
8384 break ;
8485
85- case type_long_long :
86- result .type = BCTypeEnum_i64 ;
87- break ;
8886 case type_long_double :
8987 result .type = BCTypeEnum_f106 ;
9088 break ;
@@ -99,8 +97,6 @@ BCType MetaCCodegen_GetBCType(metac_bytecode_ctx_t* ctx, metac_type_index_t type
9997 result .type = BCTypeEnum_u32 ;
10098 break ;
10199 case type_unsigned_long :
102- result .type = BCTypeEnum_u64 ;
103- break ;
104100 case type_unsigned_long_long :
105101 result .type = BCTypeEnum_u64 ;
106102 break ;
@@ -622,7 +618,7 @@ metac_bytecode_function_t MetaCCodegen_GenerateFunctionFromExp(metac_bytecode_ct
622618#ifdef PRINT_BYTECODE
623619 if (ctx -> gen == & BCGen_interface )
624620 {
625- BCGen_PrintCode ((BCGen * )c , 0 , 48 );
621+ BCGen_PrintCode ((BCGen * )c , 0 , 128 );
626622 }
627623#endif
628624
@@ -887,7 +883,21 @@ void MetaCCodegen_doDeref(metac_bytecode_ctx_t* ctx,
887883 BackendInterface gen = * ctx -> gen ;
888884 void * c = ctx -> c ;
889885 // this only works for pointers to 32bit basic types
890- gen .Load32 (c , result , addr );
886+ if (addr -> vType == BCValueType_External )
887+ {
888+ if (sizeof (void * ) == 4 )
889+ {
890+ gen .Load32 (c , result , addr );
891+ }
892+ else if (sizeof (void * ) == 8 )
893+ {
894+ gen .Load64 (c , result , addr );
895+ }
896+ }
897+ else
898+ {
899+ gen .Load32 (c , result , addr );
900+ }
891901}
892902
893903static void MetaCCodegen_doCastExpr (metac_bytecode_ctx_t * ctx ,
@@ -961,6 +971,8 @@ static void MetaCCodegen_doDotExpr(metac_bytecode_ctx_t* ctx,
961971 BCValue addr ;
962972 BCValue e1Value = {BCValueType_Unknown };
963973 BCValue offsetVal = {BCValueType_Unknown };
974+ BCValue addr_u32 ;
975+ BCValue e1Value_u32 ;
964976
965977 assert (exp -> Kind == expr_dot );
966978 assert (idxKind == type_index_struct );
@@ -980,7 +992,9 @@ static void MetaCCodegen_doDotExpr(metac_bytecode_ctx_t* ctx,
980992
981993 assert (e1Value .vType == BCValueType_StackValue );
982994
983- gen .Add3 (c , & addr , & e1Value , & offsetVal );
995+ addr_u32 = BCValue_u32 (& addr );
996+ e1Value_u32 = BCValue_u32 (& e1Value );
997+ gen .Add3 (c , & addr_u32 , & e1Value_u32 , & offsetVal );
984998
985999 MetaCCodegen_doDeref (ctx , & addr , field -> Type , result );
9861000}
@@ -1005,6 +1019,8 @@ static void MetaCCodegen_doArrowExpr(metac_bytecode_ctx_t* ctx,
10051019 BCValue e1Value = {BCValueType_Unknown };
10061020 BCValue offsetVal = {BCValueType_Unknown };
10071021 bool isExternal = false;
1022+ BCValue e1Value_u32 ;
1023+ BCValue addr_u32 ;
10081024
10091025 assert (idxKind == type_index_ptr );
10101026 assert (exp -> Kind == expr_arrow || exp -> Kind == expr_dot );
@@ -1037,7 +1053,10 @@ static void MetaCCodegen_doArrowExpr(metac_bytecode_ctx_t* ctx,
10371053 || e1Value .vType == BCValueType_HeapValue
10381054 || e1Value .vType == BCValueType_External );
10391055
1040- gen .Add3 (c , & addr , & e1Value , & offsetVal );
1056+ addr_u32 = BCValue_u32 (& addr );
1057+ e1Value_u32 = BCValue_u32 (& e1Value );
1058+ gen .Add3 (c , & addr_u32 , & e1Value_u32 , & offsetVal );
1059+
10411060 gen .Comment (c , "Address pointer was just generated as the result of an Add3" );
10421061 MetaCCodegen_doDeref (ctx , & addr , field -> Type , result );
10431062 gen .Comment (c , "doDref was executed ... " );
@@ -1169,7 +1188,8 @@ static void MetaCCodegen_doExpr(metac_bytecode_ctx_t* ctx,
11691188 if (exp -> E2 -> Kind == expr_signed_integer
11701189 && (exp -> E2 -> ValueI64 >= INT32_MIN && exp -> E2 -> ValueI64 <= INT32_MAX ))
11711190 {
1172- rhs = imm32_ (cast (int32_t )exp -> E2 -> ValueI64 , true);
1191+ bool isSigned = TypeIndex_isSigned (exp -> E2 -> TypeIndex );
1192+ rhs = imm32_ (cast (int32_t )exp -> E2 -> ValueI64 , isSigned );
11731193 }
11741194 else
11751195 {
0 commit comments