Skip to content

Instantly share code, notes, and snippets.

------------------------------------
-- basic TLS/SSL3.1 implementation
-- $Id: ssl.lua,v 1.13 2006-12-02 21:25:58 kt Exp $
------------------------------------
require "clua"
require "util"
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "crypto.h"
/*************************************************
* math lib
*************************************************/
local funtab=setmetatable({}, {__mode="k",__index=function(t,k) t[k]={}; return t[k] end})
debug.setmetatable(function() end, {
__index=function(f,k)
return funtab[f][k]
end,
__newindex=function(f,k,v)
funtab[f][k] = v
end
});
local resurrect
local t = setmetatable({}, {
__gc = function(t)
print("resurrecting")
resurrect=t
end
})
local weak = setmetatable({x=t}, {__mode="v"})
t = nil
collectgarbage()
diff -ruN lua-5.3.0-work2/src/lgc.c lua-5.3.0-work2-resurrectfin/src/lgc.c
--- lua-5.3.0-work2/src/lgc.c 2014-03-21 14:52:33.000000000 +0100
+++ lua-5.3.0-work2-resurrectfin/src/lgc.c 2014-05-03 17:53:35.358176913 +0200
@@ -815,6 +815,7 @@
int running = g->gcrunning;
L->allowhook = 0; /* stop debug hooks during GC metamethod */
g->gcrunning = 0; /* avoid GC steps */
+ resetbit(gch(gcvalue(&v))->marked, FINALIZEDBIT); /* Might be finalized again. */
setobj2s(L, L->top, tm); /* push finalizer... */
setobj2s(L, L->top + 1, &v); /* ... and its argument */
-- class implementation
local function class(t)
t.__index = t
return t
end
local function extend(dst,src)
for k,v in pairs(src) do
if type(k) == "string" and k:sub(1,1) ~= "_" then
dst[k] = dst[k] or v
end
-- example class Foo
local Foo = {
attr1 = 1,
attr2 = 2,
}
Foo.__index = Foo
function Foo:getattr1()
return self.attr1
end
/* OPCODES:
* -------
* OP_SETABC(a,b,c)
* frame->A = frame[a] etc
* set "segments" for each a, b, c (-1 do not set anything for given letter)
* arguments must refer to valid TT_TAGGED tables.
* OP_GETT(a,b,c)
* A[a] = B[b][C[c]] if table
* OR A[a] = B[b](->self,C[c]) if function call
* OP_SETT(a=val,b=tab,c=key)
'use strict'
let inherits = require('util').inherits
let Buffer = function(a,b)
{
if (!(this instanceof Buffer))
return new Buffer(a, b)
return Uint8Array.call(this,a,b)
}
inherits(Uint8Array, Buffer)
'use strict'
let Buffer = function(a,b)
{
if (!(this instanceof Buffer))
return new Buffer(a, b)
let self = Uint8Array.call(this,a,b)
self.__proto__ = Buffer.prototype
return self
}
Buffer.prototype = Object.create(Uint8Array.prototype, Buffer.prototype)