Skip to content

Commit

Permalink
lots of updates, a new compiler is about 50% done
Browse files Browse the repository at this point in the history
  • Loading branch information
efrederickson committed Nov 4, 2012
1 parent b3537af commit fbe8cf1
Show file tree
Hide file tree
Showing 47 changed files with 3,180 additions and 548 deletions.
15 changes: 13 additions & 2 deletions Example Projects/CSharpExampleProject/CSharpExampleProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
<AssemblyName>CSharpExampleProject</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,6 +34,14 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
1 change: 1 addition & 0 deletions Example Projects/TestModule/Class1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static void What()
}

[LuaFunction]
// Doesn't show up - not static
public int X()
{
return 9;
Expand Down
16 changes: 14 additions & 2 deletions Example Projects/TestModule/TestModule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
<AssemblyName>TestModule</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -29,6 +32,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
18 changes: 16 additions & 2 deletions GenerateDocumentation/GenerateDocumentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
<AssemblyName>GenerateDocumentation</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SourceAnalysisOverrideSettingsFile>C:\Users\elijah.FFHS2\AppData\Roaming\ICSharpCode/SharpDevelop4\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunSourceAnalysis>False</RunSourceAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,6 +36,14 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -48,6 +61,7 @@
<ProjectReference Include="..\SharpLua\SharpLua.csproj">
<Project>{90a9c907-11ad-4754-8b70-51ccb3a6c98a}</Project>
<Name>SharpLua</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
118 changes: 55 additions & 63 deletions Scripts/underscore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,79 +366,71 @@ m.head = m.first
m.take = m.first

m.initial = function(array, n, guard)
return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
return slice.call(array, 0, array.length - (((n == nil) or guard) and 1 or n))
end

-- Get the last element of an array. Passing **n** will return the last N
-- values in the array. The **guard** check allows it to work with `_.map`.
_.last = function(array, n, guard) {
if (array == null) return void 0;
if ((n != null) && !guard) {
return slice.call(array, Math.max(array.length - n, 0));
} else {
return array[array.length - 1];
}
};
m.last = function(array, n, guard)
if array == nil then
return nil
end
if (n ~= nil and not guard) then
return m.slice(array, math.max(#array - n, 0))
else
return array[#array - 1]
end
end

-- Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
-- Especially useful on the arguments object. Passing an **n** will return
-- the rest N values in the array. The **guard**
-- check allows it to work with `_.map`.
_.rest = _.tail = _.drop = function(array, n, guard) {
return slice.call(array, (n == null) || guard ? 1 : n);
};
m.rest = function(array, n, guard)
return m.slice(array, (n == nil or guard) and 1 or n)
end
m.tail = m.tail
m.drop = m.rest

-- Trim out all falsy values from an array.
_.compact = function(array) {
return _.filter(array, function(value){ return !!value; });
};
m.compact = function(array)
return m.filter(array, function(value) return not not value end)
end

-- Internal implementation of a recursive `flatten` function.
var flatten = function(input, shallow, output) {
each(input, function(value) {
if (_.isArray(value)) {
shallow ? push.apply(output, value) : flatten(value, shallow, output);
} else {
output.push(value);
}
});
return output;
};
m.flattenInternal = function(input, shallow, output)
m.each(input, function(value)
if m.isArray(value) then
if shallow then
m.push(output, value)
else
flatten(value, shallow, output)
end
else
m.push(output, value)
end
end)
return output
end

-- Return a completely flattened version of an array.
_.flatten = function(array, shallow) {
return flatten(array, shallow, []);
};
m.flatten = function(array, shallow)
return m.flattenInternal(array, shallow, { })
end

-- Return a version of the array that does not contain the specified value(s).
_.without = function(array) {
return _.difference(array, slice.call(arguments, 1));
};
m.without = function(array)
return m.difference(array, m.slice(arguments, 1))
end

-- Produce a duplicate-free version of the array. If the array has already
-- been sorted, you have the option of using a faster algorithm.
-- Aliased as `unique`.
_.uniq = _.unique = function(array, isSorted, iterator, context) {
var initial = iterator ? _.map(array, iterator, context) : array;
var results = [];
var seen = [];
each(initial, function(value, index) {
if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) {
seen.push(value);
results.push(array[index]);
}
});
return results;
};
m.unique = function(array, isSorted, iterator)
local initial = iterator and m.map(array, iterator) or array
local results = { }
local seen = { }
m.each(initial, function(value, index)
if (isSorted and not index or seen[#seen - 1]) ~= value or not m.contains(seen, value) then
m.push(seen, value);
m.push(results, array[index])
end
end)
return results
end
m.uniq = m.unique

-- Produce an array that contains the union: each distinct element from all of
-- the passed-in arrays.
_.union = function() {
return _.uniq(concat.apply(ArrayProto, arguments));
};
m.union = function(...)
return m.uniq(concat.apply(ArrayProto, ...))
end

-- Produce an array that contains every item shared between all the
-- passed-in arrays.
_.intersection = function(array) {
var rest = slice.call(arguments, 1);
return _.filter(_.uniq(array), function(item) {
Expand Down
4 changes: 2 additions & 2 deletions SharpLua.AlmostADebugger/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
lasm = luanet.namespace"SharpLua.LASM"
dis = lasm.Disassembler
assert(dis, "Could not load LASM Disassembler!")
--print(lasm, lasm.Disassembler)
func = nil

local func = nil
function Load(s)
local a = loadstring(s)
func = a
Expand Down
18 changes: 14 additions & 4 deletions SharpLua.AlmostADebugger/SharpLua.AlmostADebugger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
<AssemblyName>SharpLua.AlmostADebugger</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,8 +34,13 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -84,10 +92,12 @@
<ProjectReference Include="..\SharpLua.LASM\SharpLua.LASM.csproj">
<Project>{150ced9a-888b-4783-8aca-57599a3a43ef}</Project>
<Name>SharpLua.LASM</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\SharpLua\SharpLua.csproj">
<Project>{90a9c907-11ad-4754-8b70-51ccb3a6c98a}</Project>
<Name>SharpLua</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
17 changes: 12 additions & 5 deletions SharpLua.Compiler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ static int doargs(int argc, string[] argv)
if (version != 0)
{
Lua.printf("%s %s\n", Lua.LUA_RELEASE, Lua.LUA_COPYRIGHT);
if (version == argc - 1) Environment.Exit(Lua.EXIT_SUCCESS);
if (version == argc - 1)
Environment.Exit(Lua.EXIT_SUCCESS);
}
return i;
}
Expand Down Expand Up @@ -179,11 +180,15 @@ static int pmain(Lua.LuaState L)
string[] argv = s.argv;
Lua.Proto f;
int i;
if (Lua.lua_checkstack(L, argc) == 0) fatal("too many input files");
if (Lua.lua_checkstack(L, argc) == 0)
fatal("too many input files");
for (i = 0; i < argc; i++)
{
Lua.CharPtr filename = (Lua.strcmp(argv[i], "-") == 0) ? null : argv[i];
if (Lua.luaL_loadfile(L, filename) != 0) fatal(Lua.lua_tostring(L, -1));
if (Lua.luaL_loadfile(L, filename) != 0)
{
fatal(Lua.lua_tostring(L, -1));
}
}
f = combine(L, argc);
if (listing != 0) Lua.luaU_print(f, (listing > 1) ? 1 : 0);
Expand Down Expand Up @@ -217,10 +222,12 @@ static int Main(string[] args)
argc -= i; args = (string[])newargs.ToArray();
if (argc <= 0) usage("no input files given");
L = Lua.lua_open();
if (L == null) fatal("not enough memory for state");
if (L == null)
fatal("not enough memory for state");
s.argc = argc;
s.argv = args;
if (Lua.lua_cpcall(L, pmain, s) != 0) fatal(Lua.lua_tostring(L, -1));
if (Lua.lua_cpcall(L, pmain, s) != 0)
fatal(Lua.lua_tostring(L, -1));
Lua.lua_close(L);
return Lua.EXIT_SUCCESS;
}
Expand Down
16 changes: 14 additions & 2 deletions SharpLua.Compiler/SharpLua.Compiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
<AssemblyName>sluac</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -31,6 +34,14 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -43,6 +54,7 @@
<ProjectReference Include="..\SharpLua\SharpLua.csproj">
<Project>{90a9c907-11ad-4754-8b70-51ccb3a6c98a}</Project>
<Name>SharpLua</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Loading

0 comments on commit fbe8cf1

Please sign in to comment.