Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more indexing progress; more class structure cleanup
  • Loading branch information
diakopter committed Nov 6, 2011
1 parent 0cbe07e commit a72e595
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
22 changes: 7 additions & 15 deletions lua/runtime/Runtime/CaptureHelper.lua
Expand Up @@ -4,11 +4,12 @@ CaptureHelper.FLATTEN_POS = 1;
CaptureHelper.FLATTEN_NAMED = 2;

function CaptureHelper.FormWith (PosArgs, NamedArgs, FlattenSpec)
local C = CaptureHelper.CaptureTypeObject.STable.REPR:instance_of(nil, CaptureHelper.CaptureTypeObject);
local REPR = CaptureHelper.CaptureTypeObject.STable.REPR;
local C = REPR.instance_of(REPR, nil, CaptureHelper.CaptureTypeObject);
if PosArgs ~= nil then
C.Positionals = List.new();
for k,v in ipairs(PosArgs) do
C.Positionals:Add(v);
List.Add(C.Positionals, v);
end
end;
if NamedArgs ~= nil then C.Nameds = NamedArgs end;
Expand All @@ -17,12 +18,7 @@ function CaptureHelper.FormWith (PosArgs, NamedArgs, FlattenSpec)
end

function CaptureHelper.GetPositional (Capture, Pos)
local Possies = Capture.Positionals;
if (Possies ~= nil and Pos <= #Possies) then
return Possies[Pos];
else
return nil;
end
return Capture.Positionals[Pos];
end

function CaptureHelper.NumPositionals (Capture)
Expand All @@ -37,12 +33,7 @@ function CaptureHelper.NumPositionals (Capture)
end

function CaptureHelper.GetNamed (Capture, Name)
local Nameds = Capture.Nameds;
if (Nameds ~= nil and Nameds[Name] ~= nil) then
return Nameds[Name];
else
return nil;
end
return Capture.Nameds and Capture.Nameds[Name] or nil;
end

function CaptureHelper.GetPositionalAsString (Capture, Pos)
Expand All @@ -51,5 +42,6 @@ end

-- only slightly less horrible.
function CaptureHelper.Nil (TC)
return TC.DefaultListType.STable.REPR:instance_of(TC, TC.DefaultListType);
local REPR = TC.DefaultListType.STable.REPR;
return REPR.instance_of(REPR, TC, TC.DefaultListType);
end
6 changes: 4 additions & 2 deletions lua/runtime/Runtime/CodeObjectUtility.lua
@@ -1,13 +1,15 @@
CodeObjectUtility = {};

function CodeObjectUtility.WrapNativeMethod (Code)
local Wrapper = REPRRegistry.get_REPR_by_name("KnowHOWREPR"):type_object_for(nil, nil);
local REPR = REPRRegistry.get_REPR_by_name("KnowHOWREPR");
local Wrapper = REPR.type_object_for(REPR, nil, nil);
Wrapper.STable.SpecialInvoke = Code;
return Wrapper;
end

function CodeObjectUtility.BuildStaticBlockInfo (Code, Outer, LexNames, BlockName)
local Result = CodeObjectUtility.LLCodeTypeObject.STable.REPR:instance_of(nil, CodeObjectUtility.LLCodeTypeObject);
local REPR = CodeObjectUtility.LLCodeTypeObject.STable.REPR;
local Result = REPR.instance_of(REPR, nil, CodeObjectUtility.LLCodeTypeObject);
Result.Body = Code;
Result.OuterBlock = Outer;
Result.BlockName = BlockName;
Expand Down
6 changes: 3 additions & 3 deletions lua/runtime/Runtime/Context.lua
@@ -1,9 +1,8 @@
function makeContext ()
local Context = {};
local Context = { ["class"] = "Context" };
local mt = { __index = Context };
function Context.newplain()
local this = {};
return setmetatable(this, mt);
return setmetatable({}, mt);
end
function Context.new(StaticCodeObject, Caller, Capture)
local this = {};
Expand Down Expand Up @@ -40,6 +39,7 @@ function makeContext ()
end
return setmetatable(this, mt);
end
Context[1] = Context.new;
return Context;
end
Context = makeContext();
Expand Down
2 changes: 1 addition & 1 deletion lua/runtime/Runtime/ExecutionDomain.lua
@@ -1,5 +1,5 @@
function makeExecutionDomain ()
local ExecutionDomain = {};
local ExecutionDomain = { ["class"] = "ExecutionDomain" };
local mt = { __index = ExecutionDomain };
function ExecutionDomain.new()
local this = {};
Expand Down
7 changes: 5 additions & 2 deletions lua/runtime/Runtime/Lexpad.lua
@@ -1,5 +1,5 @@
function makeLexpad ()
local Lexpad = {};
local Lexpad = { ["class"] = "Lexpad" };
local mt = { __index = Lexpad };
function Lexpad.new(SlotNames)
local this = {};
Expand All @@ -11,13 +11,15 @@ function makeLexpad ()
this.Storage = List.new(this.SlotCount);
return setmetatable(this, mt);
end

Lexpad[1] = Lexpad.new;
function Lexpad:GetByName(Name)
return self.Storage[self.SlotMapping[Name]];
end
Lexpad[2] = Lexpad.GetByName;
function Lexpad:SetByName(Name, Value)
self.Storage[self.SlotMapping[Name]] = Value;
end
Lexpad[3] = Lexpad.SetByName;
function Lexpad:Extend(Names)
local SlotMapping = {};
for k,v in pairs(self.SlotMapping) do
Expand All @@ -35,6 +37,7 @@ function makeLexpad ()
self.SlotCount = new;
self.Storage = NewStorage;
end
Lexpad[4] = Lexpad.Extend;
return Lexpad;
end
Lexpad = makeLexpad();
5 changes: 2 additions & 3 deletions lua/runtime/Runtime/ThreadContext.lua
@@ -1,9 +1,8 @@
function makeThreadContext ()
local ThreadContext = {};
local ThreadContext = { ["class"] = "ThreadContext" };
local mt = { __index = ThreadContext };
function ThreadContext.new()
local this = {};
return setmetatable(this, mt);
return setmetatable({}, mt);
end
return ThreadContext;
end
Expand Down

0 comments on commit a72e595

Please sign in to comment.