Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bunches more bugfixes. still many to go I'm sure.
  • Loading branch information
diakopter committed Nov 2, 2011
1 parent c7d3c7d commit 630d886
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lua/compiler/LST2Lua.pm
Expand Up @@ -136,7 +136,7 @@ our multi sub cs_for(LST::MethodCall $mc) {
my $method_name := $invocant ~ '.' ~ $mc.name;
$code := $code ~ "$*LAST_TEMP = ";
}
$code := $code ~ "$invocant" ~ (($mc.name eq 'STable.Invoke' || $mc.name ~~ /":"/ || $invocant eq "Ops" || $invocant eq "SignatureBinder" || $invocant eq "CaptureHelper" || $invocant eq "CodeObjectUtility" || $invocant eq "Init") ?? "." !! ":") ~ $mc.name ~
$code := $code ~ "$invocant" ~ (($mc.name ~~ /":"/ || $invocant eq "Ops" || $invocant eq "SignatureBinder" || $invocant eq "CaptureHelper" || $invocant eq "CodeObjectUtility" || $invocant eq "Init") ?? "." !! ":") ~ $mc.name ~
"(" ~ pir::join(', ', @arg_names) ~ ");\n";
return $code;
}
Expand Down
12 changes: 7 additions & 5 deletions lua/compiler/PAST2LSTCompiler.pm
Expand Up @@ -60,6 +60,10 @@ method compile(PAST::Node $node) {
my $class := LST::Class.new(
:name($*COMPILING_NQP_SETTING ?? 'NQPSetting' !! unique_name_for_module())
);

$class.push(LST::Attribute.new( :name('StaticBlockInfo'), :type('RakudoCodeRef.Instance[]') ));
$class.push(LST::Attribute.new( :name('ConstantsTable'), :type('RakudoObject[]') ));

for @*INNER_BLOCKS {
$class.push($_);
}
Expand All @@ -78,8 +82,6 @@ method compile(PAST::Node $node) {
}

# Also need to include setup of static block info.
$class.push(LST::Attribute.new( :name('StaticBlockInfo'), :type('RakudoCodeRef.Instance[]') ));
$class.push(LST::Attribute.new( :name('ConstantsTable'), :type('RakudoObject[]') ));
$class.push(make_blocks_init_method('blocks_init'));
$class.push(make_constants_init_method('constants_init'));

Expand Down Expand Up @@ -477,7 +479,7 @@ our multi sub lst_for(PAST::Block $block) {
# low level code object.
if $block.blocktype eq 'immediate' {
return LST::MethodCall.new(
:name('STable.Invoke'), :type('RakudoObject'),
:name('STable:Invoke'), :type('RakudoObject'),
"StaticBlockInfo[$our_sbi]",
TC(),
"StaticBlockInfo[$our_sbi]",
Expand Down Expand Up @@ -595,7 +597,7 @@ our multi sub lst_for(PAST::Op $op) {
return LST::Stmts.new(
$inv,
LST::MethodCall.new(
:name('STable.Invoke'), :type('RakudoObject'),
:name('STable:Invoke'), :type('RakudoObject'),
$callee,
TC(),
$callee.name,
Expand All @@ -622,7 +624,7 @@ our multi sub lst_for(PAST::Op $op) {

# Emit call.
return LST::MethodCall.new(
:name('STable.Invoke'), :type('RakudoObject'),
:name('STable:Invoke'), :type('RakudoObject'),
$callee,
TC(),
$callee.name,
Expand Down
33 changes: 30 additions & 3 deletions lua/runtime/Metamodel/SharedTable.lua
Expand Up @@ -31,17 +31,44 @@ function makeSharedTable ()
-- Find the find_method method.
local HOW = Obj.STable.HOW;
local Meth = Obj.STable.CachedFindMethod;
if (Meth ~= nil) then
Meth = self.HOW.STable.FindMethod(
if (Meth == nil) then
Meth = self.HOW.STable:FindMethod(
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);
return Meth.STable:Invoke(TC, Meth, Cap);
end
end

function SharedTable:Invoke(TC, Obj, Cap)
if (self.SpecialInvoke ~= nil) then
return self.SpecialInvoke(TC, Obj, Cap);
end
local STable = Obj.STable;
if (STable.CachedInvoke == nil) then
STable.CachedInvoke = Obj.STable:FindMethod(TC, Obj, "postcircumfix:<( )>", Hints.NO_HINT);
end
STable.CachedInvoke.STable:Invoke(TC, Obj, Cap);
end

function SharedTable:TypeCheck(TC, Obj, Checkee)
if (self.TypeCheckCache ~= nil) then
for i = 1, self.TypeCheckCache.Count do
if (self.TypeCheckCache[i] == Checkee) then
return Ops.box_int(TC, 1, TC.DefaultBoolBoxType);
end
end
return Ops.box_int(TC, 0, TC.DefaultBoolBoxType);
else
local Checker = HOW.STable:FindMethod(TC, HOW, "type_check", Hints.NO_HINT);
local Cap = CaptureHelper.FormWith({ HOW, Obj, Checkee });
return Checker.STable:Invoke(TC, Checker, Cap);
end
end

return SharedTable;
end
SharedTable = makeSharedTable();
2 changes: 1 addition & 1 deletion lua/runtime/Runtime/Context.lua
Expand Up @@ -13,7 +13,7 @@ function makeContext ()

StaticCodeObject.CurrentContext = this;

this.LexPad = Lexpad.new();
this.LexPad = Lexpad.new({});
this.LexPad.SlotMapping = StaticCodeObject.StaticLexPad.SlotMapping;
this.LexPad.Storage = table_clone(StaticCodeObject.StaticLexPad.Storage);

Expand Down
6 changes: 3 additions & 3 deletions lua/runtime/Runtime/Exceptions/ExceptionDispatcher.lua
@@ -1,10 +1,10 @@
Exceptions = {};

function Exceptions.CallHandler(TC, Handler, ExceptionObject)
local Returned = Handler.STable.Invoke(TC, Handler, CaptureHelper.FormWith({ ExceptionObject }));
local Returned = Handler.STable:Invoke(TC, Handler, CaptureHelper.FormWith({ ExceptionObject }));

local ResumableMeth = Returned.STable:FindMethod(TC, Returned, "resumable", Hints.NO_HINT);
local Resumable = ResumableMeth.STable.Invoke(TC, ResumableMeth, CaptureHelper.FormWith({ Returned }));
local Resumable = ResumableMeth.STable:Invoke(TC, ResumableMeth, CaptureHelper.FormWith({ Returned }));
if (Ops.unbox_int(TC, Resumable) ~= 0) then
return Returned;
else
Expand All @@ -16,7 +16,7 @@ function Exceptions.DieFromUnhandledException(TC, Exception)
try {
function ()
local StrMeth = Exception.STable:FindMethod(TC, Exception, "Str", Hints.NO_HINT);
local Stringified = StrMeth.STable.Invoke(TC, StrMeth, CaptureHelper.FormWith({ Exception }));
local Stringified = StrMeth.STable:Invoke(TC, StrMeth, CaptureHelper.FormWith({ Exception }));
print(Ops.unbox_str(TC, Stringified));
end
}.except(){ -- catch GenericError (any error)
Expand Down
2 changes: 1 addition & 1 deletion lua/runtime/Runtime/Ops/Boxing.lua
Expand Up @@ -25,7 +25,7 @@ function Ops.box_num (TC, Value, To)
end


function Ops.box_num (TC, Value, To)
function Ops.box_str (TC, Value, To)
if To ~= nil then
local REPR = To.STable.REPR;
local Result = REPR:instance_of(TC, To);
Expand Down
2 changes: 1 addition & 1 deletion lua/runtime/Runtime/Ops/Dispatch.lua
Expand Up @@ -5,7 +5,7 @@ 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);
return Candidate.STable:Invoke(TC, Candidate, CurOuter.Capture);
end
CurOuter = CurOuter.Outer;
end
Expand Down
2 changes: 1 addition & 1 deletion lua/runtime/Runtime/Ops/Metamodel.lua
Expand Up @@ -48,7 +48,7 @@ function Ops.find_method_with_hint(TC, Object, Name, Hint)
end

function Ops.invoke(TC, Invokee, Capture)
return Invokee.STable.Invoke(TC, Invokee, Capture);
return Invokee.STable:Invoke(TC, Invokee, Capture);
end

function Ops.get_how(TC, Obj)
Expand Down
4 changes: 2 additions & 2 deletions lua/runtime/Runtime/Signatures/SignatureBinder.lua
Expand Up @@ -43,7 +43,7 @@ function makeSignatureBinder()
if (CurPositional <= Positionals.Count) then
C.LexPad.Storage[Param.VariableLexpadPosition] = Positionals[CurPositional];
else
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable.Invoke(TC, Param.DefaultValue, Capture);
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable:Invoke(TC, Param.DefaultValue, Capture);
end
elseif (band(Param.Flags, Parameter.NAMED_SLURPY_FLAG) ~= 0) then
local SlurpyHolder = TC.DefaultHashType.STable.REPR:instance_of(TC, TC.DefaultHashType);
Expand Down Expand Up @@ -75,7 +75,7 @@ function makeSignatureBinder()
if (band(Param.Flags, Parameter.OPTIONAL_FLAG) == 0) then
error("Required named parameter " .. Param.Name .. " missing");
else
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable.Invoke(TC, Param.DefaultValue, Capture);
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable:Invoke(TC, Param.DefaultValue, Capture);
end
end
else
Expand Down

0 comments on commit 630d886

Please sign in to comment.