代码拉取完成,页面将自动刷新
#! /usr/bin/python
# coding=utf-8
import sys
from codeOptimize import Optimize
import os
class InnerCode:
def __init__(self):
self.tempNum = 0
self.varNum = 0
self.labelNum = 0
self.arrayNum = 0
self.codeList = []
def addCode(self, str):
self.codeList.append(str)
print("**********")
print(len(self.codeList))
print("**********")
def printCode(self):
print("**********")
print(len(self.codeList))
print("**********")
#opt = Optimize(self.codeList) # add codeOptimize
#self.codeList = opt.getCodeList()
out = open('innerCode.txt', 'a')
for i in range(len(self.codeList)):
print(self.codeList[i])
out.write(self.codeList[i])
out.write('\n')
def createCodeforVar(self, tempname, op, node1, node2):
result = tempname + ' := '
if node1.useAddress == 1:
result += '*' + node1.name
else:
if node1.num < 0:
result += node1.name
else:
result += 'var' + str(node1.num)
result += ' ' + op + ' '
if node2.useAddress == 1:
result += '*' + node2.name
else:
if node2.num < 0:
result += node2.name
else:
result += 'var' + str(node2.num)
return result
def InnerCodeforAssign(self, node1, node2):
if node1.useAddress == 1:
result = '*' + node1.name + " := "
else:
result = 'var' + str(node1.num)
result += ' := '
if node2.useAddress == 1:
result = result + '*' + node2.name
else:
if node2.num < 0:
result += node2.name
else:
result += 'var' + str(node2.num)
return result
def createCodeforParameter(self, node):
result = 'PARAM'
result += 'var' + str(node.num)
return result
def createCodeforReturn(self, node):
result = 'RETURN'
if node.useAddress == 1:
result += '*' + node.name
else:
if node.num < 0:
result += node.name
else:
result += 'var' + str(node.num)
return result
def createCodeforArgument(self, node):
result = 'ARG'
if node.useAddress == 1:
result += '*' + node.name
else:
if node.num < 0:
result += node.name
else:
result += 'var' + str(node.num)
return result
def getNodeName(self, node):
if node.useAddress == 1:
result = '*' + node.name
else:
if node.num < 0:
result = node.name
else:
result = 'var' + str(node.num)
return result
def getarrayNodeName(self, node):
result = 'array' + str(node.num)
return result
def getLabelName(self):
result = 'label' + str(self.labelNum)
self.labelNum += 1
return result
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。