Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more prep for integer index optimization
  • Loading branch information
diakopter committed Nov 13, 2011
1 parent 442d8d3 commit 37d0e04
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 28 deletions.
4 changes: 2 additions & 2 deletions lua/runtime/Metamodel/Representations/P6hash.lua
Expand Up @@ -49,7 +49,7 @@ function makeP6hash ()
end
P6hash[6] = P6hash.get_attribute;
function P6hash:get_attribute_with_hint(TC, I, ClassHandle, Name, Hint)
return self:get_attribute(TC, Object, ClassHandle, Name);
return self.get_attribute(self, TC, Object, ClassHandle, Name);
end
P6hash[7] = P6hash.get_attribute_with_hint;
function P6hash:bind_attribute(TC, Object, ClassHandle, Name, Value)
Expand All @@ -60,7 +60,7 @@ function makeP6hash ()
end
P6hash[8] = P6hash.bind_attribute;
function P6hash:bind_attribute_with_hint(TC, Object, ClassHandle, Name, Hint, Value)
self:bind_attribute(TC, Object, ClassHandle, Name, Value);
self.bind_attribute(self, TC, Object, ClassHandle, Name, Value);
end
P6hash[9] = P6hash.bind_attribute_with_hint;
return P6hash;
Expand Down
4 changes: 2 additions & 2 deletions lua/runtime/Metamodel/Representations/P6opaque.lua
Expand Up @@ -48,7 +48,7 @@ function makeP6opaque ()
end
P6opaque[6] = P6opaque.get_attribute;
function P6opaque:get_attribute_with_hint(TC, I, ClassHandle, Name, Hint)
return self:get_attribute(TC, Object, ClassHandle, Name);
return self.get_attribute(self, TC, Object, ClassHandle, Name);
end
P6opaque[7] = P6opaque.get_attribute_with_hint;
function P6opaque:bind_attribute(TC, Object, ClassHandle, Name, Value)
Expand All @@ -59,7 +59,7 @@ function makeP6opaque ()
end
P6opaque[8] = P6opaque.bind_attribute;
function P6opaque:bind_attribute_with_hint(TC, Object, ClassHandle, Name, Hint, Value)
self:bind_attribute(TC, Object, ClassHandle, Name, Value);
self.bind_attribute(self, TC, Object, ClassHandle, Name, Value);
end
P6opaque[9] = P6opaque.bind_attribute_with_hint;
return P6opaque;
Expand Down
17 changes: 11 additions & 6 deletions lua/runtime/Metamodel/SharedTable.lua
Expand Up @@ -32,15 +32,17 @@ function makeSharedTable ()
-- Find the find_method method.
local HOW = Obj.STable.HOW;
local Meth = Obj.STable.CachedFindMethod;
local STable = HOW.STable;
if (Meth == nil) then
Meth = HOW.STable:FindMethod(
Meth = STable.FindMethod(STable,
TC, HOW, "find_method", Hints.NO_HINT);
Obj.STable.CachedFindMethod = Meth;
end

-- Call it.
local Cap = CaptureHelper.FormWith({ HOW, Obj, Ops.box_str(TC, Name, TC.DefaultStrBoxType) });
return Meth.STable:Invoke(TC, Meth, Cap);
STable = Meth.STable;
return STable.Invoke(STable, TC, Meth, Cap);
end
end
SharedTable[2] = SharedTable.FindMethod;
Expand All @@ -50,9 +52,10 @@ function makeSharedTable ()
end
local STable = Obj.STable;
if (STable.CachedInvoke == nil) then
STable.CachedInvoke = Obj.STable:FindMethod(TC, Obj, "postcircumfix:<( )>", Hints.NO_HINT);
STable.CachedInvoke = STable.FindMethod(STable, TC, Obj, "postcircumfix:<( )>", Hints.NO_HINT);
end
return STable.CachedInvoke.STable:Invoke(TC, Obj, Cap);
STable = STable.CachedInvoke.STable;
return STable.Invoke(STable, TC, Obj, Cap);
end
SharedTable[3] = SharedTable.Invoke;
function SharedTable:TypeCheck(TC, Obj, Checkee)
Expand All @@ -64,9 +67,11 @@ function makeSharedTable ()
end
return Ops.box_int(TC, 0, TC.DefaultBoolBoxType);
else
local Checker = self.HOW.STable:FindMethod(TC, self.HOW, "type_check", Hints.NO_HINT);
local STable = self.HOW.STable;
local Checker = STable.FindMethod(STable, TC, self.HOW, "type_check", Hints.NO_HINT);
local Cap = CaptureHelper.FormWith({ self.HOW, Obj, Checkee });
return Checker.STable:Invoke(TC, Checker, Cap);
STable = Checker.STable;
return STable.Invoke(STable, TC, Checker, Cap);
end
end
SharedTable[4] = SharedTable.TypeCheck;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Runtime/MultiDispatch/DispatchCache.lua
Expand Up @@ -99,7 +99,8 @@ function makeDispatchCache ()
local Result = List.new(Positionals.Count);
for i = 1, Positionals.Count do
local STable = Positionals[i].STable;
Result[i] = bit.bor(STable.TypeCacheID, STable.REPR:defined(nil, Positionals[i]) and 1 or 0);
local REPR = STable.REPR;
Result[i] = bit.bor(STable.TypeCacheID, REPR.defined(REPR, nil, Positionals[i]) and 1 or 0);
end
return Result;
end
Expand Down
26 changes: 16 additions & 10 deletions lua/runtime/Runtime/Ops/Boxing.lua
@@ -1,26 +1,32 @@
function Ops.box_int (TC, Value, To)
local REPR;
if To ~= nil then
local REPR = To.STable.REPR;
local Result = REPR:instance_of(TC, To);
REPR:set_int(TC, Result, Value);
REPR = To.STable.REPR;
local Result = REPR.instance_of(REPR, TC, To);
REPR.set_int(REPR, TC, Result, Value);
return Result;
else
local Result = TC.DefaultIntBoxType.STable.REPR:instance_of(TC, TC.DefaultIntBoxType);
TC.DefaultIntBoxType.STable.REPR:set_int(TC, Result, Value);
REPR = TC.DefaultIntBoxType.STable.REPR;
local Result = REPR.instance_of(REPR, TC, TC.DefaultIntBoxType);
REPR = TC.DefaultIntBoxType.STable.REPR;
REPR.set_int(REPR, TC, Result, Value);
return Result;
end
end
Ops[1] = Ops.box_int;

function Ops.box_num (TC, Value, To)
local REPR;
if To ~= nil then
local REPR = To.STable.REPR;
local Result = REPR:instance_of(TC, To);
REPR:set_num(TC, Result, Value);
REPR = To.STable.REPR;
local Result = REPR.instance_of(REPR, TC, To);
REPR.set_num(REPR, TC, Result, Value);
return Result;
else
local Result = TC.DefaultNumBoxType.STable.REPR:instance_of(TC, TC.DefaultNumBoxType);
TC.DefaultNumBoxType.STable.REPR:set_num(TC, Result, Value);
REPR = TC.DefaultNumBoxType.STable.REPR;
local Result = REPR.instance_of(REPR, TC, TC.DefaultNumBoxType);
REPR = TC.DefaultNumBoxType.STable.REPR;
REPR.set_num(REPR, TC, Result, Value);
return Result;
end
end
Expand Down
5 changes: 3 additions & 2 deletions lua/runtime/Runtime/Ops/Dispatch.lua
Expand Up @@ -5,7 +5,8 @@ function Ops.multi_dispatch_over_lexical_candidates(TC)
if (CodeObj.Dispatchees ~= nil) then
local Candidate = MultiDispatch.MultiDispatcher.FindBestCandidate(TC,
CodeObj, CurOuter.Capture);
return Candidate.STable:Invoke(TC, Candidate, CurOuter.Capture);
local STable = Candidate.STable;
return STable.Invoke(STable, TC, Candidate, CurOuter.Capture);
end
CurOuter = CurOuter.Outer;
end
Expand Down Expand Up @@ -55,7 +56,7 @@ function Ops.push_dispatchee(TC, Dispatcher, Dispatchee)
if (Target.Dispatchees == nil) then
error("push_dispatchee passed something that is not a dispatcher");
end
Target.Dispatchees:Add(Dispatchee);
List.Add(Target.Dispatchees, Dispatchee);

return Target;
end
Expand Down
10 changes: 5 additions & 5 deletions lua/runtime/Runtime/Ops/P6list.lua
Expand Up @@ -23,27 +23,27 @@ end
Ops[64] = Ops.lllist_elems;

function Ops.lllist_push(TC, LLList, item)
LLList.Storage:Push(item);
List.Push(LLList.Storage, item);
end
Ops[65] = Ops.lllist_push;

function Ops.lllist_pop(TC, LLList)
return LLList.Storage:Pop();
return List.Pop(LLList.Storage);
end
Ops[66] = Ops.lllist_pop;

function Ops.lllist_truncate_to(TC, LLList, Length)
LLList.Storage:Truncate(Ops.unbox_int(TC, Length));
List.Truncate(LLList.Storage, Ops.unbox_int(TC, Length));
return LLList;
end
Ops[67] = Ops.lllist_truncate_to;

function Ops.lllist_shift(TC, LLList)
return LLList.Storage:Shift();
return List.Shift(LLList.Storage);
end
Ops[68] = Ops.lllist_shift;

function Ops.lllist_unshift(TC, LLList, item)
return LLList.Storage:Unshift(item);
return List.Unshift(LLList.Storage, item);
end
Ops[69] = Ops.lllist_unshift;

0 comments on commit 37d0e04

Please sign in to comment.