Commits

Laurens Rodriguez  committed c2774cf

Aded script to help backporting fixes in Lua 5.2.2 to Killa

  • Participants
  • Parent commits d7f7c74

Comments (0)

Files changed (1)

File extra/killa/compare.pl

+##==============================================================================
+## this script helps to compare Lua and Killa source files.
+## NOTE: install module with: cmd> cpan> install File::Copy::Recursive
+## Copyright (c) 2013 Laurens Rodriguez Oscanoa.
+## This code is licensed under the MIT license.
+##------------------------------------------------------------------------------
+use strict;
+use warnings;
+
+use File::Basename;
+use File::Copy::Recursive qw( dircopy fcopy );
+use File::Path qw( rmtree );;
+
+my $TARGET_LUA_DIR = "../../src/libraries/lua52";
+my $TARGET_KILLA_DIR = "../../src/libraries/killa";
+my $RESULT_DIR = "temp/";
+my $MERGE_PROGRAM = '"C:\Program Files\WinMerge\WinMergeU.exe"';
+
+my $END_COMMENTS = "/* -------------------------------------------------------------------------- */";
+
+rmtree( $RESULT_DIR );
+
+dircopy( $TARGET_LUA_DIR, $RESULT_DIR . "lua" ) or die "$!";
+recurseDir( $TARGET_KILLA_DIR, \&renameFile );
+
+system($MERGE_PROGRAM . " $RESULT_DIR/lua  $RESULT_DIR/killa ");
+
+sub recurseDir
+{
+    my $path = $_[0];
+    my $function = $_[1];
+
+    ## Append a trailing / if it's not there.
+    $path .= '/' if ( $path !~ /\/$/ );
+
+    ## Loop through the files contained in the directory.
+    for my $eachFile ( glob( $path.'*' ) )
+    {
+        if ( -d $eachFile )
+        {
+            ## If the file is a directory, continue recursive scan.
+            recurseDir( $eachFile, $function );
+        }
+        else
+        {
+            ## Process file.
+            $function->( $eachFile );
+        }
+    }
+}
+
+sub changeName
+{
+    my $name = $_[0];
+    $name =~ s/killa/lua/;
+    $name =~ s/^k/l/;
+    return $name;
+}
+
+sub renameFile
+{
+    my $source = $_[0];
+    my $destine = $RESULT_DIR . "killa/" . changeName( basename( $source ) );
+
+    fcopy( $source, $destine ) or die "$!";
+
+    open( my $IN, '<', $destine ) or die "$!";
+    open( my $OUT, '>', $destine ."_" ) or die "$!";
+
+    my $tags = 0;
+
+    while ( <$IN> )
+    {
+        my $line = $_;
+        $line =~ s/killa_TValue/TValue/g;
+        $line =~ s/killa_CClosure/CClosure/g;
+        $line =~ s/killa_cast/cast/g;
+        $line =~ s/killa_CallInfo/CallInfo/g;
+        $line =~ s/killa_api_check/api_check/g;
+        $line =~ s/KILLA_G\(/G\(/g;
+        $line =~ s/killa_clCvalue/clCvalue/g;
+        $line =~ s/killa_setobj/setobj/g;
+        $line =~ s/KILLA_MAXUPVAL/MAXUPVAL/g;
+        $line =~ s/killa_ttislcf/ttislcf/g;
+        $line =~ s/killaA_checknelems/api_checknelems/g;
+        $line =~ s/killa_StkId/StkId/g;
+        $line =~ s/killa_setnullvalue/setnilvalue/g;
+        $line =~ s/killa_ttypename/ttypename/g;
+        $line =~ s/killa_nvalue/nvalue/g;
+        $line =~ s/killa_ttisstring/ttisstring/g;
+        $line =~ s/killa_svalue/svalue/g;
+        $line =~ s/killa_tsvalue/tsvalue/g;
+        $line =~ s/killa_uvalue/uvalue/g;
+        $line =~ s/killa_hvalue/hvalue/g;
+        $line =~ s/KILLA_EXTRA_STACK/EXTRA_STACK/g;
+        $line =~ s/killa_ttypenv/ttypenv/g;
+        $line =~ s/KILLA_UNUSED/UNUSED/g;
+        $line =~ s/killa_ttisCclosure/ttisCclosure/g;
+        $line =~ s/killa_vmtonumber/tonumber/g;
+        $line =~ s/killa_ttisuserdata/ttisuserdata/g;
+        $line =~ s/killa_ttislightuserdata/ttislightuserdata/g;
+        $line =~ s/killa_ttisnumber/ttisnumber/g;
+        $line =~ s/killa_equalobj/equalobj/g;
+        $line =~ s/killa_isfalse/l_isfalse/g;
+        $line =~ s/killaA_incr_top/api_incr_top/g;
+        $line =~ s/KILLA_TMS/TMS/g;
+        $line =~ s/killa_fvalue/fvalue/g;
+        $line =~ s/killa_rawuvalue/rawuvalue/g;
+        $line =~ s/killa_pvalue/pvalue/g;
+        $line =~ s/killa_ttisthread/ttisthread/g;
+        $line =~ s/killa_thvalue/thvalue/g;
+        $line =~ s/killa_clLvalue/clLvalue/g;
+        $line =~ s/killa_setnvalue/setnvalue/g;
+        $line =~ s/killa_TString/TString/g;
+        $line =~ s/killa_setsvalue2s/setsvalue2s/g;
+        $line =~ s/killa_getstr/getstr/g;
+        $line =~ s/killa_Closure/Closure/g;
+        $line =~ s/killa_setclCvalue/setclCvalue/g;
+        $line =~ s/killa_setbvalue/setbvalue/g;
+        $line =~ s/killa_setpvalue/setpvalue/g;
+        $line =~ s/killa_Table/Table/g;
+        $line =~ s/killa_ttype/ttype/g;
+        $line =~ s/killa_pushnull/lua_pushnil/g;
+        $line =~ s/killa_setfvalue/setfvalue/g;
+        $line =~ s/killa_setthvalue/setthvalue/g;
+        $line =~ s/killa_ttistable/ttistable/g;
+        $line =~ s/killa_invalidateTMcache/invalidateTMcache/g;
+        $line =~ s/killa_gcvalue/gcvalue/g;
+        $line =~ s/KILLA_CIST_YIELDED/CIST_YIELDED/g;
+        $line =~ s/killa_isKilla/isLua/g;
+        $line =~ s/killaA_adjustresults/adjustresults/g;
+        $line =~ s/KILLA_CIST_YPCALL/CIST_YPCALL/g;
+        $line =~ s/killa_LClosure/LClosure/g;
+        $line =~ s/killa_isLfunction/isLfunction/g;
+        $line =~ s/killa_getproto/getproto/g;
+        $line =~ s/killa_Udata/Udata/g;
+        $line =~ s/killa_setuvalue/setuvalue/g;
+        $line =~ s/killa_UpVal/UpVal/g;
+        $line =~ s/killa_sethvalue/sethvalue/g;
+        $line =~ s/killa_ttisnull/ttisnil/g;
+        $line =~ s/killa_savestack/savestack/g;
+        $line =~ s/killa_ZIO/ZIO/g;
+        $line =~ s/killa_GlobalState/global_State/g;
+        $line =~ s/killa_GCObject/GCObject/g;
+        $line =~ s/killa_obj2gco/obj2gco/g;
+        $line =~ s/killa_Proto/Proto/g;
+        $line =~ s/killa_ttisLclosure/ttisLclosure/g;
+        $line =~ s/killa_gettotalbytes/gettotalbytes/g;
+        $line =~ s/killa_GCSpause/GCSpause/g;
+        $line =~ s/KILLA_KGC_GEN/KGC_GEN/g;
+        $line =~ s/KILLA_KGC_NORMAL/KGC_NORMAL/g;
+        $line =~ s/killa_isnull/lua_isnil/g;
+        $line =~ s/killa_isnoneornull/lua_isnoneornil/g;
+        $line =~ s/KILLA_TNULL/LUA_TNIL/g;
+        $line =~ s/killa_expdesc/expdesc/g;
+        $line =~ s/killa_FuncState/FuncState/g;
+        $line =~ s/killa_Instruction/Instruction/g;
+        $line =~ s/KILLA_GET_OPCODE/GET_OPCODE/g;
+        $line =~ s/KILLA_GETARG_A/GETARG_A/g;
+        $line =~ s/KILLA_GETARG_B/GETARG_B/g;
+        $line =~ s/KILLA_SETARG_A/SETARG_A/g;
+        $line =~ s/KILLA_SETARG_B/SETARG_B/g;
+        $line =~ s/KILLA_NO_JUMP/NO_JUMP/g;
+        $line =~ s/KILLA_MAXARG_sBx/MAXARG_sBx/g;
+        $line =~ s/KILLA_GETARG_sBx/GETARG_sBx/g;
+        $line =~ s/killa_testTMode/testTMode/g;
+        $line =~ s/KILLA_NO_REG/NO_REG/g;
+        $line =~ s/KILLA_MAX_INT/MAX_INT/g;
+        $line =~ s/killa_getOpMode/getOpMode/g;
+        $line =~ s/killa_getBMode/getBMode/g;
+        $line =~ s/killa_getCMode/getCMode/g;
+        $line =~ s/KILLA_CREATE_ABC/CREATE_ABC/g;
+        $line =~ s/killa_OpCode/OpCode/g;
+        $line =~ s/KILLA_SETARG_sBx/SETARG_sBx/g;
+        $line =~ s/KILLA_GETARG_C/GETARG_C/g;
+        $line =~ s/KILLA_MAXARG_A/MAXARG_A/g;
+        $line =~ s/KILLA_MAXARG_B/MAXARG_B/g;
+        $line =~ s/KILLA_MAXARG_C/MAXARG_C/g;
+        $line =~ s/KILLA_CREATE_ABx/CREATE_ABx/g;
+        $line =~ s/KILLA_MAXARG_Bx/MAXARG_Bx/g;
+        $line =~ s/KILLA_ISK/ISK/g;
+        $line =~ s/KILLA_SETARG_C/SETARG_C/g;
+        $line =~ s/killaK_getcode/getcode/g;
+        $line =~ s/VNULL/VNIL/g;
+        $line =~ s/killaK_BinOpr/BinOpr/g;
+        $line =~ s/KILLA_CREATE_Ax/CREATE_Ax/g;
+        $line =~ s/killa_setsvalue/setsvalue/g;
+        $line =~ s/killa_check_exp/check_exp/g;
+        $line =~ s/killa_vkisinreg/vkisinreg/g;
+        $line =~ s/killaK_UnOpr/UnOpr/g;
+        $line =~ s/killa_pcRel/pcRel/g;
+        $line =~ s/killa_getfuncline/getfuncline/g;
+        $line =~ s/killa_ci_func/ci_func/g;
+        $line =~ s/killa_resethookcount/resethookcount/g;
+        $line =~ s/killa_incr_top/api_incr_top/g;
+        $line =~ s/KILLA_CIST_TAIL/CIST_TAIL/g;
+        $line =~ s/killa_ttisfunction/ttisfunction/g;
+        $line =~ s/killa_ttisclosure/ttisclosure/g;
+        $line =~ s/KILLA_INDEXK/INDEXK/g;
+        $line =~ s/killa_testAMode/testAMode/g;
+        $line =~ s/killa_objtypename/objtypename/g;
+        $line =~ s/killa_noret/l_noret/g;
+        $line =~ s/killa_LongJmp/lua_longjmp/g;
+        $line =~ s/killa_clvalue/clvalue/g;
+        $line =~ s/killa_restorestack/restorestack/g;
+        $line =~ s/killa_gco2uv/gco2uv/g;
+        $line =~ s/killa_condmovestack/condmovestack/g;
+        $line =~ s/killa_restorestack/restorestack/g;
+        $line =~ s/KILLA_CIST_STAT/CIST_STAT/g;
+        $line =~ s/KILLA_CIST_HOOKED/CIST_HOOKED/g;
+        $line =~ s/killa_ubyte/lu_byte/g;
+        $line =~ s/killa_Mbuffer/Mbuffer/g;
+        $line =~ s/killa_Dyndata/Dyndata/g;
+        $line =~ s/killa_bvalue/bvalue/g;
+        $line =~ s/killa_rawtsvalue/rawtsvalue/g;
+        $line =~ s/killa_sizeCclosure/sizeCclosure/g;
+        $line =~ s/killa_sizeLclosure/sizeLclosure/g;
+
+        $line =~ s/KILLA_/LUA_/g;
+        $line =~ s/KILLA/LUA/g;
+        $line =~ s/Killa/Lua/g;
+        $line =~ s/killa_/lua_/g;
+        $line =~ s/killa/lua/g;
+
+        print( $OUT $line ) if ( $tags > 1 );
+        $tags++ if ( index( $_, $END_COMMENTS ) == 0 );
+    }
+    close( $IN );
+    close( $OUT );
+    unlink( $destine );
+    rename( $destine . "_", $destine );
+}
+