Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:diakopter/6model
  • Loading branch information
diakopter committed Nov 8, 2011
2 parents a8c8822 + 3c55146 commit 862ce02
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 40 deletions.
1 change: 1 addition & 0 deletions lua/compiler/IndexersReplacements.txt
Expand Up @@ -9,6 +9,7 @@
%.CachedInvoke [9] # on SharedTable
%.TypeCheckCache [10] # on SharedTable
%.new%( [1]( # all classes with constructors named new
%.CurrentContext [0] # dual purpose (ThreadContext and RakudoCodeRef instance)
Ops%.box_int%( Ops[1](
Ops%.box_num%( Ops[2](
Ops%.box_str%( Ops[3](
Expand Down
20 changes: 10 additions & 10 deletions lua/compiler/PAST2LSTCompiler.pm
Expand Up @@ -122,7 +122,7 @@ method compile(PAST::Node $node) {
$loadinit_calls,
LST::Call.new( :name('constants_init'), :void(1), TC() ),
$main_block_call,
"TC.CurrentContext"
"TC[0]"
));
}
else {
Expand Down Expand Up @@ -210,7 +210,7 @@ sub make_blocks_init_method($name) {
)
),
LST::Bind.new(
'StaticBlockInfo[0].CurrentContext',
'StaticBlockInfo[0][0]',
'TC.Domain.Setting'
),

Expand Down Expand Up @@ -241,7 +241,7 @@ sub make_constants_init_method($name) {
'StaticBlockInfo[1]',
LST::ArrayLiteral.new( :type('string') )
),
'TC.CurrentContext',
'TC[0]',
LST::Null.new()
)
),
Expand Down Expand Up @@ -362,7 +362,7 @@ our multi sub lst_for(PAST::Block $block) {
%handler<code> := lst_for(PAST::Block.new(PAST::Stmts.new(
PAST::Var.new( :name('$!'), :scope('parameter') ),
emit_op('leave_block',
LST::Literal.new( :value('TC.CurrentContext.Outer.StaticCodeObject') ),
LST::Literal.new( :value('TC[0].Outer.StaticCodeObject') ),
lst_for(PAST::Var.new( :name('$!'), :scope('lexical') ))
)
)));
Expand Down Expand Up @@ -395,17 +395,17 @@ our multi sub lst_for(PAST::Block $block) {
"StaticBlockInfo[$our_sbi]",
LST::ArrayLiteral.new( :type('string') ),
),
'TC.CurrentContext',
'TC[0]',
LST::Null.new()
)
),
LST::Bind.new( 'TC.CurrentContext', loc('C', 'Context') ),
LST::Bind.new( 'TC[0]', loc('C', 'Context') ),
LST::Bind.new(
"StaticBlockInfo[$our_sbi].Sig",
compile_signature(@*PARAMS)
),
$handlers_setup_placeholder,
LST::Bind.new( 'TC.CurrentContext', 'C.Caller' )
LST::Bind.new( 'TC[0]', 'C.Caller' )
));
@*SIGINITS.push(LST::Call.new( :name($sig_setup_block), :void(1), TC() ));

Expand All @@ -418,9 +418,9 @@ our multi sub lst_for(PAST::Block $block) {
# Wrap in block prelude/postlude.
$result.push(LST::Local.new(
:name('local C'), :isdecl(1), :type('Context'),
LST::New.new( :type('Context'), "Block", "TC.CurrentContext", loc("Capture") )
LST::New.new( :type('Context'), "Block", "TC[0]", loc("Capture") )
));
$result.push(LST::Bind.new( 'TC.CurrentContext', loc('C', 'Context') ));
$result.push(LST::Bind.new( 'TC[0]', loc('C', 'Context') ));
$result.push(LST::TryFinally.new(
LST::TryCatch.new(
:exception_type('LeaveStackUnwinderException'),
Expand All @@ -437,7 +437,7 @@ our multi sub lst_for(PAST::Block $block) {
"exc.PayLoad"
)
),
LST::Bind.new( 'TC.CurrentContext', 'C.Caller' )
LST::Bind.new( 'TC[0]', 'C.Caller' )
));

# Add nested inner blocks after it (.Net does not support
Expand Down
4 changes: 4 additions & 0 deletions lua/runtime/List.lua
Expand Up @@ -6,6 +6,10 @@ function makeList ()
list.Count = count ~= nil and count or 0;
return setmetatable(list, mt);
end
function List.createFrom (list)
list.Count = #list;
return setmetatable(list, mt);
end
function List:Clone ()
local list = List.create(self.Count);
for i = 1, self.Count do
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/KnowHOW/KnowHOWREPR.lua
Expand Up @@ -9,7 +9,8 @@ function makeKnowHOWREPR ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
4 changes: 3 additions & 1 deletion lua/runtime/Metamodel/Representations/P6capture.lua
Expand Up @@ -7,9 +7,11 @@ function makeP6capture ()
local Instance = { ["class"] = "P6capture"};
local mt = { __index = Instance };
function Instance.new (STable)
--return { ["STable"] = STable };
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6hash.lua
Expand Up @@ -10,7 +10,8 @@ function makeP6hash ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6int.lua
Expand Up @@ -12,7 +12,8 @@ function makeP6int ()
this.STable = STable;
this.Undefined = false;
this.Value = 0;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6list.lua
Expand Up @@ -9,7 +9,8 @@ function makeP6list ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6mapping.lua
Expand Up @@ -9,7 +9,8 @@ function makeP6mapping ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6num.lua
Expand Up @@ -11,7 +11,8 @@ function makeP6num ()
this.STable = STable;
this.Undefined = false;
this.Value = 0.0;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6opaque.lua
Expand Up @@ -9,7 +9,8 @@ function makeP6opaque ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
3 changes: 2 additions & 1 deletion lua/runtime/Metamodel/Representations/P6str.lua
Expand Up @@ -9,7 +9,8 @@ function makeP6str ()
function Instance.new (STable)
local this = {};
this.STable = STable;
return setmetatable(this, mt);
return this;
--return setmetatable(this, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
7 changes: 4 additions & 3 deletions lua/runtime/Metamodel/Representations/RakudoCodeRef.lua
Expand Up @@ -7,9 +7,10 @@ function makeRakudoCodeRef ()
local Instance = { ["class"] = "RakudoCodeRef" };
local mt = { __index = Instance };
function Instance.new (STable)
local instance = {};
instance.STable = STable;
return setmetatable(instance, mt);
local this = {};
this.STable = STable;
return this;
--return setmetatable(instance, mt);
end
Instance[1] = Instance.new;
return Instance;
Expand Down
9 changes: 3 additions & 6 deletions lua/runtime/Runtime/CaptureHelper.lua
Expand Up @@ -7,13 +7,10 @@ function CaptureHelper.FormWith (PosArgs, NamedArgs, FlattenSpec)
local REPR = CaptureHelper.CaptureTypeObject.STable.REPR;
local C = REPR.instance_of(REPR, nil, CaptureHelper.CaptureTypeObject);
if PosArgs ~= nil then
C.Positionals = List.create();
for k,v in ipairs(PosArgs) do
List.Add(C.Positionals, v);
end
C.Positionals = List.createFrom(PosArgs);
end;
if NamedArgs ~= nil then C.Nameds = NamedArgs end;
if FlattenSpec ~= nil then C.FlattenSpec = FlattenSpec; end;
C.Nameds = NamedArgs;
C.FlattenSpec = FlattenSpec;
return C;
end
CaptureHelper[1] = CaptureHelper.FormWith;
Expand Down
24 changes: 12 additions & 12 deletions lua/runtime/Runtime/Ops/P6mapping.lua
@@ -1,31 +1,31 @@
function Ops.llmapping_get_at_key(TC, LLMapping, Key)
if (LLMapping.class == "P6mapping") then
--if (LLMapping.class == "P6mapping") then
local Storage = LLMapping.Storage;
local StrKey = Ops.unbox_str(TC, Key);
return Storage[StrKey];
else
error("Cannot use llmapping_get_at_key if representation is not P6mapping");
end
--else
-- error("Cannot use llmapping_get_at_key if representation is not P6mapping");
--end
end
Ops[70] = Ops.llmapping_get_at_key;

function Ops.llmapping_bind_at_key(TC, LLMapping, Key, Value)
if (LLMapping.class == "P6mapping") then
--if (LLMapping.class == "P6mapping") then
local Storage = LLMapping.Storage;
local StrKey = Ops.unbox_str(TC, Key);
Storage[StrKey] = Value;
return Value;
else
error("Cannot use llmapping_bind_at_key if representation is not P6mapping");
end
--else
-- error("Cannot use llmapping_bind_at_key if representation is not P6mapping");
--end
end
Ops[71] = Ops.llmapping_bind_at_key;

function Ops.llmapping_elems(TC, LLMapping)
if (LLMapping.class == "P6mapping") then
--if (LLMapping.class == "P6mapping") then
return Ops.box_int(TC, LLMapping.Storage.Count, TC.DefaultIntBoxType);
else
error("Cannot use llmapping_elems if representation is not P6mapping");
end
--else
-- error("Cannot use llmapping_elems if representation is not P6mapping");
--end
end
Ops[72] = Ops.llmapping_elems;

0 comments on commit 862ce02

Please sign in to comment.