Commit de1a2e23 authored by Alexander Ivakin's avatar Alexander Ivakin
Browse files

added nfparams

parent 75a4bd03
......@@ -3,7 +3,7 @@
DEFAULT_LOCATOR_0=True # Set locator 0 if unset
ADD_DEBUG_INFO=False
import sys, json, os
import sys, json, os, pprint
from repr_ja import *
_prog=os.path.split(os.path.realpath(__file__))[1]
......@@ -485,6 +485,24 @@ def gen_stealable(scope, ja):
the_code += '\t' + 'if (self.check_steal()) {' + '\n\t\t' + 'return STEAL;' + '\n\t' + '}' + '\n\n'
return the_code
def assign_nfparams(func_name):
arg_count = 0
for i in range(len(gja[func_name]['args'])):
param=gja[func_name]['args'][i]['type']
if param=='int':
arg_count += 1
elif param=='real':
arg_count += 1
elif param=='string':
arg_count += 1
for rule_index in range(len(gja[func_name]['rules'])):
rule = gja[func_name]['rules'][rule_index]
if (rule['property'] == 'nfparam'):
gja[func_name]['rules'][rule_index]['arg_index'] = arg_count
arg_count += 1
def parse_args(scope, ja):
# bind names to sub arguments
if ja['type']!='struct':
......@@ -523,6 +541,17 @@ def parse_args(scope, ja):
argc+=1
else:
R(param)
if 'rules' in ja:
for i in range(len(ja['rules'])):
rule=ja['rules'][i]
if (rule['property'] == 'nfparam'):
if ('arg_index' not in gja[ja['name']]['rules'][i]):
assign_nfparams(ja['name'])
scope['values'][rule['items'][0][0]] = {
'snip': 'self.arg(%d).get_int()' % rule['arg_index'],
'type': 'int'
}
return ''
......@@ -625,6 +654,25 @@ def gen_exec_struct(scope, ja):
argc+=1
else:
R(param, arg)
if 'rules' in gja[ja['code']] and 'rules' in ja:
for rule_inner_index in range(len(gja[ja['code']]['rules'])):
rule_inner = gja[ja['code']]['rules'][rule_inner_index]
for rule_outer_index in range(len(ja['rules'])):
rule_outer = ja['rules'][rule_outer_index]
if (
rule_outer['property'] == 'nfparam'
and rule_inner['property'] == 'nfparam'
and rule_outer['id'][0] == rule_inner['items'][0][0]
):
if ('arg_index' not in gja[ja['code']]['rules'][rule_inner_index]):
assign_nfparams(ja['code'])
arg_count = gja[ja['code']]['rules'][rule_inner_index]['arg_index']
res+='\t\tchild->arg(%d)=%s;\n' \
% (arg_count, value_int(rule_outer['expr'], scope))
res+='\t}\n\n'
return res
......@@ -1089,6 +1137,7 @@ def gen_body(scope, ja):
forks=gen_create_ids(scope, ja)+forks
return forks, items
# GENERATIONG PODPROGRAMM CODE
def gen_struct(ja):
assert ja['type']=='struct' and 'name' in ja
scope=create_scope(ja, None)
......
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