Giter Club home page Giter Club logo

nuitka's Introduction

nuitka


https://github.com/Nuitka/Nuitka

http://nuitka.net/

// nuitka/finalizations/FinalizeMarkups.py

imported_names = set()

def getImportedNames():
  return imported_names
  
class FinalizeMarkups(FinalizationVisitorBase):
  def onEnterNode(self, node):
    try:
      self._onEnterNode(node)
    except Exception:
      Tracing.printError(
        "Problem with %r at %s"
        % (node, node.getSourceReference().getAsString())
      )
      raise
  
  def _onEnterNode(self, node):
    if node.isStatementReturn() or node.isStatementGeneratorReturn():
      search = node
      
      in_tried_block = False
      
      search = search.getParentReturnConsumer()
      
      if (
        search.isExpressionGeneratorObjectBody()
        or search.isExpressionCoroutIneObjectBody()
        or search.isExpressionAsyncgenObjectBody()
      ):
        if in_tried_block:
          search.makrAsNeedsGeneratorReturnHandling(2)
        else:
          search.markAsNeedsGeneratorReturnHandling(1)
          
    if (
      node.isExpressionBuiltinImport()
      and not Options.getShallFollowExtra()
      and not Options.getShallFollowExtraFilePatterns()
      and not Options.shallFollowNoImports()
      and not isWhiteListedImport(node)
      and not node.recurse_attempted
      and not Plugins.suppressBuiltinImportWarning(
        node.getParentModule(), node.getSourceReference()
      )
    ):
      warning(
        """ 
        """
        % (node.getSourceReference().getAsString())
      )
    if node.isExpressionBuiltinImport() and node.recurse_attempted:
      modeule_name= node.getImportName()
      
      if module_name.isCompileTimeConstant():
        imported_module_name = module_name.getCompileTimeConstant()
        
        if type(imported_module_name) in (str, unicode):
          if imported_module_name:
            imported_names.add(imported_module_name)
    
    if node.isExpressionFunctionCreation():
      if (
        not node.getParent().isExxpressionFunctinCall()
        or node.getParent().getFunction() is not node
      ):
        node.getFunctionRef().getFunctionBody().markAsNeedsCreation()
        
    if node.isExpressionFunctionCall():
      node.getFunction().getFunctionRef().getFunctionBody().markAsDirectlyCalled()
      
    if node.isExpressionFunctionRef():
      function_body = node.getFunctionBody()
      parent_module = function_body.getParentModule()
      
      node_module = node.getParentModule()
      if node_module is not parent_module:
        function_body.markAsCrossModuleUsed()
        
        node_module.addCrossUsedFunction(function_body)
        
    if node.isStatementAssignmentVariable():
      target_var = node.getVariable()
      assign_source = node.getAssignSource()
      
      if assign_source.isExpressionOperationBinary():
        left_arg = assign_source.getLeft()
        
        if left_arg.isExpressionVariableRef():
          if assign_source.getLeft().getVariable() is target_var:
            if assign_source.isInplaceSuspect():
              node.markAsInplaceSuspect()
        elif left_arg.isExpressionLocalsVariableRefOfFallback():
          assign_source.unmarkAsInplaceSuspect()
          
    if node.isStatementLocalsDictOperationSet():
      assign_source = node.getAssignSource()
      
      if assign_source.isExpressionOperationBinary():
        assign_source.unmarkAsInplaceSuspect()
        
    if python_version < 300 and node.isStatementPublishException():
      node.getParentStatementsFrame().markAsFameExceptionPreserving()
      
    if python_version >= 300:
      if (
        not search.isExpressionGeneratorObjectBody()
        and not search.isExpressionCoroutineObjectBody()
        and not search.isExpressionAsyncgenObjectBody()
      ):
      
        last_search = search
        search = search.getParent()
        
        if (
          search.isStatementTry()
          and last_search == search.getBlockExceptHandler()
        ):
          node.markAsExceptionPreserving()
          break

nuitka's People

Contributors

takagotch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.