Commit e8b97eeb authored by rdubner's avatar rdubner

Tolerates symbolic variable length/offset; handles VARIABLE_STRING_ with non-C++ characters

parent 84169f85
......@@ -317,6 +317,7 @@ def Main() :
COMMAND_LINE=[]
COMMANDS_REMOVED=[]
TO_BE_LINKED_AT_THE_END=[]
c_module_count=0
ASKED_FOR_HELP=False
ASKED_FOR_VERSION=False
......@@ -341,15 +342,22 @@ def Main() :
## passed along as -a -b -c
##
params = []
prior_param = ["",""]
do_not_process = False
for param in sys.argv[1:] + COBCDFLAGS : ## Skip the program name, and add in the switches from the environment
prior_param[0] = prior_param[1]
prior_param[1] = param
ORIGINAL_COMMAND_LINE.append(param)
#print("param:",param)
if do_not_process :
do_not_process = False
params.append(param)
continue
if param[-2:] == ".o" or param[-2:] == ".O" or param[-2:] == ".i" or param[-2:] == ".I" :
last_two = param[-2:]
last_two.lower()
if last_two in (".c") :
c_module_count += 1
if last_two in (".o") and prior_param[0] != "-o" :
## Sequester .o object files until the final link
TO_BE_LINKED_AT_THE_END.append(param)
continue
......@@ -442,7 +450,7 @@ def Main() :
SAVE_TEMPS=param
COMMANDS_REMOVED.append(param)
continue;
elif param in ("-E","-C","-S","-c","-###") :
elif param in ("-E","-C","-S","-c","-###","-") :
end_early = True
COMMAND_LINE.append(param)
......@@ -469,13 +477,24 @@ def Main() :
command = [COBC] + ORIGINAL_COMMAND_LINE
if ECHO :
print('#### Termination due to one or more of "-E","-C","-S","-c","-###"')
print('#### Termination due to one or more of "-E","-C","-S","-c","-###","-"')
SmartPrint(command)
## Execute it:
resultcode = SubprocessCall(command,False)
os._exit(resultcode)
if c_module_count :
command = [COBC] + ORIGINAL_COMMAND_LINE
if ECHO :
print('#### Termination due to presence of .c inputs')
SmartPrint(command)
## Execute it:
resultcode = SubprocessCall(command,False)
os._exit(resultcode)
if DASH_V :
## If there was a -v request, we need to show the user everything we're doing
ECHO = 1
......
......@@ -727,6 +727,14 @@ def GetAddressOf(variable) :
retval = val_info
return retval
def AddEmUp(expression) :
retval = 0
tokens = expression.split('+')
for token in tokens :
if token.isnumeric() :
retval += int(token)
return retval
class VarTrie() :
def __init__(self):
self.storage_list = []
......@@ -812,10 +820,10 @@ class VarTrie() :
payload.Fname = tokens[self.IndexFname]
payload.Bname = tokens[self.IndexBname]
payload.Aname = tokens[self.IndexAname]
payload.Offset = int(tokens[self.IndexOffset] or "0")
payload.Length = int(tokens[self.IndexLength] or "0")
payload.OccursMin = int(tokens[self.IndexOffset] or "0")
payload.OccursMax = int(tokens[self.IndexLength] or "0")
payload.Offset = AddEmUp(tokens[self.IndexOffset])
payload.Length = AddEmUp(tokens[self.IndexLength])
payload.OccursMin = int(tokens[self.IndexOccursMin] or "0")
payload.OccursMax = int(tokens[self.IndexOccursMax] or "0")
payload.payload_index = len(self.storage_list)
self.storage_list.append(payload)
......@@ -1856,8 +1864,16 @@ class TabFileInformation() :
name_root = possible_file
name_root = name_root.split('/')
name_root = name_root[-1]
name_root = name_root.replace('.','_')
string_name = "VARIABLE_STRING_" + name_root.upper()
name_root2 = ""
for ch in name_root :
if ch.isalnum() :
name_root2 += ch
else :
hh = hex(ord(ch))[-2:]
name_root2 += hh.upper()
string_name = "VARIABLE_STRING_" + name_root2
if self.ReadVariableString(string_name) :
break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment