Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
more bugfixes
  • Loading branch information
diakopter committed Nov 2, 2011
1 parent 5c50076 commit a5cabb9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lua/compiler/Makefile
Expand Up @@ -6,7 +6,7 @@ RM_RF = perl -MExtUtils::Command -e rm_f
RT_SRC = ../runtime/*.lua ../runtime/Metamodel/*.lua ../runtime/Metamodel/KnowHOW/*.lua ../runtime/Metamodel/Representations/*.lua ../runtime/Runtime/*.lua ../runtime/Runtime/Exceptions/*.lua ../runtime/Runtime/MultiDispatch/*.lua ../runtime/Runtime/Ops/*.lua ../runtime/Runtime/Signatures/*.lua
LUA = luajit

all: P6Objects.lbc
all: RakudoRuntime.lbc NQPSetting.lbc P6Objects.lbc

gen_actions.pir: Actions.pm
parrot-nqp --target=pir Actions.pm > gen_actions.pir
Expand All @@ -32,13 +32,13 @@ RakudoRuntime.lua: $(RT_SRC)
RakudoRuntime.lbc: RakudoRuntime.lua
luajit -b RakudoRuntime.lua RakudoRuntime.lbc

NQPSetting.lua: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_lst.pir gen_past2lst.pir gen_lst2lua.pir ../../common/NQP/NQPSetting.pm RakudoRuntime.lbc
NQPSetting.lua: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_lst.pir gen_past2lst.pir gen_lst2lua.pir ../../common/NQP/NQPSetting.pm
parrot compile.pir ../../common/NQP/NQPSetting.pm --setting > NQPSetting.lua

NQPSetting.lbc: NQPSetting.lua
luajit -b NQPSetting.lua NQPSetting.lbc

P6Objects.lua: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_lst.pir gen_past2lst.pir gen_lst2lua.pir ../../common/NQP/P6Objects.pm NQPSetting.lbc
P6Objects.lua: compile.pir gen_actions.pir gen_grammar.pir gen_nqpoptimizer.pir gen_lst.pir gen_past2lst.pir gen_lst2lua.pir ../../common/NQP/P6Objects.pm
parrot compile.pir ../../common/NQP/P6Objects.pm --no-core-libs > P6Objects.lua

P6Objects.lbc: P6Objects.lua
Expand Down
2 changes: 1 addition & 1 deletion lua/compiler/PAST2LSTCompiler.pm
Expand Up @@ -526,7 +526,7 @@ sub compile_signature(@params) {

# Flags.
$param.push(
$_.viviself && $_.named ?? 'bor(Parameter.OPTIONAL_FLAG, Parameter.NAMED_FLAG)' !!
$_.viviself && $_.named ?? 'bit.bor(Parameter.OPTIONAL_FLAG, Parameter.NAMED_FLAG)' !!
$_.viviself ?? 'Parameter.OPTIONAL_FLAG' !!
$_.slurpy && $_.named ?? 'Parameter.NAMED_SLURPY_FLAG' !!
$_.slurpy ?? 'Parameter.POS_SLURPY_FLAG' !!
Expand Down
2 changes: 1 addition & 1 deletion lua/runtime/Init.lua
Expand Up @@ -124,7 +124,7 @@ function makeInit ()
end
return CaptureHelper.Nil();
end));
SettingContext.LexPad.SetByName("say",
SettingContext.LexPad:SetByName("say",
CodeObjectUtility.WrapNativeMethod(function (TC, self, C)
for i = 1, CaptureHelper.NumPositionals(C) do
local Value = CaptureHelper.GetPositional(C, i);
Expand Down
4 changes: 2 additions & 2 deletions lua/runtime/Metamodel/KnowHOW/KnowHOWBootstrapper.lua
Expand Up @@ -111,13 +111,13 @@ function KnowHOWBootstrapper.SetupKnowHOWAttribute (KnowHOW)

HOW.Methods.new = CodeObjectUtility.WrapNativeMethod(
function (TC, Code, Cap)
local WHAT = CaptureHelper.GetPositional(Cap, 2).STable.WHAT;
local WHAT = CaptureHelper.GetPositional(Cap, 1).STable.WHAT;
local Name = Ops.unbox_str(TC, CaptureHelper.GetNamed(Cap, "name"));
return Ops.box_str(TC, Name, WHAT);
end);
HOW.Methods.name = CodeObjectUtility.WrapNativeMethod(
function (TC, Code, Cap)
local self = CaptureHelper.GetPositional(Cap, 2);
local self = CaptureHelper.GetPositional(Cap, 1);
return Ops.box_str(TC, Ops.unbox_str(TC, self), TC.DefaultStrBoxType);
end);

Expand Down
7 changes: 6 additions & 1 deletion lua/runtime/Runtime/CaptureHelper.lua
Expand Up @@ -5,7 +5,12 @@ CaptureHelper.FLATTEN_NAMED = 2;

function CaptureHelper.FormWith (PosArgs, NamedArgs, FlattenSpec)
local C = CaptureHelper.CaptureTypeObject.STable.REPR:instance_of(nil, CaptureHelper.CaptureTypeObject);
if PosArgs ~= nil then C.Positionals = PosArgs end;
if PosArgs ~= nil then
C.Positionals = List.new();
for k,v in ipairs(PosArgs) do
C.Positionals:Add(v);
end
end;
if NamedArgs ~= nil then C.Nameds = NamedArgs end;
if FlattenSpec ~= nil then C.FlattenSpec = FlattenSpec; end;
return C;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Runtime/Lexpad.lua
Expand Up @@ -24,8 +24,9 @@ function makeLexpad ()
SlotMapping[k] = v;
end
for k,v in ipairs(Names) do
SlotMapping[Name] = NewSlot + k - 1;
SlotMapping[v] = self.SlotCount + k - 1;
end
self.SlotMapping = SlotMapping;
local new = self.SlotCount + #Names;
local NewStorage = List.new(new);
for i = 1, self.SlotCount do
Expand Down
4 changes: 2 additions & 2 deletions lua/runtime/Runtime/Ops/Primitive.lua
Expand Up @@ -39,11 +39,11 @@ function Ops.div_num(TC, x, y)
end

function Ops.bitwise_or_int(TC, x, y)
return Ops.box_int(TC, bor(Ops.unbox_int(TC, x), Ops.unbox_int(TC, y)), TC.DefaultIntBoxType);
return Ops.box_int(TC, bit.bor(Ops.unbox_int(TC, x), Ops.unbox_int(TC, y)), TC.DefaultIntBoxType);
end

function Ops.bitwise_and_int(TC, x, y)
return Ops.box_int(TC, band(Ops.unbox_int(TC, x), Ops.unbox_int(TC, y)), TC.DefaultIntBoxType);
return Ops.box_int(TC, bit.band(Ops.unbox_int(TC, x), Ops.unbox_int(TC, y)), TC.DefaultIntBoxType);
end

-- skip num bitwise
Expand Down
11 changes: 7 additions & 4 deletions lua/runtime/Runtime/Signatures/Signature.lua
Expand Up @@ -3,18 +3,21 @@ function makeSignature ()
local mt = { __index = Signature };
function Signature.new(Parameters)
local this = {};
this.Parameters = Parameters;
this.Parameters = List.new();
for k,v in ipairs(Parameters) do
this.Parameters:Add(v);
end
this.NumRequiredPositionals = 0;
this.NumPositionals = 0;

for i = 1, Parameters.Count do
if (Parameters[i].Flags == Parameter.POS_FLAG) then
for i = 1, this.Parameters.Count do
if (this.Parameters[i].Flags == Parameter.POS_FLAG) then
this.NumRequiredPositionals = this.NumRequiredPositionals + 1;
this.NumPositionals = this.NumPositionals + 1;
elseif (Parameters[i].Flags == Parameter.OPTIONAL_FLAG) then
this.NumPositionals = this.NumPositionals + 1;
else
i = Parameters.Count + 1; -- fake break
i = this.Parameters.Count + 1; -- fake break
end
end
return setmetatable(this, mt);
Expand Down
6 changes: 3 additions & 3 deletions lua/runtime/Runtime/Signatures/SignatureBinder.lua
Expand Up @@ -45,7 +45,7 @@ function makeSignatureBinder()
else
C.LexPad.Storage[Param.VariableLexpadPosition] = Param.DefaultValue.STable:Invoke(TC, Param.DefaultValue, Capture);
end
elseif (band(Param.Flags, Parameter.NAMED_SLURPY_FLAG) ~= 0) then
elseif (bit.band(Param.Flags, Parameter.NAMED_SLURPY_FLAG) ~= 0) then
local SlurpyHolder = TC.DefaultHashType.STable.REPR:instance_of(TC, TC.DefaultHashType);
C.LexPad.Storage[Param.VariableLexpadPosition] = SlurpyHolder;
for Name, unused in pairs(Nameds) do
Expand All @@ -55,7 +55,7 @@ function makeSignatureBinder()
Nameds[Name]);
end
end
elseif (band(Param.Flags, Parameter.POS_SLURPY_FLAG) ~= 0) then
elseif (bit.band(Param.Flags, Parameter.POS_SLURPY_FLAG) ~= 0) then
local SlurpyHolder = TC.DefaultArrayType.STable.REPR:instance_of(TC, TC.DefaultArrayType);
C.LexPad.Storage[Param.VariableLexpadPosition] = SlurpyHolder;
-- pretty sure this might be off-by-one. ;)
Expand All @@ -72,7 +72,7 @@ function makeSignatureBinder()
end
SeenNames[Param.Name] = true;
else
if (band(Param.Flags, Parameter.OPTIONAL_FLAG) == 0) then
if (bit.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);
Expand Down

0 comments on commit a5cabb9

Please sign in to comment.