forked from BruceDLong/CodeDog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxlator_Java.py
More file actions
941 lines (868 loc) · 45.7 KB
/
xlator_Java.py
File metadata and controls
941 lines (868 loc) · 45.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
#This file, along with Lib_Java.py specify to the CodeGenerater how to compile CodeDog source code into Java source code.
import progSpec
import codeDogParser
from progSpec import cdlog, cdErr, logLvl
from codeGenerator import codeItemRef, codeUserMesg, codeAllocater, codeParameterList, makeTagText, codeAction, getModeStateNames, codeExpr, convertType, generateGenericStructName, getGenericTypeSpec
###### Routines to track types of identifiers and to look up type based on identifier.
def getContainerType(typeSpec, actionOrField):
idxType=''
if progSpec.isNewContainerTempFunc(typeSpec):
containerTypeSpec = progSpec.getContainerSpec(typeSpec)
if 'owner' in containerTypeSpec: owner=progSpec.getOwnerFromTypeSpec(containerTypeSpec)
else: owner='me'
if 'indexType' in containerTypeSpec:
if 'IDXowner' in containerTypeSpec['indexType']:
idxOwner=containerTypeSpec['indexType']['IDXowner'][0]
idxType=containerTypeSpec['indexType']['idxBaseType'][0][0]
idxType=applyOwner(typeSpec, idxOwner, idxType, '')
else:
idxType=containerTypeSpec['indexType']['idxBaseType'][0][0]
else:
idxType = progSpec.getFieldType(typeSpec)
adjustBaseTypes(idxType, True)
if(isinstance(containerTypeSpec['datastructID'], str)):
datastructID = containerTypeSpec['datastructID']
else: # it's a parseResult
datastructID = containerTypeSpec['datastructID'][0]
elif progSpec.isOldContainerTempFunc(typeSpec): print("Deprecated container type:", typeSpec); exit(2);
else:
owner = progSpec.getOwnerFromTypeSpec(typeSpec)
datastructID = 'None'
return [datastructID, idxType, owner]
def adjustBaseTypes(fieldType, isContainer):
javaType = ''
if fieldType !="":
if isContainer:
if fieldType=='int': javaType = 'Integer'
elif fieldType=='long': javaType = 'Long'
elif fieldType=='double': javaType = 'Double'
elif fieldType=='timeValue': javaType = 'Long' # this is hack and should be removed ASAP
elif fieldType=='int64': javaType = 'Long'
elif fieldType=='string': javaType = 'String'
elif fieldType=='uint': javaType = 'Integer'
else:
javaType = fieldType
else:
if(fieldType=='int32'): javaType= 'int'
elif(fieldType=='uint32'or fieldType=='uint'): javaType='int' # these should be long but Java won't allow
elif(fieldType=='int64' or fieldType=='uint64'):javaType= 'long'
elif(fieldType=='uint8' or fieldType=='uint16'):javaType='uint32'
elif(fieldType=='int8' or fieldType=='int16'): javaType='int32'
elif(fieldType=='char' ): javaType= 'char'
elif(fieldType=='bool' ): javaType= 'boolean'
elif(fieldType=='string'): javaType= 'String'
else: javaType=progSpec.flattenObjectName(fieldType)
return javaType
def isJavaPrimativeType(fieldType):
if fieldType=="int" or fieldType=="boolean" or fieldType=="float" or fieldType=="double" or fieldType=="long" or fieldType=="char": return True
return False
def applyOwner(typeSpec, owner, langType, actionOrField, varMode):
if owner=='const':
if actionOrField=="field": langType = "final static "+langType
else: langType = "final "+langType
elif owner=='me':
langType = langType
elif owner=='my':
langType = langType
elif owner=='our':
langType = langType
elif owner=='their':
langType = langType
elif owner=='itr':
itrType = progSpec.fieldTypeKeyword(progSpec.getItrTypeOfDataStruct(langType, typeSpec))
langType = itrType
if itrType=='nodeType':
print("TODO: design iterators in Java!!!!!!!!!!!!!!!!!!!!!!!!!!",itrType)
exit(2)
elif owner=='we':
langType = 'static '+langType
else:
cdErr("ERROR: Owner of type not valid '" + owner + "'")
return langType
def getUnwrappedClassOwner(classes, typeSpec, fieldType, varMode, ownerIn):
ownerOut = ownerIn
baseType = progSpec.isWrappedType(classes, fieldType)
if baseType!=None: # TODO: When this is all tested and stable, un-hardcode and optimize this!!!!!
if 'ownerMe' in baseType:
ownerOut = 'their'
else:
ownerOut=ownerIn
return ownerOut
def getReqTagString(classes, typeSpec):
reqTagString = ""
reqTagList = progSpec.getReqTagList(typeSpec)
if(reqTagList != None):
reqTagString = "<"
count = 0
for reqTag in reqTagList:
reqOwner = progSpec.getOwnerFromTemplateArg(reqTag)
varTypeKeyword = progSpec.getTypeFromTemplateArg(reqTag)
unwrappedOwner=getUnwrappedClassOwner(classes, typeSpec, varTypeKeyword, 'alloc', reqOwner)
unwrappedTypeKeyword = progSpec.getUnwrappedClassFieldTypeKeyWord(classes, varTypeKeyword)
reqType = adjustBaseTypes(unwrappedTypeKeyword, True)
if(count>0):reqTagString += ", "
reqTagString += reqType
count += 1
reqTagString += ">"
return reqTagString
def xlateLangType(classes, typeSpec, owner, fieldType, varMode, actionOrField, xlator):
# varMode is 'var' or 'arg' or 'alloc'. Large items are passed as pointers
if progSpec.isOldContainerTempFunc(typeSpec): print("Deprecated container type:", typeSpec); exit(2);
if(isinstance(fieldType, str)):
langType = adjustBaseTypes(fieldType, progSpec.isNewContainerTempFunc(typeSpec))
else: langType = progSpec.flattenObjectName(fieldType[0])
langType = applyOwner(typeSpec, owner, langType, actionOrField, varMode)
if langType=='TYPE ERROR': print(langType, owner, fieldType);
InnerLangType = langType
reqTagString = getReqTagString(classes, typeSpec)
langType += reqTagString
if progSpec.isNewContainerTempFunc(typeSpec):
return [langType, InnerLangType]
if owner =="const": InnerLangType = fieldType
return [langType, InnerLangType]
def makePtrOpt(typeSpec):
return('')
def isComparableType(typeSpec):
fTypeKW = progSpec.fieldTypeKeyword(typeSpec)
if fTypeKW == 'keyType': return True
if 'generic' in typeSpec and typeSpec['generic'] == 'keyType' and fTypeKW == 'string':
return True
return False
def codeIteratorOperation(itrCommand, fieldType):
result = ''
if itrCommand=='goNext': result='%0.next()'
elif itrCommand=='goPrev':result='%0.JAVA ERROR!'
elif itrCommand=='key': result='%0.getKey()'
elif itrCommand=='val': result='%0'
return result
def recodeStringFunctions(name, typeSpec):
if name == "size": name = "length"
elif name == "subStr":
typeSpec['codeConverter']='%0.substring(%1, %1+%2)'
typeSpec['fieldType']='String'
elif name == "append":
typeSpec['codeConverter']='%0 += %1'
return [name, typeSpec]
def langStringFormatterCommand(fmtStr, argStr):
fmtStr=fmtStr.replace(r'%i', r'%d')
fmtStr=fmtStr.replace(r'%l', r'%d')
S='String.format('+'"'+ fmtStr +'"'+ argStr +')'
return S
def LanguageSpecificDecorations(classes, S, typeSpec, owner, LorRorP_Val, xlator):
return S
def checkForTypeCastNeed(lhsTypeSpec, rhsTypeSpec, RHScodeStr):
LHS_KeyType = progSpec.fieldTypeKeyword(lhsTypeSpec)
RHS_KeyType = progSpec.fieldTypeKeyword(rhsTypeSpec)
if LHS_KeyType == 'bool'or LHS_KeyType == 'boolean':
if progSpec.typeIsPointer(rhsTypeSpec):
return '(' + RHScodeStr + ' == null)'
if (RHS_KeyType=='int' or RHS_KeyType=='flag'):
if RHScodeStr[0]=='!': return '(' + RHScodeStr[1:] + ' == 0)'
else: return '(' + RHScodeStr + ' != 0)'
if RHScodeStr == "0": return "false"
if RHScodeStr == "1": return "true"
return RHScodeStr
def getTheDerefPtrMods(itemTypeSpec):
if itemTypeSpec!=None and isinstance(itemTypeSpec, dict) and 'owner' in itemTypeSpec:
if progSpec.isOldContainerTempFunc(itemTypeSpec): print("Deprecated container type:", itemTypeSpec); exit(2);
return ['', '', False]
def derefPtr(varRef, itemTypeSpec):
[leftMod, rightMod, isDerefd] = getTheDerefPtrMods(itemTypeSpec)
S = leftMod + varRef + rightMod
return [S, isDerefd]
def ChoosePtrDecorationForSimpleCase(owner):
print("TODO: finish ChoosePtrDecorationForSimpleCase")
return ['','', '','']
def chooseVirtualRValOwner(LVAL, RVAL):
return ['','']
def determinePtrConfigForAssignments(LVAL, RVAL, assignTag, codeStr):
return ['','', '','']
def getCodeAllocStr(varTypeStr, owner):
if(owner!='const'): S="new "+varTypeStr
else: print("ERROR: Cannot allocate a 'const' variable."); exit(1);
return S
def getCodeAllocSetStr(varTypeStr, owner, value):
S=getCodeAllocStr(varTypeStr, owner)
S+='('+value+')'
return S
def getConstIntFieldStr(fieldName, fieldValue):
S= "public static final int "+fieldName+ " = " + fieldValue+ ";\n"
return(S)
def getEnumStr(fieldName, enumList):
S = ''
count=0
for enumName in enumList:
S += " " + getConstIntFieldStr(enumName, str(count))
count=count+1
S += "\n"
# S += 'public static final String ' + fieldName+'Strings[] = {"'+('", "'.join(enumList))+'"};\n'
return(S)
def getEnumStringifyFunc(className, enumList):
print("TODO: finish getEnumStringifyFunc")
def codeIdentityCheck(S, S2, retType1, retType2, opIn):
S2 = adjustQuotesForChar(retType1, retType2, S2)
if opIn == '===':
#print("TODO: finish codeIdentityCk")
return S + " == "+ S2
else:
lFType = progSpec.fieldTypeKeyword(retType1)
rFType = progSpec.fieldTypeKeyword(retType2)
if (lFType=='String' or lFType == "string") and opIn=="==" and (rFType == "String" or rFType == "string"):
return S+'.equals('+S2+')'
else:
if (opIn == '=='): opOut=' == '
elif (opIn == '!='): opOut=' != '
elif (opIn == '!=='): opOut=' != '
else: print("ERROR: '==' or '!=' or '===' or '!==' expected."); exit(2)
return S+opOut+S2
return S
def codeComparisonStr(S, S2, retType1, retType2, op):
S3 = ""
if (op == '<'):
if isComparableType(retType1):
S+='.compareTo('
S3= ") < 0"
else: S+=' < '
elif (op == '>'):
if isComparableType(retType1):
S+='.compareTo('
S3= ") > 0"
else: S+=' > '
elif (op == '<='): S+=' <= '
elif (op == '>='): S+=' >= '
else: print("ERROR: One of <, >, <= or >= expected in code generator."); exit(2)
S2 = adjustQuotesForChar(retType1, retType2, S2)
[S2, isDerefd]=derefPtr(S2, retType2)
S+=S2+S3
return S
###################################################### CONTAINERS
def getContaineCategory(containerSpec):
fTypeKW = progSpec.fieldTypeKeyword(containerSpec)
if fTypeKW=='DblLinkedList':
return 'DblLinkedList'
elif fTypeKW=='TreeMap' or fTypeKW=='Java_Map' or 'RBTreeMap' in fTypeKW or "__Map_" in fTypeKW:
return 'MAP'
elif fTypeKW=='list' or fTypeKW=='Java_ArrayList' or "__List_" in fTypeKW or "__CDList" in fTypeKW:
return 'LIST'
return None
def getContainerTypeInfo(classes, containerType, name, idxType, typeSpecIn, paramList, genericArgs, xlator):
convertedIdxType = ""
typeSpecOut = typeSpecIn
if progSpec.isNewContainerTempFunc(typeSpecIn): return(name, typeSpecOut, paramList, convertedIdxType)
if progSpec.isOldContainerTempFunc(typeSpecIn): print("Deprecated container type:", typeSpecIn); exit(2);
return(name, typeSpecOut, paramList, convertedIdxType)
def codeArrayIndex(idx, containerType, LorR_Val, previousSegName, idxTypeSpec):
if LorR_Val=='RVAL':
#Next line may be cause of bug with printing modes. remove 'not'?
if (previousSegName in getModeStateNames()):
S= '.get((int)' + idx + ')'
elif (containerType== 'ArrayList' or containerType== 'TreeMap' or containerType== 'Java_ArrayList' or containerType== 'Map' or containerType== 'multimap'or containerType== 'Java_Map'):
S= '.get(' + idx + ')'
elif (containerType== 'string'):
S= '.charAt(' + idx + ')' # '.substring(' + idx + ', '+ idx + '+1' +')'
else: S= '[' + idx +']'
else:
if containerType== 'ArrayList' or containerType== 'Java_Map' or containerType== 'Java_ArrayList': S = '.get('+idx+')'
else: S= '[' + idx +']'
return S
###################################################### CONTAINER REPETITIONS
def codeRangeSpec(traversalMode, ctrType, repName, S_low, S_hi, indent, xlator):
if(traversalMode=='Forward' or traversalMode==None):
S = indent + "for("+ctrType+" " + repName+'='+ S_low + "; " + repName + "!=" + S_hi +"; "+ xlator['codeIncrement'](repName) + "){\n"
elif(traversalMode=='Backward'):
S = indent + "for("+ctrType+" " + repName+'='+ S_hi + "-1; " + repName + ">=" + S_low +"; --"+ repName + "){\n"
return (S)
def iterateRangeContainerStr(classes,localVarsAlloc,StartKey,EndKey,ctnrTSpec,ctnrOwner,repName,repContainer,datastructID,idxTypeKW,indent,xlator):
willBeModifiedDuringTraversal=True # TODO: Set this programatically leter.
actionText = ""
loopCounterName = ""
containedType = progSpec.getFieldTypeNew(ctnrTSpec)
ctnrOwner = progSpec.getOwnerFromTypeSpec(ctnrTSpec)
ctrlVarsTypeSpec = {'owner':ctnrOwner, 'fieldType':containedType}
containerCat = getContaineCategory(ctnrTSpec)
if containerCat == "MAP":
loopCounterName = repName+'_key'
valueFieldType = adjustBaseTypes(progSpec.fieldTypeKeyword(ctnrTSpec), True)
keyVarSpec = {'owner':ctnrTSpec['owner'], 'fieldType':containedType}
localVarsAlloc.append([loopCounterName, keyVarSpec]) # Tracking local vars for scope
localVarsAlloc.append([repName, ctrlVarsTypeSpec]) # Tracking local vars for scope
idxTypeKW = adjustBaseTypes(idxTypeKW, True)
repContainerTypeSpec = (repContainer)
actionText += (indent + 'for(Map.Entry<'+idxTypeKW+','+valueFieldType+'> '+repName+'Entry : '+repContainer+'.subMap('+StartKey+', '+EndKey+').entrySet()){\n' +
indent + ' '+valueFieldType+' '+ repName + ' = ' + repName+'Entry.getValue();\n' +
indent + ' ' +idxTypeKW +' '+ loopCounterName + ' = ' + repName+'Entry.getKey();\n\n' )
elif datastructID=='list' or (datastructID=='deque' and not willBeModifiedDuringTraversal):
pass;
elif datastructID=='deque' and willBeModifiedDuringTraversal:
pass;
else:
print("DSID iterateRangeContainerStr:",datastructID,ctnrTSpec)
exit(2)
return [actionText, loopCounterName]
def iterateContainerStr(classes,localVarsAlloc,ctnrTSpec,repName,ctnrName,isBackward,indent,genericArgs,xlator):
#TODO: handle isBackward
willBeModifiedDuringTraversal=True # TODO: Set this programatically later.
[datastructID, idxTypeKW, ctnrOwner]=getContainerType(ctnrTSpec, 'action')
actionText = ""
loopCounterName = repName+'_key'
owner = progSpec.getContainerFirstElementOwner(ctnrTSpec)
containedType = progSpec.getContainerFirstElementType(ctnrTSpec)
ctrlVarsTypeSpec = {'owner':ctnrTSpec['owner'], 'fieldType':containedType}
reqTagList = progSpec.getReqTagList(ctnrTSpec)
[LDeclP, RDeclP, LDeclA, RDeclA] = ChoosePtrDecorationForSimpleCase(ctnrOwner)
itrTypeSpec = progSpec.getItrTypeOfDataStruct(datastructID, ctnrTSpec)
itrFieldType = progSpec.fieldTypeKeyword(itrTypeSpec)
itrOwner = progSpec.getOwnerFromTypeSpec(itrTypeSpec)
[LNodeP, RNodeP, LNodeA, RNodeA] = ChoosePtrDecorationForSimpleCase(itrOwner)
itrName = repName + "Itr"
containerCat = getContaineCategory(ctnrTSpec)
itrIncStr = ""
if containerCat=='DblLinkedList': cdErr("TODO: handle dblLinkedList")
if containerCat=='MAP':
reqTagString = getReqTagString(classes, ctnrTSpec)
if(reqTagList != None):
ctrlVarsTypeSpec['owner'] = progSpec.getOwnerFromTemplateArg(reqTagList[1])
ctrlVarsTypeSpec['fieldType'] = progSpec.getTypeFromTemplateArg(reqTagList[1])
if datastructID=='TreeMap' or datastructID=='Java_Map':
keyVarSpec = {'owner':ctnrTSpec['owner'], 'fieldType':idxTypeKW, 'codeConverter':(repName+'.getKey()')}
ctrlVarsTypeSpec['codeConverter'] = (repName+'.getValue()')
iteratorTypeStr="Map.Entry"+reqTagString
actionText += indent + "for("+iteratorTypeStr+" " + repName+' :'+ ctnrName+".entrySet()){\n"
else:
keyVarSpec = {'owner':ctnrTSpec['owner'], 'fieldType':idxTypeKW, 'codeConverter':(repName+'.node.key')}
ctrlVarsTypeSpec['codeConverter'] = (repName+'.node.value')
itrType = progSpec.fieldTypeKeyword(progSpec.getItrTypeOfDataStruct(datastructID, ctnrTSpec)) + ' '
frontItr = ctnrName+'.front()'
if not 'generic' in ctnrTSpec: itrType += reqTagString
actionText += (indent + 'for('+itrType + itrName+' ='+frontItr + '; ' + itrName + '.node!='+ctnrName+'.end().node'+'; '+repName+'.goNext()){\n')
#actionText += (indent + "for("+itrType + itrName+' ='+frontItr + "; " + itrName + " !=" + ctnrName+RDeclP+'end()' +"; ++"+itrName + " ){\n"
# + indent+" "+itrType+repName+" = *"+itrName+";\n")
elif containerCat=="LIST":
containedOwner = progSpec.getOwnerFromTypeSpec(ctnrTSpec)
keyVarSpec = {'owner':containedOwner, 'fieldType':containedType}
[iteratorTypeStr, innerType]=convertType(ctrlVarsTypeSpec, 'var', 'action', genericArgs, xlator)
loopVarName=repName+"Idx";
if(isBackward):
actionText += (indent + "for(int "+loopVarName+'='+ctnrName+'.size()-1; ' + loopVarName +' >=0; --' + loopVarName+'){\n'
+ indent + indent + iteratorTypeStr+' '+repName+" = "+ctnrName+".get("+loopVarName+");\n")
else:
actionText += (indent + "for(int "+loopVarName+"=0; " + loopVarName +' != ' + ctnrName+'.size(); ' + loopVarName+' += 1){\n'
+ indent + indent + iteratorTypeStr+' '+repName+" = "+ctnrName+".get("+loopVarName+");\n")
else: cdErr("iterateContainerStr() datastructID = " + datastructID)
localVarsAlloc.append([loopCounterName, keyVarSpec]) # Tracking local vars for scope
localVarsAlloc.append([repName, ctrlVarsTypeSpec]) # Tracking local vars for scope
return [actionText, loopCounterName, itrIncStr]
###################################################### EXPRESSION CODING
def codeFactor(item, objsRefed, returnType, expectedTypeSpec, LorRorP_Val, genericArgs, xlator):
#### ( value | ('(' + expr + ')') | ('!' + expr) | ('-' + expr) | varRef("varFunRef"))
#print(' factor: ', item)
S=''
retTypeSpec='noType'
item0 = item[0]
#print("ITEM0=", item0, ">>>>>", item)
if (isinstance(item0, str)):
if item0=='(':
[S2, retTypeSpec] = codeExpr(item[1], objsRefed, returnType, expectedTypeSpec, LorRorP_Val, genericArgs, xlator)
S+='(' + S2 +')'
elif item0=='!':
[S2, retTypeSpec] = codeExpr(item[1], objsRefed, returnType, expectedTypeSpec, LorRorP_Val, genericArgs, xlator)
if(progSpec.typeIsPointer(retTypeSpec)):
S= '('+S2+' == null)'
retTypeSpec='bool'
else: S+='!' + S2
elif item0=='-':
[S2, retTypeSpec] = codeExpr(item[1], objsRefed, returnType, expectedTypeSpec, LorRorP_Val, genericArgs, xlator)
S+='-' + S2
elif item0=='[':
count=0
tmp="(Arrays.asList("
for expr in item[1:-1]:
count+=1
[S2, exprTypeSpec] = codeExpr(expr, objsRefed, returnType, expectedTypeSpec, LorRorP_Val, genericArgs, xlator)
if not exprTypeSpec=='noType':
retTypeSpec = adjustBaseTypes(exprTypeSpec, True)
if count>1: tmp+=', '
tmp+=S2
if exprTypeSpec=='Long' or exprTypeSpec=='noType':
if '*' in S2:
numVal = S2
#print 'numVal', numVal
elif int(S2) > 2147483647:
tmp+="L"
retTypeSpec = 'Long'
tmp+="))"
retTypeKW = progSpec.fieldTypeKeyword(retTypeSpec)
if isinstance(exprTypeSpec,str):typeKeyword = exprTypeSpec
elif progSpec.isAContainer(returnType):
reqType = progSpec.getContainerFirstElementType(returnType)
typeKeyword = progSpec.fieldTypeKeyword(reqType)
typeKeyword = adjustBaseTypes(typeKeyword, True)
else: typeKeyword = retTypeKW
S+='new ArrayList<'+typeKeyword+'>'+tmp # ToDo: make this handle things other than long.
else:
expected_KeyType = progSpec.varTypeKeyWord(expectedTypeSpec)
if(item0[0]=="'"): S+=codeUserMesg(item0[1:-1], xlator); retTypeSpec='String'
elif (item0[0]=='"'):
if returnType != None and returnType["fieldType"]=="char":
retTypeSpec='char'
innerS=item0[1:-1]
if len(innerS)==1:
S+="'"+item0[1:-1] +"'"
else:
cdErr("Characters must have exactly 1 character.")
else:
S+='"'+item0[1:-1] +'"'
retTypeSpec='String'
else:
S+=item0;
if retTypeSpec == 'noType' and progSpec.typeIsInteger(expected_KeyType):
retTypeSpec=expected_KeyType
if retTypeSpec == 'noType' and progSpec.isStringNumeric(item0):
retTypeSpec={'owner': 'literal', 'fieldType': 'numeric'}
if retTypeSpec == 'noType' and progSpec.typeIsInteger(expected_KeyType):retTypeSpec=expected_KeyType
else: # CODEDOG LITERALS
if isinstance(item0[0], str):
S+=item0[0]
if '"' in S or "'" in S: retTypeSpec = 'string'
if '.' in S: retTypeSpec = 'double'
if isinstance(S, int): retTypeSpec = 'int64'
else: retTypeSpec = 'int32'
else:
[codeStr, retTypeSpec, prntType, AltIDXFormat]=codeItemRef(item0, 'RVAL', objsRefed, returnType, LorRorP_Val, genericArgs, xlator)
if(codeStr=="NULL"):
codeStr="null"
retTypeSpec={'owner':"PTR"}
typeKeyword = progSpec.fieldTypeKeyword(retTypeSpec)
if (len(item0[0]) > 1 and item0[0][0]==typeKeyword and item0[0][1] and item0[0][1]=='('):
codeStr = 'new ' + codeStr
S+=codeStr # Code variable reference or function call
return [S, retTypeSpec]
######################################################
def adjustQuotesForChar(typeSpec1, typeSpec2, S):
fieldType1 = progSpec.fieldTypeKeyword(typeSpec1)
fieldType2 = progSpec.fieldTypeKeyword(typeSpec2)
if fieldType1 == "char" and (fieldType2 == 'string' or fieldType2 == 'String') and S[0] == '"':
return("'" + S[1:-1] + "'")
return(S)
def adjustConditional(S, conditionType):
if not isinstance(conditionType, str):
if conditionType['owner']=='our' or conditionType['owner']=='their' or conditionType['owner']=='my' or progSpec.isStruct(conditionType['fieldType']):
if S[0]=='!': S = S[1:]+ " == true"
else: S+=" != null"
elif conditionType['owner']=='me' and (conditionType['fieldType']=='flag' or progSpec.typeIsInteger(conditionType['fieldType'])):
if S[0]=='!': S = '('+S[1:]+' == 0)'
else: S = '('+S+') != 0'
conditionType='bool'
return [S, conditionType]
def codeSpecialReference(segSpec, objsRefed, genericArgs, xlator):
S=''
fieldType='void' # default to void
retOwner='me' # default to 'me'
funcName=segSpec[0]
if(len(segSpec)>2): # If there are arguments...
paramList=segSpec[2]
if(funcName=='print'):
S+='System.out.print('
count = 0
for P in paramList:
if(count!=0): S+=" + "
count+=1
[S2, argTypeSpec]=codeExpr(P[0], objsRefed, None, None, 'PARAM', genericArgs, xlator)
if 'fieldType' in argTypeSpec:
fieldType = progSpec.fieldTypeKeyword(argTypeSpec)
fieldType = adjustBaseTypes(fieldType, False)
else: fieldType = argTypeSpec
if fieldType == "timeValue" or fieldType == "int" or fieldType == "double": S2 = '('+S2+')'
S+=S2
S+=")"
retOwner='me'
fieldType='string'
elif(funcName=='AllocateOrClear'):
[varName, varTypeSpec]=codeExpr(paramList[0][0], objsRefed, None, None, 'PARAM', genericArgs, xlator)
S+='if('+varName+' != null){'+varName+'.clear();} else {'+varName+" = "+codeAllocater(varTypeSpec, genericArgs, xlator)+"();}"
elif(funcName=='Allocate'):
[varName, varTypeSpec]=codeExpr(paramList[0][0], objsRefed, None, None, 'PARAM', genericArgs, xlator)
fieldType = progSpec.fieldTypeKeyword(varTypeSpec)
S+=varName+" = "+codeAllocater(varTypeSpec, genericArgs, xlator)+'('
count=0 # TODO: As needed, make this call CodeParameterList() with modelParams of the constructor.
if fieldType=='workerMsgThread':
S += '"workerMsgThread"'
else:
for P in paramList[1:]:
if(count>0): S+=', '
[S2, argTypeSpec]=codeExpr(P[0], objsRefed, None, None, 'PARAM', genericArgs, xlator)
S+=S2
count=count+1
S+=")"
elif(funcName=='break'):
if len(paramList)==0: S='break'
elif(funcName=='return'):
if len(paramList)==0: S+='return'
elif(funcName=='self'):
if len(paramList)==0: S+='this'
elif(funcName=='toStr'):
if len(paramList)==1:
[S2, argTypeSpec]=codeExpr(P[0][0], objsRefed, None, None, 'PARAM', genericArgs, xlator)
[S2, isDerefd]=derefPtr(S2, argTypeSpec)
S+='String.valueOf('+S2+')'
fieldType='String'
else: # Not parameters, i.e., not a function
if(funcName=='self'):
S+='this'
return [S, retOwner, fieldType]
def checkIfSpecialAssignmentFormIsNeeded(AltIDXFormat, RHS, rhsType, LHS, LHSParentType, LHS_FieldType):
# Check for string A[x] = B; If so, render A.put(B,x)
[containerType, idxType, owner]=getContainerType(AltIDXFormat[1], "")
if LHSParentType == 'string' and LHS_FieldType == 'char':
S=AltIDXFormat[0] + '= replaceCharAt(' +AltIDXFormat[0]+', '+ AltIDXFormat[2] + ', ' + RHS + ');\n'
elif containerType == 'ArrayList':
S=AltIDXFormat[0] + '.add(' + AltIDXFormat[2] + ', ' + RHS + ');\n'
elif containerType == 'TreeMap' or containerType == 'Java_Map':
S=AltIDXFormat[0] + '.put(' + AltIDXFormat[2] + ', ' + RHS + ');\n'
elif containerType == 'RBTreeMap' or containerType[:2]=="__" and 'Map' in containerType:
S=AltIDXFormat[0] + '.insert(' + AltIDXFormat[2] + ', ' + RHS + ');\n'
else:
print("ERROR in checkIfSpecialAssignmentFormIsNeeded: containerType not found for ", containerType)
exit(1)
return S
############################################
def codeMain(classes, tags, objsRefed, xlator):
return ["", ""]
def codeArgText(argFieldName, argType, argOwner, typeSpec, makeConst, typeArgList, xlator):
return argType + " " +argFieldName
def codeStructText(classes, attrList, parentClass, classInherits, classImplements, structName, structCode, tags):
classAttrs=''
Platform = progSpec.fetchTagValue(tags, 'Platform')
if len(attrList)>0:
for attr in attrList:
if attr=='abstract': classAttrs += 'abstract '
if parentClass != "":
parentClass = parentClass.replace('::', '_')
parentClass = progSpec.getUnwrappedClassFieldTypeKeyWord(classes, structName)
parentClass=' extends ' +parentClass
elif classInherits!=None:
parentClass=' extends ' + classInherits[0][0]
if classImplements!=None:
# TODO: verify if classImplements is used
#print(structName, "Implements: " , classImplements)
parentClass+=' implements '
count =0
for item in classImplements[0]:
if count>0:
parentClass+= ', '
parentClass+= item
count += 1
if structName =="GLOBAL" and Platform == 'Android':
classAttrs = "public " + classAttrs
S= "\n"+classAttrs +"class "+structName+''+parentClass+" {\n" + structCode + '};\n'
typeArgList = progSpec.getTypeArgList(structName)
if(typeArgList != None):
templateHeader = codeTemplateHeader(structName, typeArgList)
S=templateHeader+" {\n" + structCode + '};\n'
return([S,""])
def produceTypeDefs(typeDefMap, xlator):
return ''
def addSpecialCode(filename):
S='\n\n//////////// Java specific code:\n'
return S
def addGLOBALSpecialCode(classes, tags, xlator):
filename = makeTagText(tags, 'FileName')
specialCode ='const String: filename <- "' + filename + '"\n'
GLOBAL_CODE="""
struct GLOBAL{
%s
}
""" % (specialCode)
codeDogParser.AddToObjectFromText(classes[0], classes[1], GLOBAL_CODE, 'Java special code')
def codeNewVarStr(classes, tags, lhsTypeSpec, varName, fieldDef, indent, objsRefed, actionOrField, genericArgs, localVarsAllocated, xlator):
varDeclareStr = ''
assignValue = ''
isAllocated = fieldDef['isAllocated']
owner = progSpec.getTypeSpecOwner(lhsTypeSpec)
useCtor = False
if fieldDef['paramList'] and fieldDef['paramList'][-1] == "^&useCtor//8":
del fieldDef['paramList'][-1]
useCtor = True
[convertedType, innerType] = convertType(lhsTypeSpec, 'var', actionOrField, genericArgs, xlator)
reqTagList = progSpec.getReqTagList(lhsTypeSpec)
fieldType = progSpec.fieldTypeKeyword(lhsTypeSpec)
if reqTagList and xlator['renderGenerics']=='True' and not progSpec.isWrappedType(classes, fieldType) and not progSpec.isAbstractStruct(classes[0], fieldType):
convertedType = generateGenericStructName(fieldType, reqTagList, genericArgs, xlator)
allocFieldType = convertedType
lhsTypeSpec = getGenericTypeSpec(genericArgs, lhsTypeSpec, xlator)
if 'fromImplemented' in lhsTypeSpec: lhsTypeSpec.pop('fromImplemented')
localVarsAllocated.append([varName, lhsTypeSpec]) # Tracking local vars for scope
else:
localVarsAllocated.append([varName, lhsTypeSpec]) # Tracking local vars for scope
containerTypeSpec = progSpec.getContainerSpec(lhsTypeSpec)
if progSpec.isOldContainerTempFunc(lhsTypeSpec): print("Deprecated container type:", lhsTypeSpec); exit(2);
isAContainer=progSpec.isNewContainerTempFunc(lhsTypeSpec)
fieldType = adjustBaseTypes(convertedType, isAContainer)
if isinstance(containerTypeSpec, str) and containerTypeSpec == None:
if(fieldDef['value']):
[S2, rhsTypeSpec]=codeExpr(fieldDef['value'][0], objsRefed, None, None, 'RVAL', genericArgs, xlator)
RHS = S2
assignValue=' = '+ RHS
#TODO: make test case
else: assignValue=''
elif(fieldDef['value']):
[S2, rhsTypeSpec]=codeExpr(fieldDef['value'][0], objsRefed, lhsTypeSpec, None, 'RVAL', genericArgs, xlator)
S2=checkForTypeCastNeed(convertedType, rhsTypeSpec, S2)
RHS = S2
if varTypeIsValueType(fieldType):
assignValue=' = '+ RHS
else:
#TODO: make test case
constructorExists=False # TODO: Use some logic to know if there is a constructor, or create one.
if (constructorExists):
assignValue=' = new ' + fieldType +'('+ RHS + ')'
else:
assignValue= ' = '+ RHS #' = new ' + fieldType +'();\n'+ indent + varName+' = '+RHS
else: # If no value was given:
CPL=''
if fieldDef['paramList'] != None: # call constructor # curly bracket param list
# Code the constructor's arguments
[CPL, paramTypeList] = codeParameterList(varName, fieldDef['paramList'], None, objsRefed, genericArgs, xlator)
if len(paramTypeList)==1:
if not isinstance(paramTypeList[0], dict):
print("\nPROBLEM: The return type of the parameter '", CPL, "' of "+varName+"(...) cannot be found and is needed. Try to define it.\n", paramTypeList)
exit(1)
rhsTypeSpec = paramTypeList[0]
rhsType = progSpec.getFieldType(rhsTypeSpec)
if not isinstance(rhsType, str) and fieldType==rhsType[0]:
assignValue = " = " + CPL # Act like a copy constructor
elif 'codeConverter' in paramTypeList[0]: #ktl 12.14.17
assignValue = " = " + CPL
else:
if isJavaPrimativeType(fieldType): assignValue = " = " + CPL
else: assignValue = " = new " + fieldType + CPL
if(assignValue==''): assignValue = ' = '+getCodeAllocStr(fieldType, owner)+CPL
elif varTypeIsValueType(fieldType):
if fieldType == 'long' or fieldType == 'int' or fieldType == 'float'or fieldType == 'double': assignValue=' = 0'
elif fieldType == 'string': assignValue=' = ""'
elif fieldType == 'boolean': assignValue=' = false'
elif fieldType == 'char': assignValue=" = ' '"
else: assignValue=''
else:assignValue= " = new " + fieldType + "()"
varDeclareStr= fieldType + " " + varName + assignValue
return(varDeclareStr)
def codeIncrement(varName):
return "++" + varName
def codeDecrement(varName):
return "--" + varName
def varTypeIsValueType(convertedType):
if (convertedType=='int' or convertedType=='long' or convertedType=='byte' or convertedType=='boolean' or convertedType=='char'
or convertedType=='float' or convertedType=='double' or convertedType=='short'):
return True
return False
def codeVarFieldRHS_Str(fieldName, convertedType, fieldType, typeSpec, paramList, objsRefed, isAllocated, typeArgList, genericArgs, xlator):
fieldValueText=""
fieldOwner=progSpec.getTypeSpecOwner(typeSpec)
if fieldOwner=='we':
convertedType = convertedType.replace('static ', '', 1)
if (not varTypeIsValueType(convertedType) and (fieldOwner=='me' or fieldOwner=='we' or fieldOwner=='const')):
if fieldOwner =="const": convertedType = fieldType
if paramList!=None:
#TODO: make test case
if paramList[-1] == "^&useCtor//8":
del paramList[-1]
[CPL, paramTypeList] = codeParameterList(fieldName, paramList, None, objsRefed, genericArgs, xlator)
fieldValueText=" = new " + convertedType + CPL
elif typeArgList == None:
fieldValueText=" = new " + convertedType + "()"
return fieldValueText
def codeConstField_Str(convertedType, fieldName, fieldValueText, className, indent, xlator ):
defn = indent + convertedType + ' ' + fieldName + fieldValueText +';\n';
decl = ''
return [defn, decl]
def codeVarField_Str(convertedType, typeSpec, fieldName, fieldValueText, className, tags, typeArgList, indent):
# TODO: make test case
S=""
fieldOwner=progSpec.getTypeSpecOwner(typeSpec)
Platform = progSpec.fetchTagValue(tags, 'Platform')
# TODO: make next line so it is not hard coded
if(Platform == 'Android' and (convertedType == "TextView" or convertedType == "ViewGroup" or convertedType == "CanvasView" or convertedType == "FragmentTransaction" or convertedType == "FragmentManager" or convertedType == "Menu" or convertedType == "static GLOBAL" or convertedType == "Toolbar" or convertedType == "NestedScrollView" or convertedType == "SubMenu" or convertedType == "APP" or convertedType == "AssetManager" or convertedType == "ScrollView" or convertedType == "LinearLayout" or convertedType == "GUI"or convertedType == "CheckBox" or convertedType == "HorizontalScrollView"or convertedType == "GUI_ZStack"or convertedType == "widget"or convertedType == "GLOBAL")):
S += indent + "public " + convertedType + ' ' + fieldName +';\n';
else:
S += indent + "public " + convertedType + ' ' + fieldName + fieldValueText +';\n';
return [S, '']
###################################################### CONSTRUCTORS
def codeConstructors(className, ctorArgs, ctorOvrRide, ctorInit, copyCtorArgs, funcBody, callSuper, xlator):
if callSuper:
funcBody = ' super();\n' + funcBody
withArgConstructor = ''
if ctorArgs != '':
withArgConstructor = " public " + className + "(" + ctorArgs+"){\n"+funcBody+ ctorInit+" };\n"
copyConstructor = " public " + className + "(final " + className + " fromVar" +"){\n "+ className + " toVar = new "+ className + "();\n" +copyCtorArgs+" };\n"
noArgConstructor = " public " + className + "(){\n"+funcBody+'\n };\n'
# TODO: remove hardCoding
if (className =="ourSubMenu" or className =="GUI"or className =="CanvasView"or className =="APP"or className =="GUI_ZStack"):
return ""
return withArgConstructor + copyConstructor + noArgConstructor
def codeConstructorInit(fieldName, count, defaultVal, xlator):
return " " + fieldName+"= arg_"+fieldName+";\n"
def codeConstructorArgText(argFieldName, count, argType, defaultVal, xlator):
return argType + " arg_"+ argFieldName
def codeCopyConstructor(fieldName, convertedType, isTemplateVar, xlator):
if isTemplateVar: return ""
return " toVar."+fieldName+" = fromVar."+fieldName+";\n"
def codeConstructorCall(className):
return ' INIT();\n'
def codeSuperConstructorCall(parentClassName):
return ' '+parentClassName+'();\n'
def codeFuncHeaderStr(className, fieldName, typeDefName, argListText, localArgsAllocated, inheritMode, overRideOper, isConstructor, typeArgList, typeSpec, indent):
# if fieldName == 'init':
# fieldName = fieldName+'_'+className
if inheritMode=='pure-virtual':
typeDefName = 'abstract '+typeDefName
structCode='\n'; funcDefCode=''; globalFuncs='';
if(className=='GLOBAL'):
if fieldName=='main':
structCode += indent + "public static void " + fieldName +" (String[] args)";
#localArgsAllocated.append(['args', {'owner':'me', 'fieldType':'String', 'argList':None}])
else:
structCode += indent + "public " + typeDefName + ' ' + fieldName +"("+argListText+")"
else:
structCode += indent + "public " + typeDefName +' ' + fieldName +"("+argListText+")"
if inheritMode=='pure-virtual':
structCode += ";\n"
elif inheritMode=='override': pass
return [structCode, funcDefCode, globalFuncs]
def getVirtualFuncText(field):
return ""
def codeTypeArgs(typeArgList):
print("TODO: finish codeTypeArgs")
def codeTemplateHeader(structName, typeArgList):
templateHeader = "\nclass "+structName+"<"
count = 0
for typeArg in typeArgList:
if(count>0):templateHeader+=", "
templateHeader+=typeArg
if isComparableType(typeArg):templateHeader+=" extends Comparable"
count+=1
templateHeader+=">"
return(templateHeader)
def extraCodeForTopOfFuntion(argList):
return ''
def codeSetBits(LHS_Left, LHS_FieldType, prefix, bitMask, RHS, rhsType):
if (LHS_FieldType =='flag' ):
item = LHS_Left+"flags"
mask = prefix+bitMask
if (RHS != 'true' and RHS !='false' and progSpec.fieldTypeKeyword(rhsType)!='bool' ):
RHS += '!=0'
val = '('+ RHS +')?'+mask+':0'
elif (LHS_FieldType =='mode' ):
item = LHS_Left+"flags"
mask = prefix+bitMask+"Mask"
if RHS == 'false': RHS = '0'
if RHS == 'true': RHS = '1'
val = RHS+"<<"+prefix+bitMask+"Offset"
return "{"+item+" &= ~"+mask+"; "+item+" |= ("+val+");}\n"
def codeSwitchBreak(caseAction, indent, xlator):
if not(len(caseAction) > 0 and caseAction[-1]['typeOfAction']=='funcCall' and caseAction[-1]['calledFunc'][0][0] == 'return'):
return indent+" break;\n"
else:
return ''
def applyTypecast(typeInCodeDog, itemToAlterType):
return '((int)'+itemToAlterType+')'
#######################################################
def includeDirective(libHdr):
S = 'import '+libHdr+';\n'
return S
def generateMainFunctionality(classes, tags):
# TODO: Some deInitialize items should automatically run during abort().
# TODO: System initCode should happen first in initialize, last in deinitialize.
runCode = progSpec.fetchTagValue(tags, 'runCode')
Platform = progSpec.fetchTagValue(tags, 'Platform')
if Platform != 'Android':
mainFuncCode="""
me void: main( ) <- {
initialize(String.join(" ", args))
""" + runCode + """
deinitialize()
endFunc()
}
"""
if Platform == 'Android':
mainFuncCode="""
me void: runDogCode() <- {
""" + runCode + """
}
"""
progSpec.addObject(classes[0], classes[1], 'GLOBAL', 'struct', 'SEQ')
codeDogParser.AddToObjectFromText(classes[0], classes[1], progSpec.wrapFieldListInObjectDef('GLOBAL', mainFuncCode ), 'Java start-up code')
def fetchXlators():
xlators = {}
xlators['LanguageName'] = "Java"
xlators['BuildStrPrefix'] = "Javac "
xlators['fileExtension'] = ".java"
xlators['typeForCounterInt'] = "int"
xlators['GlobalVarPrefix'] = "GLOBAL.static_Global."
xlators['PtrConnector'] = "." # Name segment connector for pointers.
xlators['ObjConnector'] = "." # Name segment connector for classes.
xlators['NameSegConnector'] = "."
xlators['NameSegFuncConnector'] = "."
xlators['doesLangHaveGlobals'] = "False"
xlators['funcBodyIndent'] = " "
xlators['funcsDefInClass'] = "True"
xlators['MakeConstructors'] = "True"
xlators['blockPrefix'] = ""
xlators['usePrefixOnStatics'] = "False"
xlators['iteratorsUseOperators'] = "False"
xlators['renderGenerics'] = "True"
xlators['renameInitFuncs'] = "False"
xlators['codeFactor'] = codeFactor
xlators['codeComparisonStr'] = codeComparisonStr
xlators['codeIdentityCheck'] = codeIdentityCheck
xlators['derefPtr'] = derefPtr
xlators['checkForTypeCastNeed'] = checkForTypeCastNeed
xlators['adjustConditional'] = adjustConditional
xlators['includeDirective'] = includeDirective
xlators['codeMain'] = codeMain
xlators['produceTypeDefs'] = produceTypeDefs
xlators['addSpecialCode'] = addSpecialCode
xlators['applyTypecast'] = applyTypecast
xlators['codeIteratorOperation'] = codeIteratorOperation
xlators['xlateLangType'] = xlateLangType
xlators['getContainerType'] = getContainerType
xlators['recodeStringFunctions'] = recodeStringFunctions
xlators['langStringFormatterCommand'] = langStringFormatterCommand
xlators['LanguageSpecificDecorations'] = LanguageSpecificDecorations
xlators['getCodeAllocStr'] = getCodeAllocStr
xlators['getCodeAllocSetStr'] = getCodeAllocSetStr
xlators['codeSpecialReference'] = codeSpecialReference
xlators['checkIfSpecialAssignmentFormIsNeeded'] = checkIfSpecialAssignmentFormIsNeeded
xlators['getConstIntFieldStr'] = getConstIntFieldStr
xlators['codeStructText'] = codeStructText
xlators['getContainerTypeInfo'] = getContainerTypeInfo
xlators['codeNewVarStr'] = codeNewVarStr
xlators['chooseVirtualRValOwner'] = chooseVirtualRValOwner
xlators['determinePtrConfigForAssignments'] = determinePtrConfigForAssignments
xlators['iterateRangeContainerStr'] = iterateRangeContainerStr
xlators['iterateContainerStr'] = iterateContainerStr
xlators['getEnumStr'] = getEnumStr
xlators['codeVarFieldRHS_Str'] = codeVarFieldRHS_Str
xlators['codeVarField_Str'] = codeVarField_Str
xlators['codeFuncHeaderStr'] = codeFuncHeaderStr
xlators['extraCodeForTopOfFuntion'] = extraCodeForTopOfFuntion
xlators['codeArrayIndex'] = codeArrayIndex
xlators['codeSetBits'] = codeSetBits
xlators['generateMainFunctionality'] = generateMainFunctionality
xlators['addGLOBALSpecialCode'] = addGLOBALSpecialCode
xlators['codeArgText'] = codeArgText
xlators['codeConstructors'] = codeConstructors
xlators['codeConstructorInit'] = codeConstructorInit
xlators['codeIncrement'] = codeIncrement
xlators['codeDecrement'] = codeDecrement
xlators['codeConstructorArgText'] = codeConstructorArgText
xlators['codeSwitchBreak'] = codeSwitchBreak
xlators['codeCopyConstructor'] = codeCopyConstructor
xlators['codeRangeSpec'] = codeRangeSpec
xlators['codeConstField_Str'] = codeConstField_Str
xlators['checkForTypeCastNeed'] = checkForTypeCastNeed
xlators['codeConstructorCall'] = codeConstructorCall
xlators['codeSuperConstructorCall'] = codeSuperConstructorCall
xlators['getVirtualFuncText'] = getVirtualFuncText
xlators['getUnwrappedClassOwner'] = getUnwrappedClassOwner
xlators['makePtrOpt'] = makePtrOpt
return(xlators)