-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b0303f
commit 22a5d23
Showing
103 changed files
with
1,243 additions
and
1,031 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
 | ||
<Assembly Path="C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll" />
 | ||
</AssemblyExplorer></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"runtimeTarget": { | ||
"name": ".NETCoreApp,Version=v6.0", | ||
"signature": "" | ||
}, | ||
"compilationOptions": {}, | ||
"targets": { | ||
".NETCoreApp,Version=v6.0": { | ||
"JuliadotNET/1.0.0": { | ||
"dependencies": { | ||
"Lokad.ILPack": "0.1.7" | ||
}, | ||
"runtime": { | ||
"JuliadotNET.dll": {} | ||
} | ||
}, | ||
"Lokad.ILPack/0.1.7": { | ||
"runtime": { | ||
"lib/netcoreapp2.1/Lokad.ILPack.dll": { | ||
"assemblyVersion": "0.1.7.0", | ||
"fileVersion": "0.1.7.0" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"libraries": { | ||
"JuliadotNET/1.0.0": { | ||
"type": "project", | ||
"serviceable": false, | ||
"sha512": "" | ||
}, | ||
"Lokad.ILPack/0.1.7": { | ||
"type": "package", | ||
"serviceable": true, | ||
"sha512": "sha512-0tNM0zh0zJcjHUt/PHqgeML7OoWof0tiltGLcX2zur8Kjildye01X/RDwTt4Fxru5uIGXQvGHWqkWicvHmpcaQ==", | ||
"path": "lokad.ilpack/0.1.7", | ||
"hashPath": "lokad.ilpack.0.1.7.nupkg.sha512" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Base; | ||
|
||
namespace JULIAdotNET{ | ||
public static partial class JPrimitive { | ||
public static Any BaseM, CoreM, MainM; | ||
public static JType ModuleT, TypeT, FunctionT, MethodT, UnionT; | ||
public static Any sprintF, showerrorF, catch_backtraceF, stringF, getpropertyF, setpropertyNotF, namesF, makearrayF, writeSharpArrayF, maketupleF, ievalF, getindexF, setindexNotF, lengthF, iterateF, EqualityF, InequalityF, GreaterThanF, LessThanF, GreaterThanOrEqualF, LessThanOrEqualF, NotF, OnesComplementF, ExclusiveOrF, BitwiseAndF, BitwiseOrF, ModulusF, MultiplyF, AdditionF, SubtractionF, DivisionF, RightShiftF, LeftShiftF, typeofF, hashF, ismutableF, isabstracttypeF, isimmutableF, isprimitivetypeF, sizeofF, parentmoduleF, nameofF, fieldcountF, fieldnameF, fieldoffsetF, fieldtypeF; | ||
|
||
internal static unsafe void primitive_init() { | ||
|
||
Julia.Eval(@"module SharpModule begin | ||
export makearray, maketuple, writeSharpArray, maketuple, ieval | ||
function method_argnames(m::Method) | ||
argnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), m.slot_syms) | ||
isempty(argnames) && return argnames | ||
return [string(sym) for sym = (argnames[1:m.nargs])[2:end]] | ||
end | ||
ieval(mod::Module, ex) = begin | ||
Core.eval(mod, Meta.parse(ex)) | ||
end | ||
makearray(T::Type, dims::Ptr{Cvoid}, len::Int32) = begin | ||
ptr = convert(Ptr{Int32}, dims) | ||
Array{T}(undef, [unsafe_load(ptr, i) for i = 1:len]...) | ||
end | ||
maketuple(vals...) = begin | ||
tuple(vals...) | ||
end | ||
linedEvaluation(s::String, file::String, m::Module) = begin | ||
Core.eval(m, Meta.parseall(s, filename = file)) | ||
end | ||
function writeSharpArray(p, arr) | ||
ptr = convert(Ptr{Any}, p) | ||
for i = eachindex(arr) | ||
unsafe_store!(ptr, arr[i], i) | ||
end | ||
end | ||
end end; using .SharpModule"); | ||
|
||
var writeSharpArray = Julia.Eval("writeSharpArray"); | ||
fixed (Any* values = new Any[54]) { | ||
var syms = Julia.Eval("[Base,Core,Main,sprint,showerror,catch_backtrace,string,getproperty,setproperty!,names,makearray,writeSharpArray,maketuple,ieval,getindex,setindex!,length,iterate,Module,Type,Function,Method,Union,==,!=,>,<,>=,<=,!,~,^,&,|,rem,*,+,-,/,>>,<<,typeof,hash,ismutable,isabstracttype,isimmutable,isprimitivetype,sizeof,parentmodule,nameof,fieldcount,fieldname,fieldoffset,fieldtype]"); | ||
writeSharpArray.Invoke(new Any(values), syms); | ||
|
||
BaseM = values[0]; | ||
CoreM = values[1]; | ||
MainM = values[2]; | ||
ModuleT = values[18]; | ||
TypeT = values[19]; | ||
FunctionT = values[20]; | ||
MethodT = values[21]; | ||
UnionT = values[22]; | ||
sprintF = values[3]; | ||
showerrorF = values[4]; | ||
catch_backtraceF = values[5]; | ||
stringF = values[6]; | ||
getpropertyF = values[7]; | ||
setpropertyNotF = values[8]; | ||
namesF = values[9]; | ||
makearrayF = values[10]; | ||
writeSharpArrayF = values[11]; | ||
maketupleF = values[12]; | ||
ievalF = values[13]; | ||
getindexF = values[14]; | ||
setindexNotF = values[15]; | ||
lengthF = values[16]; | ||
iterateF = values[17]; | ||
EqualityF = values[23]; | ||
InequalityF = values[24]; | ||
GreaterThanF = values[25]; | ||
LessThanF = values[26]; | ||
GreaterThanOrEqualF = values[27]; | ||
LessThanOrEqualF = values[28]; | ||
NotF = values[29]; | ||
OnesComplementF = values[30]; | ||
ExclusiveOrF = values[31]; | ||
BitwiseAndF = values[32]; | ||
BitwiseOrF = values[33]; | ||
ModulusF = values[34]; | ||
MultiplyF = values[35]; | ||
AdditionF = values[36]; | ||
SubtractionF = values[37]; | ||
DivisionF = values[38]; | ||
RightShiftF = values[39]; | ||
LeftShiftF = values[40]; | ||
typeofF = values[41]; | ||
hashF = values[42]; | ||
ismutableF = values[43]; | ||
isabstracttypeF = values[44]; | ||
isimmutableF = values[45]; | ||
isprimitivetypeF = values[46]; | ||
sizeofF = values[47]; | ||
parentmoduleF = values[48]; | ||
nameofF = values[49]; | ||
fieldcountF = values[50]; | ||
fieldnameF = values[51]; | ||
fieldoffsetF = values[52]; | ||
fieldtypeF = values[53]; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
julia generators/Generator.jl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include("csharp/Core/JPrimitive.jl") | ||
|
||
project_root = pwd() | ||
|
||
generate_primitives(project_root, "$project_root/src/csharp/Core", "$project_root/generated/csharp/Core") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#Used for Parser Validation | ||
SharpModule = quote | ||
export makearray, maketuple, writeSharpArray, maketuple, ieval | ||
|
||
function method_argnames(m::Method) | ||
argnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), m.slot_syms) | ||
isempty(argnames) && return argnames | ||
return [string(sym) for sym in argnames[1:m.nargs][2:end]] | ||
end | ||
|
||
ieval(mod::Module, ex) = Core.eval(mod, Meta.parse(ex)) | ||
makearray(T::Type, dims::Ptr{Cvoid}, len::Int32) = (ptr = convert(Ptr{Int32}, dims); Array{T}(undef, [unsafe_load(ptr, i) for i in 1:len]...)) | ||
maketuple(vals...) = tuple(vals...) | ||
linedEvaluation(s::String, file::String, m::Module) = Core.eval(m, Meta.parseall(s, filename=file)) | ||
function writeSharpArray(p, arr) | ||
ptr = convert(Ptr{Any}, p) | ||
for i in eachindex(arr) | ||
unsafe_store!(ptr, arr[i], i) | ||
end | ||
end | ||
end | ||
|
||
eval(SharpModule) | ||
|
||
symbols = [Base, Core, Main, | ||
sprint, showerror, catch_backtrace, string, | ||
getproperty, setproperty!, names, | ||
makearray, writeSharpArray, maketuple, ieval, | ||
getindex, setindex!, length, iterate, | ||
Module, Type, Function, Method, Union, | ||
==, !=, >, <, >=, <=, !, ~, ^, &, |, %, *, +, -, /, >>, <<, | ||
typeof, hash, | ||
ismutable, isabstracttype, isimmutable, isprimitivetype, sizeof, parentmodule, nameof, | ||
fieldcount, fieldname, fieldoffset, fieldtype] | ||
|
||
function generate_primitives(project_root, src_root, gen_root) | ||
|
||
function write_expression(x) | ||
buffer = IOBuffer() | ||
Base.show_unquoted(buffer, Base.remove_linenums!(x)) | ||
return String(take!(buffer)) | ||
end | ||
|
||
function fix_name(f) | ||
f = replace(string(f), | ||
"+" => "Addition", | ||
"-" => "Subtraction", | ||
"*" => "Multiply", | ||
"/" => "Division", | ||
"%" => "Modulus", | ||
"rem" => "Modulus", | ||
"^" => "ExclusiveOr", | ||
"&" => "BitwiseAnd", | ||
"|" => "BitwiseOr", | ||
"<<" => "LeftShift", | ||
">>" => "RightShift", | ||
"==" => "Equality", | ||
">=" => "GreaterThanOrEqual", | ||
"<=" => "LessThanOrEqual", | ||
">" => "GreaterThan", | ||
"<" => "LessThan", | ||
"!=" => "Inequality", | ||
"--" => "Decrement", | ||
"++" => "Increment", | ||
"~" => "OnesComplement", | ||
"!" => "Not") | ||
f = replace(f, "!" => "") | ||
return f | ||
end | ||
|
||
count = 0 | ||
modules = [] | ||
functions = [] | ||
types = [] | ||
|
||
for s in symbols | ||
if s isa Module | ||
push!(modules, (s, count)) | ||
elseif s isa Function | ||
push!(functions, (s, count)) | ||
elseif s isa Type | ||
push!(types, (s, count)) | ||
end | ||
count += 1 | ||
end | ||
|
||
open("$gen_root/JPrimitive.gen.cs", "w") do io | ||
write(io, """using System; | ||
using System.Collections.Generic; | ||
using Base; | ||
namespace JULIAdotNET{ | ||
public static partial class JPrimitive { | ||
public static Any $(join(["$(m[1])M" for m in modules], ", ")); | ||
public static JType $(join(["$(t[1])T" for t in types], ", ")); | ||
public static Any $(join(["$(fix_name(f[1]))F" for f in functions], ", ")); | ||
internal static unsafe void primitive_init() { | ||
Julia.Eval(@"module SharpModule $(write_expression(SharpModule)) end; using .SharpModule"); | ||
var writeSharpArray = Julia.Eval(\"writeSharpArray\"); | ||
fixed (Any* values = new Any[$count]) { | ||
var syms = Julia.Eval(\"[$(join(symbols, ","))]\"); | ||
writeSharpArray.Invoke(new Any(values), syms); | ||
$(join(["$(m[1])M = values[$(m[2])];" for m in modules], "\n\t\t\t\t")) | ||
$(join(["$(t[1])T = values[$(t[2])];" for t in types], "\n\t\t\t\t")) | ||
$(join(["$(fix_name(f[1]))F = values[$(f[2])];" for f in functions], "\n\t\t\t\t")) | ||
} | ||
} | ||
} | ||
}""") | ||
|
||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
JuliadotNET/obj/Debug/net5.0/JuliadotNET.csproj.CoreCompileInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
b4696e5d14df4e6ff0d7fc4e121aef589b44613c | ||
2cfa2cfe14f642b688e1d6081380e6c3d799f222 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
JuliadotNET/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("Johnathan Bizzano")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("JuliadotNET")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("JuliadotNET")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyMetadataAttribute("RepositoryUrl", "https://github.com/HyperSphereStudio/JULIAdotNET")] | ||
|
||
// Generated by the MSBuild WriteCodeFragment class. | ||
|
Oops, something went wrong.