Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language server package #3655

Draft
wants to merge 6 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion M2/Macaulay2/d/actors.d
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,30 @@ assignNewFromFun(newclass:Code,newinitializer:Code,rhs:Code):Expr := (
i := eval(newinitializer);
when i is Error do i
is ii:HashTable do installMethod(NewFromE,cc,ii,eval(rhs))
else printErrorMessageE(newinitializer,"expected a hash table"))
is a:Sequence do (
if length(a) == 2
then (
when a.0
is T1:HashTable do
when a.1
is T2:HashTable do (
installMethod(NewFromE, cc, T1, T2, eval(rhs)))
else WrongArgHashTable(2)
else WrongArgHashTable(1))
else if length(a) == 3
then (
when a.0
is T1:HashTable do
when a.1
is T2:HashTable do
when a.2
is T3:HashTable do (
installMethod(NewFromE, cc, T1, T2, T3, eval(rhs)))
else WrongArgHashTable(3)
else WrongArgHashTable(2)
else WrongArgHashTable(1))
else WrongNumArgs(1, 3))
else printErrorMessageE(newinitializer,"expected 1 to 3 hash tables"))
else printErrorMessageE(newclass,"expected a hash table as prospective class"));
AssignNewFromFun = assignNewFromFun;
setup(NewFromS,AssignNewFromFun);
Expand Down
29 changes: 28 additions & 1 deletion M2/Macaulay2/d/actors2.dd
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,34 @@ newfromfun(newClassCode:Code,newInitCode:Code):Expr := (
then newClass(applyEEE(method,Expr(classs),newInitExpr),classs,true)
else (
when newInitExpr
is s:Sequence do newClass(newInitExpr,classs,false)
is s:Sequence do (
if length(s) == 2
then (
method = lookupTernaryMethod(
classs,
Class(s.0),
Class(s.1),
NewFromE);
if method != nullE
then newClass(
applyEEEE(method, Expr(classs), s.0, s.1),
classs, true)
else newClass(newInitExpr, classs, false))
else if length(s) == 3
then (
method = lookupQuaternaryMethod(
classs,
Class(s.0),
Class(s.1),
Class(s.2),
NewFromE);
if method != nullE
then newClass(
applyES(method,
Sequence(Expr(classs), s.0, s.1, s.2)),
classs, true)
else newClass(newInitExpr, classs, false))
else newClass(newInitExpr,classs,false))
is p:List do (
if p.Class == classs
then Expr(if p.Mutable then copy(p) else p)
Expand Down
11 changes: 2 additions & 9 deletions M2/Macaulay2/m2/gb.m2
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,12 @@ GroebnerBasis.synonym = "Gröbner basis"
GroebnerBasisOptions = new Type of OptionTable
GroebnerBasisOptions.synonym = "Gröbner basis options"

-- m: a Matrix
-- type: an GroebnerBasisOptions
-- opts: an OptionTable
-- TODO: document this
new GroebnerBasis from Sequence := (GB, S) -> (
(m, type, opts) := if #S === 3 then S else error "GroebnerBasis: expected three initial values";
-- TODO: implement recursive type checking
if not instance(m, Matrix) or not instance(type, GroebnerBasisOptions) or not instance(opts, OptionTable)
then error "GroebnerBasis: expected a sequence of type (Matrix, GroebnerBasisOptions, OptionTable)";
new GroebnerBasis from (Matrix, GroebnerBasisOptions, OptionTable) := (GB, m, type, opts) -> (
if flagInhomogeneity and not isHomogeneous m then error "internal error: gb: inhomogeneous matrix flagged";
-- initialize the toplevel container
G := new GroebnerBasis;
if debugLevel > 5 then registerFinalizer(G, "gb (new GroebnerBasis from Sequence)");
if debugLevel > 5 then registerFinalizer(G, "gb (new GroebnerBasis from (Matrix, GroebnerBasisOptions, OptionTable))");
G.ring = ring m;
G.matrix = Bag {m};
G.target = target m;
Expand Down
21 changes: 9 additions & 12 deletions M2/Macaulay2/m2/modules.m2
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,15 @@ isHomogeneous Vector := (v) -> isHomogeneous v#0
Module = new Type of ImmutableType
Module.synonym = "module"
new Module from List := (Module,v) -> new Module of Vector from hashTable v
new Module from Sequence := (Module,x) -> (
(R,rM) -> (
assert instance(R,Ring);
assert instance(rM,RawFreeModule);
new Module of Vector from hashTable {
symbol cache => new CacheTable from {
cache => new MutableHashTable -- this hash table is mutable, hence has a hash number that can serve as its age
},
symbol RawFreeModule => rM,
symbol ring => R,
symbol numgens => rawRank rM
})) x
new Module from (Ring, RawFreeModule) := (Module, R, rM) -> (
new Module of Vector from hashTable {
symbol cache => new CacheTable from {
cache => new MutableHashTable -- this hash table is mutable, hence has a hash number that can serve as its age
},
symbol RawFreeModule => rM,
symbol ring => R,
symbol numgens => rawRank rM
})

vector(Module, Matrix) := (M, f) -> vector map(M,,entries f)
vector(Module, List) := (M, v) -> vector map(M,,apply(splice v, i -> {i}))
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/packages/=distributed-packages
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,4 @@ Permutations
SCMAlgebras
NumericalSemigroups
IncidenceCorrespondenceCohomology
JSONRPC
Loading
Loading