Repository navigation
Expand file tree
/
Copy pathcommon.h
More file actions
1649 lines (1371 loc) · 60.7 KB
/
Copy pathcommon.h
File metadata and controls
1649 lines (1371 loc) · 60.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef __COMMON_H__
#define __COMMON_H__
#include <neo-c.h>
#define NEO_IS_ASCII_ALPHA(c) ((((unsigned char)(c)) >= 'a' && ((unsigned char)(c)) <= 'z') || (((unsigned char)(c)) >= 'A' && ((unsigned char)(c)) <= 'Z'))
#define NEO_IS_ASCII_DIGIT(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '9')
#define NEO_IS_ASCII_ALNUM(c) (NEO_IS_ASCII_ALPHA(c) || NEO_IS_ASCII_DIGIT(c))
#define NEO_IS_ASCII_PUNCT(c) ((((unsigned char)(c)) >= '!' && ((unsigned char)(c)) <= '/') || (((unsigned char)(c)) >= ':' && ((unsigned char)(c)) <= '@') || (((unsigned char)(c)) >= '[' && ((unsigned char)(c)) <= '`') || (((unsigned char)(c)) >= '{' && ((unsigned char)(c)) <= '~'))
#define NEO_IS_PARSE_TAIL_CHAR(c) ((NEO_IS_ASCII_PUNCT(c) || (c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\0' || (c) == '\r') && (c) != '_')
#define NEO_IS_WORD_HEAD_CHAR(c) (NEO_IS_ASCII_ALPHA(c) || (c) == '_' || (c) == '$')
#define NEO_IS_WORD_BODY_CHAR(c) (NEO_IS_ASCII_ALNUM(c) || (c) == '_' || (c) == '$')
#define FUN_VERSION_MAX 128
#define GENERICS_TYPE_MAX 12
#define METHOD_GENERICS_TYPE_MAX 7
extern bool gComeDebug;
extern bool gComeUniq;
extern bool gComeC;
extern bool gComePthread;
extern bool gComeNet;
extern bool gComeMalloc;
extern bool gComeBareMetal;
extern bool gComeMicro;
extern bool gComeMicro32;
extern bool gComeMicro16;
extern bool gComeMicro8;
extern bool gComeMicroRam8K;
extern bool gComeMemleakStacktrace;
extern bool gComeCPlusPlus;
extern bool gComelang;
extern bool gComeSafe;
extern bool gPortableC;
extern bool gComeLowMemory;
struct sType;
struct sClass;
struct sInfo;
struct sVar;
struct sRightValueObject;
struct sVarTable;
struct sBlock;
char* parsecmp_tail(const char* p2, sInfo* info=info);
char* parsecmp_forward(const char* p2, sInfo* info=info);
void add_parse_variable_to_table(char* name, sInfo* info=info);
interface sNode
{
bool compile(sInfo* info);
int sline();
int sline_real();
string sname();
bool terminated();
string kind();
sNode* left_value();
};
uniq class sClass
{
bool mStruct;
bool mFloat;
bool mUnion;
bool mGenerics;
bool mMethodGenerics;
bool mEnum;
bool mProtocol;
bool mNumber;
bool mUniq;
bool mTypeName;
bool mAnonymous;
string mName;
int mGenericsNum;
int mMethodGenericsNum;
list<tuple2<string, sType*%>*%>*% mFields;
string mParentClassName;
string mAttribute;
bool mIter;
new(string name, bool number=false, bool union_=false, bool generics=false, bool method_generics=false, bool protocol_=false, bool struct_=false, bool float_=false, int generics_num=-1, int method_generics_num=-1, bool enum_=false, bool uniq_=false, bool typename=false, sInfo* info=info, bool iter_=false)
{
self.mNumber = number;
self.mStruct = struct_;
self.mUnion = union_;
self.mGenerics = generics;
self.mMethodGenerics = method_generics;
self.mEnum = false;
self.mProtocol = protocol_;
self.mFloat = float_;
self.mEnum = enum_;
self.mTypeName = typename;
self.mUniq = uniq_;
self.mName = string(name);
self.mGenericsNum = generics_num;
self.mMethodGenericsNum = method_generics_num;
self.mFields = new list<tuple2<string, sType*%>*%>();
self.mIter = iter_;
}
};
uniq class sType
{
sClass* mClass;
_weak sType*% mOriginalLoadVarType;
_weak sType*% mChannelType;
_weak list<sType*%>*% mGenericsTypes;
_weak sType*% mNoSolvedGenericsType;
sNode*% mSizeNum;
sNode*% mAlignas;
bool mAlignasDouble;
string mTupleName;
string mAttribute;
string mVarAttribute;
string mMiddleAttribute;
string mPointerAttribute;
bool mNew;
bool mAllocaValue;
bool mUnsigned;
bool mShort;
bool mLong;
bool mLongLong;
bool mConstant;
bool mAtomic;
bool mThreadLocal;
bool mNorecord;
bool mThread;
bool mComplex;
bool mRegister;
bool mVolatile;
bool mNoreturn;
bool mStatic;
bool mWeak;
bool mUniq;
bool mExtern;
bool mRestrict;
bool mHeap;
bool mChannel;
bool mDefferRightValue;
bool mNoHeap;
bool mRefference;
bool mSlice;
bool mOptional;
bool mNoCallingDestructor;
bool mTypeName;
bool mAnonymous;
string mAnonymousName;
bool mInnerStruct;
string mInnerStructName;
bool mAnonymousVarName;
bool mInline;
string mAsmName;
bool mTypedef;
bool mMultipleTypes;
list<sNode*%>*% mArrayNum;
list<sNode*%>*% mVarNameArrayNum;
list<int>*% mArrayStatic;
list<int>*% mArrayRestrict;
int mPointerNum;
int mFunctionPointerNum;
int mArrayPointerNum;
bool mPointerParen;
bool mMinusPointerNum;
_weak sType*% mTypedefOriginalType;
string mOriginalTypeName;
int mOriginalTypePointerNum;
int mOriginalTypePointerHeap;
bool mArrayPointerType;
//// lambda ///
_weak list<sType*%>*% mParamTypes;
list<string>*% mParamNames;
_weak sType*% mResultType;
bool mVarArgs;
sNode*% mTypeOfNode;
list<sNode*%>*% mHeapArrayNum;
new(string name, bool heap=false, sInfo* info=info, bool unsigned_=false, int pointer_num_=0)
{
int pointer_num = pointer_num_;
char* p = borrow name;
while(*p) {
if(xisalpha(*p) || *p == '_') {
p++;
}
else {
break;
}
}
while(*p == '*') {
pointer_num++;
p++;
}
string name2 = string(name).substring(0, -pointer_num+pointer_num_-1);
sClass* klass = borrow info.classes[string(name2)];
sClass* generics_class = borrow info.generics_classes[name2];
if(klass == null && generics_class == null) {
warning_msg(info, "class not found(%s)(1)\n", name2);
}
if(klass) {
self.mClass = klass;
}
else {
sClass*% klass2 = new sClass;
klass2->mName = string(name);
info.classes.insert(string(name), klass2);
self.mClass = borrow info.classes[string(name)];
}
self.mNoSolvedGenericsType = null;
self.mOriginalLoadVarType = null;
self.mGenericsTypes = new list<sType*%>();
self.mArrayNum = new list<sNode*%>();
self.mVarNameArrayNum = new list<sNode*%>();
self.mArrayStatic = new list<int>();
self.mArrayRestrict = new list<int>();
self.mParamTypes = new list<sType*%>();
self.mParamNames = new list<string>();
self.mOriginalTypeName = s"";
self.mVarArgs = false;
self.mResultType = null;
self.mUnsigned = unsigned_;
self.mConstant = false;
self.mRegister = false;
self.mVolatile = false;
self.mStatic = false;
self.mRestrict = false;
self.mLongLong = false;
self.mHeap = heap;
self.mNoHeap = false;
self.mPointerNum = pointer_num;
self.mSizeNum = null;
self.mTypeOfNode = null;
self.mMiddleAttribute = s"";
self.mPointerAttribute = s"";
}
};
struct sVar
{
string mName;
string mCValueName;
sType*% mType;
bool mGlobal;
bool mAllocaValue;
bool mNoFree;
string mFunName;
bool no_output_come_code;
};
uniq class sFun
{
string mName;
sType*% mResultType;
_weak list<sType*%>*% mParamTypes;
list<string>*% mParamNames;
list<string>*% mParamDefaultParametors;
sType*% mLambdaType;
list<sVar*%>*% mAllVar;
sBlock*% mBlock;
string mTextBlock;
string mTextBlockSName;
int mTextBlockSline;
buffer*% mSource;
buffer*% mSourceHead;
buffer*% mSourceHead2;
buffer*% mSourceEnd;
bool mStatic;
bool mInline;
bool mUniq;
bool mExternal;
bool mVarArgs;
bool mNoResultType;
bool mConstFun;
string mAttribute;
string mMiddleAttribute;
string mFunAttribute;
bool mGenericsFun;
bool mDefineReturnVar;
string mAsmFun;
new(string name, sType*% result_type, list<sType*%>*% param_types, list<string>*% param_names, list<string>%* param_default_parametors, bool external, bool var_args, sBlock*% block, bool static_, sInfo* info, bool inline_, bool uniq_=false, string attribute=s"", string fun_attribute=s"", bool const_fun=false, string text_block=null, string generics_sname=null, int generics_sline=0, bool immutable_=false, string asm_fun=s"")
{
self.mName = name;
self.mResultType = result_type;
self.mParamTypes = param_types;
self.mParamNames = param_names;
self.mParamDefaultParametors = param_default_parametors;
self.mExternal = external;
self.mVarArgs = var_args;
self.mStatic = static_;
self.mInline = inline_;
self.mUniq = uniq_;
self.mConstFun = const_fun;
self.mAllVar = new list<sVar*%>();
self.mLambdaType = new sType(s"lambda");
self.mAsmFun = asm_fun;
foreach(it, param_types) {
self.mLambdaType.mParamTypes.push_back(clone it);
}
foreach(it, param_names) {
self.mLambdaType.mParamNames.push_back(clone it);
}
self.mLambdaType.mResultType = result_type;
self.mLambdaType.mVarArgs = var_args;
self.mSource = new buffer();
self.mSourceHead = new buffer();
self.mSourceHead2 = new buffer();
self.mSourceEnd = new buffer();
self.mBlock = block;
self.mTextBlock = text_block;
self.mTextBlockSName = generics_sname;
self.mTextBlockSline = generics_sline;
if((result_type->mClass->mNumber || result_type->mClass->mName === "double" || result_type->mClass->mName === "float" || result_type->mClass->mStruct) && result_type->mPointerNum == 0) {
self.mNoResultType = true;
}
self.mAttribute = attribute;
self.mMiddleAttribute = s"";
self.mFunAttribute = fun_attribute;
}
};
uniq class sGenericsFun
{
sType*% mImplType;
list<string>*% mGenericsTypeNames;
list<string>*% mMethodGenericsTypeNames;
string mName;
sType*% mResultType;
_weak list<sType*%>*% mParamTypes;
list<string>*% mParamNames;
list<string>*% mParamDefaultParametors;
string mBlock;
int mSLine;
bool mVarArgs;
bool mGenerate;
string mGenericsSName;
int mGenericsSLine;
bool mConstFun;
new(sType*% impl_type, list<string>* generics_type_names, list<string>* method_generics_type_names, string name, sType*% result_type, list<sType*%>*% param_types, list<string>*% param_names, list<string>*% param_default_parametors, bool var_args, string block, sInfo* info, string generics_sname, int generics_sline, bool const_fun=false)
{
self.mGenericsTypeNames = clone generics_type_names;
self.mMethodGenericsTypeNames = clone method_generics_type_names;
self.mName = name;
self.mResultType = result_type;
self.mParamTypes = param_types;
self.mParamNames = param_names;
self.mParamDefaultParametors = param_default_parametors;
self.mVarArgs = var_args;
self.mBlock = block;
self.mSLine = info.sline;
self.mGenericsSName = string(generics_sname);
self.mGenericsSLine = generics_sline;
self.mConstFun = const_fun;
}
};
uniq class CVALUE
{
string c_value;
_weak sType*% type;
sVar* var;
sRightValueObject* right_value_objects;
string c_value_without_right_value_objects;
string c_value_without_cast_object_value;
bool mLoadField;
bool mCastValue;
bool mNullValue;
string c_value_without_null_checker;
new() {
}
};
uniq class sModule
{
buffer*% mSourceHead;
buffer*% mSource;
string mLastCode;
string mLastCode2;
map<string, string>*% mHeader;
new() {
self.mSourceHead = new buffer();
self.mSource = new buffer();
self.mLastCode = null;
self.mLastCode2 = null;
self.mHeader = new map<string, string>();
}
};
uniq class sVarTable
{
map<string, sVar*%>*% mVars;
bool mGlobal;
struct sVarTable* mParent;
new(bool global, sVarTable* parent)
{
self.mVars = new map<string, sVar*%>();
self.mGlobal = global;
self.mParent = parent;
}
void finalize()
{
delete self.mVars;
}
};
uniq class sBlock
{
list<sNode*%>*% mNodes;
sVarTable*% mVarTable;
bool mOmitSemicolon;
new() {
self.mNodes = new list<sNode*%>();
}
};
struct sRightValueObject
{
_weak sType*% mType;
string mVarName;
string mFunName;
char* mSName;
int mSLine;
bool mFreed;
int mID;
int mBlockLevel;
bool mStored;
bool mDecrementRefCount;
_weak sType*% mObjType;
string mObjValue;
_weak sVar* mObjVar;
bool mNoFree;
};
struct sInfo
{
char* p;
char* head;
buffer*% source;
char* end;
string sname;
string sname_at_head;
string base_sname;
int sline;
int err_num;
int warning_num;
string clang_option;
string cpp_option;
string linker_option;
string linker_option2;
bool no_output_err;
bool no_output_come_code;
bool undefined_array_num_var;
sFun* come_fun;
sFun* caller_fun;
int caller_line;
string caller_sname;
int block_level;
map<string, sFun*%>*% funcs;
map<string, sFun*%>*% uniq_funcs;
map<string, sGenericsFun*%>*% generics_funcs;
map<string, sClass*%>*% classes;
map<string, sType*%>*% types;
map<string, sClass*%>*% generics_classes;
map<string, buffer*%>*% struct_definition;
map<string, buffer*%>*% c_include_definition;
map<string, buffer*%>*% var_definition;
map<string, buffer*%>*% previous_struct_definition;
map<string, buffer*%>*% typedef_definition;
map<string, sType*%>*% named_child_struct;
map<string, string>*% reflection_vars;
sModule*% module;
sType*% type;
list<sRightValueObject*%>*% right_value_objects;
sType*% generics_type;
_weak list<sType*%>*% method_generics_types;
list<CVALUE*%>*% stack;
sType*% come_function_result_type;
sType*% come_method_block_function_result_type;
sVarTable* lv_table;
sVarTable*% gv_table;
bool no_comma;
bool no_assign;
bool no_label;
bool last_statment_is_return;
list<string>*% generics_type_names;
list<string>*% method_generics_type_names;
sType*% impl_type;
sType*% class_type;
int current_stack_num;
int num_method_block;
sClass* current_stack_frame_struct;
bool define_struct;
bool in_typedef;
string output_file_name;
sVarTable* current_loop_vtable;
bool verbose;
int num_current_stack;
int num_source_files;
int max_source_files;
bool writing_source_file_position;
sType*% function_result_type;
bool in_class;
map<string,string>*% module_params;
bool constructor_;
sClass* defining_class;
bool array_initializer;
bool va_arg;
bool in_fun_param;
bool inhibits_output_code;
bool inhibits_output_code2;
bool in_generics_fun;
bool in_clone_object;
bool in_conditional_operator;
list<sVar*%>*% match_it_var;
int sline_top;
sFun* calling_fun;
map<string, string>*% uniq_definition;
bool in_top_level;
bool remove_comment;
int sline_real;
int sline_block;
bool m5stack_cpp;
bool pico_cpp;
bool baremetal_cpp;
bool gcc_compiler;
bool in_method_block;
bool in_offsetof;
int right_value_num;
int right_value_max;
bool in_conditional;
int num_conditional;
int max_conditional;
string pragma;
list<string>*% pragma_pack_stack;
bool in_refference;
buffer*% paren_block_buffer;
bool in_typeof;
bool in_store_array;
int parse_struct_recursive_count;
bool exp_value;
buffer*% if_expression_buffer;
string if_result_value_name;
bool if_result_value_name_defined;
sType*% if_result_type;
bool defer_block;
buffer*% loop_expression_buffer;
string loop_result_value_name;
bool loop_result_value_name_defined;
sType*% loop_result_type;
string iter_buffer;
string iter_next;
string iter_block;
bool use_iter_next;
sType*% iter_type;
int id;
bool in_case_optional_load;
};
uniq class sNodeBase
{
int sline;
string sname;
int sline_real;
new(sInfo* info=info) {
self.sline = info.sline;
self.sname = string(info.sname);
self.sline_real = info.sline_real;
}
int sline(sInfo* info=info) {
return self.sline;
}
int sline_real(sInfo* info=info) {
return self.sline_real;
}
bool terminated() {
return false;
}
string sname(sInfo* info=info) {
return self.sname;
}
sNode* left_value() {
return null;
}
};
uniq class sCurrentNode extends sNodeBase
{
new(sInfo* info)
{
self.super();
}
int sline(sInfo* info)
{
return self.sline;
}
string sname(sInfo* info)
{
return self.sname;
}
string kind()
{
return string("sCurrentNode");
}
bool compile(sInfo* info)
{
info->current_stack_num++;
string class_name = xsprintf("__current_stack%d__", info->current_stack_num);
sClass*% current_stack = new sClass(name: class_name, struct_:true);
sVarTable* vtable = info->lv_table;
while(vtable) {
foreach(it, vtable.mVars) {
char* key = it;
sVar* value = borrow vtable.mVars[string(key)];
sType*% type2 = clone value.mType;
type2.mPointerNum++;
tuple2<string, sType*%>*% item = t(string(value.mCValueName), type2);
if(value.mCValueName != null) {
if(strcmp(value.mCValueName, "__list_values") == 0)
{
}
else if(strcmp(value.mCValueName, "__map_keys") == 0)
{
}
else if(strcmp(value.mCValueName, "__map_element") == 0)
{
}
else if(strncmp(value.mCValueName, "_o2_saved_", 10) == 0)
{
}
else if(value.mType.mClass.mName === "va_list" || value.mType.mClass.mName === "__builtin_va_list")
{
}
else if(type2->mArrayPointerType) {
sType*% type3 = clone type2;
type3->mPointerNum--;
//type3->mArrayPointerType = false;
type3->mArrayPointerNum++;
tuple2<string, sType*%>*% item2 = t(string(value.mCValueName), type3);
current_stack.mFields.push_back(clone item2);
}
else if(type2->mArrayNum.length() > 0) {
sType*% type3 = clone type2;
type3->mPointerNum--;
type3->mArrayPointerNum++;
tuple2<string, sType*%>*% item2 = t(string(value.mCValueName), type3);
current_stack.mFields.push_back(clone item2);
}
else {
current_stack.mFields.push_back(clone item);
}
}
}
vtable = vtable->mParent;
}
output_struct(current_stack, null, info);
info.classes.insert(class_name, current_stack);
add_come_code_at_function_head(info, "struct %s __current_stack%d__;\n", class_name, info->current_stack_num);
add_come_code_at_function_head2(info, "memset(&__current_stack%d__, 0, sizeof(struct %s));\n", info->current_stack_num, class_name);
vtable = info->lv_table;
add_come_code(info, "({");
while(vtable) {
foreach(it, vtable.mVars) {
char* key = it;
sVar* value = borrow vtable.mVars[key];
sType*% type2 = clone value.mType;
tuple2<string, sType*%>*% item = t(value.mCValueName, type2);
if(value.mCValueName != null) {
if(strcmp(value.mCValueName, "__list_values") == 0)
{
}
else if(strcmp(value.mCValueName, "__map_keys") == 0)
{
}
else if(strcmp(value.mCValueName, "__map_element") == 0)
{
}
else if(strncmp(value.mCValueName, "_o2_saved_", 10) == 0)
{
}
else if(value.mType.mClass.mName === "va_list" || value.mType.mClass.mName === "__builtin_va_list")
{
}
else {
if(value->mFunName === info.come_fun.mName) {
if(type2->mClass->mName === "lambda") {
add_come_code(info, "__current_stack%d__.%s = %s;\n", info->current_stack_num, value.mCValueName, value.mCValueName);
}
else {
add_come_code(info, "__current_stack%d__.%s = &%s;\n", info->current_stack_num, value.mCValueName, value.mCValueName);
}
}
else {
if(type2->mClass->mName === "lambda") {
add_come_code(info, "__current_stack%d__.%s = parent->%s;\n", info->current_stack_num, value.mCValueName, value.mCValueName);
}
else {
add_come_code(info, "__current_stack%d__.%s = parent->%s;\n", info->current_stack_num, value.mCValueName, value.mCValueName);
}
}
}
}
}
vtable = vtable->mParent;
}
add_come_code(info, "})");
// if(info->in_conditional) {
add_come_code(info, ",");
/*
}
else {
add_come_code(info, ";");
}
*/
CVALUE*% come_value = new CVALUE();
come_value.c_value = xsprintf("&__current_stack%d__", info->current_stack_num);
come_value.type = new sType(class_name);
come_value.var = null;
add_come_last_code(info, "%s;\n", come_value.c_value);
info.stack.push_back(come_value);
return true;
}
};
/////////////////////////////////////////////////////////////////////
/// 02transpile.c ///
/////////////////////////////////////////////////////////////////////
sNode*% parse_iterator_it(sInfo* info=info);
bool transpile_conditional_with_free_right_object_value(sNode* node, sInfo* info=info);
int err_msg(sInfo* info, const char* msg, ...);
int warning_msg(sInfo* info, const char* msg, ...);
int expected_next_character(char c, sInfo* info=info);;
bool node_compile(sNode* node, sInfo* info=info);
bool node_conditional_compile(sNode* node, sInfo* info=info);
int come_main(int argc, char** argv);
string make_type_name_string(sType* type, sInfo* info=info, bool no_static=false, bool cast_type=false, bool typedef_extended=false, bool nullchecker=false);
string make_come_type_name_string(sType* type, sInfo* info=info);
string make_come_define_var(sType* type, char* name, sInfo* info=info);
/////////////////////////////////////////////////////////////////////
/// 03output_code.c ///
/////////////////////////////////////////////////////////////////////
sType*% get_no_solved_type(sType* type);
sType*% get_no_solved_type2(sType* type);
string header_function(sFun* fun, sInfo* info);
bool output_source_file(sInfo* info);
void show_type(sType* type, sInfo* info=info);
string create_generics_name(sType* generics_type, sInfo* info);
void add_last_code_to_source(sInfo* info);
void add_come_code_at_function_head(sInfo* info, const char* code, ...);
void add_come_code_at_come_header(sInfo* info, string id, const char* msg, ...);
void add_come_code_no_indent(sInfo* info, const char* msg, ...);
void add_come_code_at_come_struct_header(sInfo* info, string id, const char* msg, ...);
void add_come_code_at_function_head2(sInfo* info, const char* code, ...);
void add_come_code(sInfo* info, const char* msg, ...);
void add_come_last_code(sInfo* info, const char* msg, ...);
void add_come_last_code2(sInfo* info, const char* msg, ...);
void dec_stack_ptr(int value=1, sInfo* info=info);
CVALUE*% get_value_from_stack(int offset, sInfo* info);
string make_define_var(sType* type, char* name, sInfo* info=info, bool no_static=false, bool in_typedef=false);
string make_var_name(sType* type, char* name, sInfo* info=info, bool no_static=false);
void transpiler_clear_last_code(sInfo* info);
bool output_header_file(sInfo* info);
/////////////////////////////////////////////////////////////////////
/// 04heap.c ///
/////////////////////////////////////////////////////////////////////
void on_drop_object(sType* type, char* obj, sInfo* info=info);
void on_load_object(sType* type, char* obj, sInfo* info=info);
sType*% solve_method_generics(sType* type, sInfo* info);
bool existance_free_right_value_objects(sInfo* info);
bool existance_free_objects_on_return(sBlock* current_block, sInfo* info, sVar* ret_value, bool top_block);
void std_move(sType* left_type, sType* right_type, CVALUE* right_value, sInfo* info=info);
bool create_equals_method(sType* type, sInfo* info);
bool create_operator_equals_method(sType* type, sInfo* info);
bool create_operator_not_equals_method(sType* type, sInfo* info);
bool require_explicit_method_in_low_memory_mode(sType* type, const char* fun_name, sInfo* info=info);
sType*% solve_generics(sType* type, sType* generics_type, sInfo* info);
sVar* get_variable_from_table(sVarTable* table, char* name);
void free_objects_on_return(sBlock* current_block, sInfo* info, sVar* ret_value, bool top_block, bool ret_value_is_field=false);
void free_objects_of_match_lv_tables(sInfo* info);
void free_objects_on_break(sInfo* info);
void free_object(
sType* type, char* obj, bool no_decrement, bool no_free, sInfo* info, bool ret_value=false);
sType*%, string clone_object(sType* type, char* obj, sInfo* info);
void free_right_value_objects(sInfo* info);
void free_objects(sVarTable* table, sVar* ret_value, sInfo* info, bool ret_value_is_field=false);
void append_object_to_right_values(CVALUE* come_value, sType* type, sInfo* info, bool decrement_ref_count=false, sType* obj_type=null, char* obj_value=null, sVar* obj_var=null);
void remove_object_from_right_values(int right_value_num, sInfo* info);
void remove_value_from_right_value_objects(CVALUE* come_value, sInfo* info=info);
string increment_ref_count_object(sType* type, char* obj, sInfo* info);
void decrement_ref_count_object(sType* type, char* obj, sInfo* info, bool no_free=false);
/////////////////////////////////////////////////////////////////////
/// 05function.c ///
/////////////////////////////////////////////////////////////////////
void transpile_toplevel(bool block=false, sInfo* info=info);
sNode*% reverse_node(sNode*% value, sInfo* info);
sFun*% compile_uniq_function(sFun* fun, sInfo* info=info);
sNode*% cast_node(sType* type, sNode*% node, sInfo* info=info);
sNode*% create_defference_node(sNode*% value, bool quote, sInfo* info);
sNode*% reffence_node(sNode*% value, sInfo* info);
string,sGenericsFun* make_method_generics_function(string fun_name, list<sType*%>* method_generics_types, sInfo* info);
sNode*% create_return_node(sNode*% value, sInfo* info=info);
sNode*% post_position_operator(sNode*% node, sInfo* info);
bool create_method_generics_fun(string fun_name, sGenericsFun* generics_fun, sInfo* info);
bool operator_overload_fun_self(sType* type, const char* fun_name, sNode*% node, CVALUE* left_value, sInfo* info);
bool is_ref_or_optional_type_for_operator(sType* type, sInfo* info=info);
bool reject_ref_optional_unary_operator(const char* op_name, CVALUE* value, sInfo* info=info);
bool reject_ref_optional_binary_operator(const char* op_name, CVALUE* left_value, CVALUE* right_value, sInfo* info=info);
void caller_begin(sInfo* info=info);
void caller_end(sInfo* info=info);
sNode*% craete_logical_denial(sNode*% node, sInfo* info);
tuple3<sType*%,string,bool>*% backtrace_parse_type(bool parse_variable_name=false,sInfo* info=info);
void skip_pointer_attribute(sInfo* info=info);
void skip_paren(sInfo* info);
sNode*% parse_normal_block(bool clang=false, bool unsafe_block=false, sInfo* info=info);
void cast_type(sType* left_type, sType* right_type, CVALUE* come_value, sInfo* info=info);
bool check_assign_type(const char* msg, sType* left_type, sType* right_type, CVALUE* come_value, sInfo* info=info);
string,string parse_attribute(sInfo* info=info,bool parse_function_attribute=false);
string,string parse_function_attribute(sInfo* info=info);
sNode*% get_number(bool minus, sInfo* info);
sNode*% get_oct_number(sInfo* info);
sNode*% get_hex_number(bool minus, sInfo* info);
sNode*% create_int_node(string value, sInfo* info);
tuple4<list<sType*%>*%, list<string>*%, list<string>*%, bool>*% parse_params(sInfo* info, bool in_constructor_=false);
sFun*,string create_pthread_fun(sType* type, char* fun_name, sInfo* info);
sFun*,string create_finalizer_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_to_string_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_cloner_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_equals_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_operator_equals_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_operator_not_equals_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_not_equals_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_get_hash_key_automatically(sType* type, const char* fun_name, sInfo* info);
sFun*,string create_compare_automatically(sType* type, const char* fun_name, sInfo* info);
string skip_block(sInfo* info=info, bool return_self_at_last=false);
bool is_contained_generics_class(sType* type, sInfo* info);
bool is_type_name(char* buf, sInfo* info=info);
bool parsecmp(const char* p2, sInfo* info=info)
char* parsecmp_forward(const char* p2, sInfo* info=info);
int match_common_attribute_keyword_len(const char* p);
string parse_word(bool digits=false, sInfo* info=info);
string backtrace_parse_word(sInfo* info=info);
void skip_spaces_and_lf(sInfo* info=info);
void skip_spaces_and_lf2(sInfo* info=info);
string, bool create_generics_fun(string fun_name, sGenericsFun* generics_fun, sType* generics_type, sInfo* info);
tuple3<sType*%,string,bool>*% parse_type(sInfo* info=info, bool parse_variable_name=false, bool parse_multiple_type=true, bool in_function_parametor=false)
tuple2<sType*%, string>*% parse_variable_name_on_multiple_declare(sType* base_type_name, bool first, sInfo* info);
sBlock*% parse_block(sInfo* info=info, bool return_self_at_last=false, bool in_function=false);
bool is_function_attribute_word(char* buf);
int transpile_block(sBlock* block, list<sType*%>* param_types, list<string>* param_names, sInfo* info, bool no_var_table=false, bool loop_block=false, bool if_result_value=false, bool iter_=false, bool loop_result_type=false);
void arrange_stack(sInfo* info, int top);
sNode*% parse_function(sInfo* info);
sNode*% parse_function_call(char* fun_name, sInfo* info, bool come_=false);
sNode*% statment(sInfo* info=info);
sNode*% top_level(char* buf, char* head, int head_sline, sInfo* info) version 1;
sNode*% top_level(char* buf, char* head, int head_sline, sInfo* info) version 99;
sNode*% expression_node(sInfo* info=info) version 1;