py-apx 0.4.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- apx/__init__.py +16 -0
- apx/apx_writer.py +124 -0
- apx/base.py +927 -0
- apx/client.py +153 -0
- apx/compiler.py +295 -0
- apx/context.py +71 -0
- apx/file.py +90 -0
- apx/file_manager.py +20 -0
- apx/file_map.py +141 -0
- apx/generator.py +895 -0
- apx/node.py +428 -0
- apx/node_data.py +218 -0
- apx/pack.py +2 -0
- apx/parser.py +219 -0
- apx/tester.py +79 -0
- apx/vm.py +406 -0
- apx/vm_base.py +56 -0
- apx/vm_state.py +250 -0
- numheader.py +97 -0
- py_apx-0.4.4.dist-info/METADATA +43 -0
- py_apx-0.4.4.dist-info/RECORD +27 -0
- py_apx-0.4.4.dist-info/WHEEL +5 -0
- py_apx-0.4.4.dist-info/licenses/LICENSE +21 -0
- py_apx-0.4.4.dist-info/top_level.txt +3 -0
- remotefile/__init__.py +406 -0
- remotefile/proto.py +6 -0
- remotefile/socket_adapter.py +129 -0
apx/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
__version__ = "0.4.4"
|
|
2
|
+
from apx.base import *
|
|
3
|
+
from apx.vm_base import *
|
|
4
|
+
from apx.node import *
|
|
5
|
+
from apx.file import *
|
|
6
|
+
from apx.file_map import *
|
|
7
|
+
from apx.file_manager import *
|
|
8
|
+
from apx.node_data import *
|
|
9
|
+
from apx.parser import Parser
|
|
10
|
+
from apx.context import *
|
|
11
|
+
from apx.client import *
|
|
12
|
+
from apx.compiler import *
|
|
13
|
+
from apx.vm import *
|
|
14
|
+
from apx.generator import NodeGenerator, ComGenerator
|
|
15
|
+
from apx.tester import *
|
|
16
|
+
|
apx/apx_writer.py
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
class ApxSignature(object):
|
|
2
|
+
def __init__(self,mainType,name,dsg,attr=""):
|
|
3
|
+
self.mainType=mainType
|
|
4
|
+
self.name=name
|
|
5
|
+
self.dsg=dsg
|
|
6
|
+
self.attr=attr
|
|
7
|
+
def __str__(self):
|
|
8
|
+
if (self.attr != None) and len(self.attr)>0:
|
|
9
|
+
return '%s"%s"%s:%s'%(self.mainType,self.name,self.dsg,self.attr)
|
|
10
|
+
else:
|
|
11
|
+
return '%s"%s"%s'%(self.mainType,self.name,self.dsg)
|
|
12
|
+
|
|
13
|
+
class ApxType(object):
|
|
14
|
+
@staticmethod
|
|
15
|
+
def _calcUIntTypeLen(dataType):
|
|
16
|
+
if dataType['type']=='integer':
|
|
17
|
+
if dataType['min'] == 0:
|
|
18
|
+
return int(math.ceil(math.log(dataType['max'],2)))
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def _calcIntTypeLen(dataType):
|
|
23
|
+
if dataType['type']=='integer':
|
|
24
|
+
if dataType['min'] < 0:
|
|
25
|
+
return int(math.ceil(math.log(abs(dataType['max']),2)))+1
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def _calcDataSignature(dataType):
|
|
30
|
+
global typeData
|
|
31
|
+
global args
|
|
32
|
+
typeCode = None
|
|
33
|
+
|
|
34
|
+
if dataType['type']=='boolean':
|
|
35
|
+
return 'C(0,1)'
|
|
36
|
+
if dataType['type']=='integer':
|
|
37
|
+
return ApxType._getIntegerTypeCode(dataType)
|
|
38
|
+
elif dataType['type'] == 'array':
|
|
39
|
+
typeCode = ApxType._getIntegerTypeCode(typeData.find(dataType['typeRef']))
|
|
40
|
+
if typeCode != None:
|
|
41
|
+
return "%s[%d]"%(typeCode,int(dataType['length']))
|
|
42
|
+
else:
|
|
43
|
+
raise Exception("unsupported type: %s"%typeData.find(dataType['typeRef']))
|
|
44
|
+
elif dataType['type'] == 'string':
|
|
45
|
+
typeCode = 'a'
|
|
46
|
+
if typeCode != None:
|
|
47
|
+
return "%s[%d]"%(typeCode,int(dataType['length'])+1)
|
|
48
|
+
elif dataType['type'] == 'record':
|
|
49
|
+
result="{"
|
|
50
|
+
for elem in dataType['elements']:
|
|
51
|
+
#uncomment to remove _RE from end of element names
|
|
52
|
+
#if elem['name'].endswith('_RE'):
|
|
53
|
+
#elem['name']=elem['name'][:-3]
|
|
54
|
+
childType = typeData.find(elem['typeRef'])
|
|
55
|
+
result+='"%s"%s'%(elem['name'],ApxType._calcDataSignature(childType))
|
|
56
|
+
|
|
57
|
+
result+="}"
|
|
58
|
+
return result
|
|
59
|
+
else: raise Exception('uhandled data type: %s'%dataType['type'])
|
|
60
|
+
return ""
|
|
61
|
+
|
|
62
|
+
@staticmethod
|
|
63
|
+
def _getIntegerTypeCode(dataType):
|
|
64
|
+
global args
|
|
65
|
+
if dataType['min'] >= 0:
|
|
66
|
+
bits = ApxType._calcUIntTypeLen(dataType)
|
|
67
|
+
if bits <=8:
|
|
68
|
+
if (dataType['min']>0) or (dataType['max']<255):
|
|
69
|
+
return 'C(%d,%d)'%(dataType['min'],dataType['max'])
|
|
70
|
+
else:
|
|
71
|
+
return 'C'
|
|
72
|
+
elif bits <=16:
|
|
73
|
+
return 'S'
|
|
74
|
+
elif bits <=32:
|
|
75
|
+
return 'L'
|
|
76
|
+
elif bits <=64:
|
|
77
|
+
return 'U'
|
|
78
|
+
elif dataType['min']<0:
|
|
79
|
+
bits = ApxType._calcIntTypeLen(dataType)
|
|
80
|
+
if bits <=8:
|
|
81
|
+
if (dataType['min']>-128) or dataType['max']<127:
|
|
82
|
+
return 'c(%d,%d)'%(dataType['min'],dataType['max'])
|
|
83
|
+
else:
|
|
84
|
+
return 'c'
|
|
85
|
+
elif bits <=16:
|
|
86
|
+
return 's'
|
|
87
|
+
elif bits <=32:
|
|
88
|
+
return 'l'
|
|
89
|
+
elif bits <=64:
|
|
90
|
+
return 'u'
|
|
91
|
+
else:
|
|
92
|
+
print("not implemented (min=%s)"%dataType['min'])
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def _calcAttribute(dataType):
|
|
96
|
+
if dataType['type']=='integer':
|
|
97
|
+
typeSemantics = typeData.find('/DataType/Semantics/%s'%dataType['name'])
|
|
98
|
+
if (typeSemantics != None) and ('valueTable' in typeSemantics):
|
|
99
|
+
v=','.join(['"%s"'%x for x in typeSemantics['valueTable']])
|
|
100
|
+
return "VT(%s)"%v
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
def __init__(self,dataType):
|
|
104
|
+
self.name = dataType['name']
|
|
105
|
+
self.signature = ApxSignature('T',dataType['name'],ApxType._calcDataSignature(dataType),ApxType._calcAttribute(dataType))
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class ApxPort(object):
|
|
109
|
+
def __init__(self,name,typeIndex,attrib):
|
|
110
|
+
self.name = name
|
|
111
|
+
self.typeIndex = typeIndex
|
|
112
|
+
self.attrib=attrib
|
|
113
|
+
def getAttrStr(self):
|
|
114
|
+
result=""
|
|
115
|
+
if self.attrib['initValue']!=None:
|
|
116
|
+
result+="=%s"%self.attrib['initValue']
|
|
117
|
+
if self.attrib['isQueued']:
|
|
118
|
+
if self.attrib['queueLen']!=None:
|
|
119
|
+
result+="Q[%d]"%self.attrib['queueLen']
|
|
120
|
+
else:
|
|
121
|
+
result+="Q"
|
|
122
|
+
if self.attrib['isParameter']:
|
|
123
|
+
result+="P"
|
|
124
|
+
return result
|