当前位置: 首页>>代码示例>>Python>>正文


Python Settings.getValue方法代码示例

本文整理汇总了Python中Settings.Settings.getValue方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getValue方法的具体用法?Python Settings.getValue怎么用?Python Settings.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Settings.Settings的用法示例。


在下文中一共展示了Settings.getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Settings import Settings [as 别名]
# 或者: from Settings.Settings import getValue [as 别名]
class RunnerContext:
    def __init__(self, reporter, codeGenContext, settings = None):
        self.expSymbolTable = expressionActionSymbolTable
        self.expSymbolTable.clear()
        self.kindSymbolTable = kindSymbolTable
        self.kindSymbolTable.clear()
        self.settings = Settings() if not settings else settings
        self.codeGenContext = codeGenContext 
        self.architectureContext = codeGenContext.architectureContext
        self.reporter = reporter
        # init
        self.phases = PhaseList(self._internalPhases())

    def _internalPhases(self):
       return [
       SyntaxPhase(self.reporter, self.settings),
       phases.TreePhases.RemoveCommentsPhase(self.reporter),
       phases.TreePhases.MarkNormalizePhase(self.reporter, self.settings),
       phases.TreePhases.SplitValuesPhase(self.reporter),
       phases.InternPhase(self.expSymbolTable, self.reporter, self.settings),
       #phases.TreePhases.UnaryMinusPhase(self.reporter, self.settings),
       #? This can't go here. Point of fact, it must go as
       # processing on the final file, as the CodeGenPhase needs
       # to see operators etc.? (what about FunctionCategorizePhase?)
       #phases.NASMPreprocessPhase(self.reporter, self.settings),
       phases.LinearizePhases.FunctionCategorizePhase(self.codeGenContext, self.reporter, self.settings),
       phases.LinearizePhases.RenderCategorizePropagatePhase(self.codeGenContext, self.reporter, self.settings),
       phases.LinearizePhases.FunctionUnnestPhase(self.architectureContext),
       phases.LinearizePhases.ParseLiveRangesPhase(self.reporter),
       phases.LinearizePhases.ChooseRegistersPhase(self.architectureContext, self.reporter),
       phases.LinearizePhases.ToSplicecode(self.reporter)

       #CodeGenPhase(self.reporter, self.codeGenContext, self.settings)
       ]


    def _reportPhase(self, item, phaseName):
      if (phaseName):
        self.reporter.info("{0}: phase: '{1}'".format(item, phaseName))
      else:
        self.reporter.info("{0}:".format(item))

    #? Better to quit without run, if data requested, in what circumstance?
    # - no path? But not XOtree, tree, ranges, phase marks, tables...
    def run(self, compilationUnit):
       # If output tokens, print and quit
       if (self.settings.getValue('XOtokens')):
         self.reporter.info('Tokens:\n' + compilationUnit.source.tokenIterator().toPrettyString())
         sys.exit(0)

       # If setting data output, print and quit
       if (self.settings.getValue('XOsettings')):
           self.reporter.info('Settings:\n' + self.settings.toPrettyString())
           sys.exit(0)

       # If phase data output, print and quit
       if (self.settings.getValue('XOphases')): 
         self.reporter.info('Phases:\n' + self.phases.phaseDataToString())
         sys.exit(0)

       endPhaseName = self.settings.getValue('XCtoPhase')
       phaseList = self.phases
       if (endPhaseName):
          # limit phase list
          if(not self.phases.contains(endPhaseName)):
              self.reporter.warning("Phase name not in list:phase name: '{0}'\nIgnoring XCtoPhase limit".format(endPhaseName))
          else:
              phaseList = self.phases.take(endPhaseName)

       endPhaseName = endPhaseName if (endPhaseName) else 'all'


       #!
       #if (self.settings.getValue('XOphases')):
       #  self.reporter.info('Phases:\n' + phaseList.phaseDataToString())
       #  sys.exit(0)

       for p in phaseList:
         if (self.settings.getValue('XCphases')):
            self.reporter.info("phase: '{0}'".format(p.name))
         p.run(compilationUnit)
         if (self.reporter.hasErrors()):
             break 

       #? May be better done by sending print signals
       #? to the phase, then halting right there?
       # if symbol table output requested
       if (self.settings.getValue('XOexpressionSymbolTable')):
           self._reportPhase('expression symbol table', endPhaseName)
           self.reporter.info('Table:\n' + self.expSymbolTable.toPrettyString())

       if (self.settings.getValue('XOkindSymbolTable')):
           self._reportPhase('kind symbol table', endPhaseName)
           self.reporter.info('Table:\n' + self.kindSymbolTable.toPrettyString())

       # if tree output requested
       if (self.settings.getValue('XOtree')):
           #print('XOtree' + str(self.settings.getValue('XOtree')))
           self._reportPhase('tree', endPhaseName)
           self.reporter.info('Tree:\n' + compilationUnit.tree.toPrettyString())
#.........这里部分代码省略.........
开发者ID:rcrowther,项目名称:wild,代码行数:103,代码来源:RunnerContext.py


注:本文中的Settings.Settings.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。