예제 #1
0
 def printInfo(self):
     pp = PrettyPrinter()
     with PPWrap(pp, "Player Stats"):
         self.player_stats.printInfo(pp)
     with PPWrap(pp, "World Data"):
         self.worlds.printInfo(pp)
     with PPWrap(pp, "Player Data"):
         self.player_data.printInfo(pp)
예제 #2
0
 def visitStatementBlockOpt_StatementMul(self, statementBlockOpt):
     print('{')
     pp.incrementTab()
     statementBlockOpt.statementmul.accept(self)
     pp.decrementTab()
     pp.printTab()
     print('}')
예제 #3
0
 def visitFds_statements_withStatements(self, fds_statements):
   print('{')
   pp.incrementTab()
   fds_statements.inner_statement_MUL.accept(self)
   pp.decrementTab()
   pp.printTab()
   print('}')
예제 #4
0
    def fromBinary(self, binrdr):
        """
        Load an FCH file into memory.
        """
        # Before we can load the data we have some validation to perform.
        # The file is wrapped in the following format:
        # 
        #   i32 data_byte_count
        #   u8[data_byte_count] data
        #   i32 checksum_byte_count
        #   u8[checksum_byte_count] checksum
        #
        # The checksum is a SHA-512 of "data". The checksum is not validated
        # by the Valheim engine, at the time of writing. However, we're going
        # to validate it here if we have access to a SHA-512 algorithm.
        #
        info("Reading FCH file from disk...")
        byte_count = binrdr.read_i32()
        start_pos = binrdr.tell()
        # Skip the byte data for now, we'll extract the checksum first.
        binrdr.skip(byte_count)
        checksum_size = binrdr.read_i32()
        checksum = binrdr.read(checksum_size)

        # If we get here without failures, then the file is at least big enough
        # according to the basic check.
        #
        # Now calculate the checksum and verify the data!
        if _have_sha512:
            binrdr.push_pos(start_pos)
            calc_checksum = self._calculate_checksum(binrdr, byte_count)
            binrdr.pop_pos()
            if checksum != calc_checksum:
                pp = PrettyPrinter()
                pp.bytes("Disk Checksum", checksum)
                pp.bytes("Calculated Checksum", calc_checksum)
                die("Calculated checksum does not match the one loaded from "
                    "disk!")
        # Checksum seems legit, lets go!
        binrdr.push_pos(start_pos)
        self.player_stats.fromBinary(binrdr)
        self.worlds.fromBinary(binrdr, self.player_stats.version)
        self.player_data.fromBinary(binrdr, self.player_stats.version)
        binrdr.pop_pos()
        info("Reading FCH file succeeded.")
예제 #5
0
 def visitStatement_Global(self, statement):
   pp.printTab()
   statement._global.accept(self)
   print(';')
예제 #6
0
 def visitStatementBlockOpt_Statement(self, statementblockopt):
     print()
     pp.incrementTab()
     statementblockopt.statement.accept(self)
     pp.decrementTab()
예제 #7
0
 def visitMain_MainProgram(self, main):
   print('<?php')
   pp.incrementTab()
   main.mainInner.accept(self)
   print('?>')
예제 #8
0
 def visitFuncDecStatement_Function(self, funcDecStatement):
   pp.printTab()
   print('function', end=' ')
   funcDecStatement.fds_id.accept(self)
   funcDecStatement.fds_parameter.accept(self)
   funcDecStatement.fds_statements.accept(self)
예제 #9
0
 def visitStatementElse_Single(self, statementElse):
   pp.printTab()
   print('else',end='')
   statementElse.statement_BLOCK_OPT.accept(self)
예제 #10
0
 def visitStatement_Break(self, statement):
   pp.printTab()
   statement._break.accept(self)
예제 #11
0
 def visitStatementBlockOpt_Empty(self, statementblockopt):
     print('{')
     pp.printTab()
     print('}')
예제 #12
0
 def visitStatement_Foreach(self, statement):
   pp.printTab()
   statement.foreach.accept(self)
예제 #13
0
 def visitStatement_Die(self, statement):
   pp.printTab()
   statement.die.accept(self)
   print(';')
예제 #14
0
 def visitStatement_Do_While(self, statement):
   pp.printTab()
   statement.dowhilee.accept(self)
   print(';')
예제 #15
0
 def visitStatement_While(self, statement):
   pp.printTab()
   statement.whilee.accept(self)
예제 #16
0
 def visitStatement_Exit(self, statement):
   pp.printTab()
   statement.exit.accept(self)
   print(';')
예제 #17
0
 def visitStatement_Return(self, statement):
   pp.printTab()
   statement._return.accept(self)
예제 #18
0
 def visitStatement_Continue(self, statement):
   pp.printTab()
   statement._continue.accept(self)
예제 #19
0
 def visitDoWhileStatementSingle(self, whilestatement):
     print('do', end='')
     whilestatement.statementblockopt.accept(self)
     pp.printTab()
     print('while', end='')
     whilestatement.exprparentheses.accept(self)
예제 #20
0
 def visitStatement_For(self, statement):
   pp.printTab()
   statement._for.accept(self)
예제 #21
0
 def visitFds_statements_noStatements(self, fds_statements):
   print('{')
   pp.printTab()
   print('}')
예제 #22
0
 def visitStatementElseIf_Mul(self, statementElseIfMul):
   pp.printTab()
   print('elseif',end='')
   statementElseIfMul.expr_parentheses.accept(self)
   statementElseIfMul.statement_BLOCK_OPT.accept(self)
   statementElseIfMul.statement_elseif.accept(self)
예제 #23
0
 def visitStatementElseIf_Single(self, statementElseIfSingle):
   pp.printTab()
   print('elseif',end='')
   statementElseIfSingle.expr_parentheses.accept(self)
   statementElseIfSingle.statement_BLOCK_OPT.accept(self)
예제 #24
0
def toString(ast):
    pp = PrettyPrinter()
    ret = pp.toString(ast)
    return ret