-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from metaindu/evaluator-12-compile
Evaluator 12: IlExpression
- Loading branch information
Showing
56 changed files
with
3,355 additions
and
1 deletion.
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,46 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class AddIlExpression : IlExpression | ||
{ | ||
public AddIlExpression(IlExpression left, IlExpression right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} | ||
|
||
public IlExpression Left { get; } | ||
public IlExpression Right { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Left.GetInstructions(instructions); | ||
Right.GetInstructions(instructions); | ||
instructions.Add(Instruction.Add()); | ||
} | ||
} | ||
} |
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,46 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class AndIlExpression : IlExpression | ||
{ | ||
public AndIlExpression(IlExpression left, IlExpression right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} | ||
|
||
public IlExpression Left { get; } | ||
public IlExpression Right { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Left.GetInstructions(instructions); | ||
Right.GetInstructions(instructions); | ||
instructions.Add(Instruction.And()); | ||
} | ||
} | ||
} |
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,55 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class CallIlExpression : IlExpression | ||
{ | ||
public CallIlExpression(MethodInfo method, params IlExpression[] args) | ||
{ | ||
Method = method ?? | ||
throw new ArgumentNullException(nameof(method)); | ||
Args = args ?? throw new ArgumentNullException(nameof(args)); | ||
} | ||
public CallIlExpression(Delegate @delegate, | ||
params IlExpression[] args) | ||
: this(@delegate?.Method, args) | ||
{ | ||
} | ||
|
||
public MethodInfo Method { get; } | ||
public IlExpression[] Args { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
// TODO: check args against method signature? | ||
int i; | ||
for (i = 0; i < Args.Length; i++) | ||
Args[i].GetInstructions(instructions); | ||
instructions.Add(Instruction.Call(Method)); | ||
} | ||
} | ||
} |
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,47 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class CompareEqualIlExpression : IlExpression | ||
{ | ||
public CompareEqualIlExpression(IlExpression left, | ||
IlExpression right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} | ||
|
||
public IlExpression Left { get; } | ||
public IlExpression Right { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Left.GetInstructions(instructions); | ||
Right.GetInstructions(instructions); | ||
instructions.Add(Instruction.CompareEqual()); | ||
} | ||
} | ||
} |
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,47 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class CompareGreaterThanIlExpression : IlExpression | ||
{ | ||
public CompareGreaterThanIlExpression(IlExpression left, | ||
IlExpression right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} | ||
|
||
public IlExpression Left { get; } | ||
public IlExpression Right { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Left.GetInstructions(instructions); | ||
Right.GetInstructions(instructions); | ||
instructions.Add(Instruction.CompareGreaterThan()); | ||
} | ||
} | ||
} |
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,47 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class CompareLessThanIlExpression : IlExpression | ||
{ | ||
public CompareLessThanIlExpression(IlExpression left, | ||
IlExpression right) | ||
{ | ||
Left = left ?? throw new ArgumentNullException(nameof(left)); | ||
Right = right ?? throw new ArgumentNullException(nameof(right)); | ||
} | ||
|
||
public IlExpression Left { get; } | ||
public IlExpression Right { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Left.GetInstructions(instructions); | ||
Right.GetInstructions(instructions); | ||
instructions.Add(Instruction.CompareLessThan()); | ||
} | ||
} | ||
} |
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,44 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class ConvertI4IlExpression : IlExpression | ||
{ | ||
public ConvertI4IlExpression(IlExpression argument) | ||
{ | ||
Argument = argument ?? | ||
throw new ArgumentNullException(nameof(argument)); | ||
} | ||
|
||
public IlExpression Argument { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Argument.GetInstructions(instructions); | ||
instructions.Add(Instruction.ConvertI4()); | ||
} | ||
} | ||
} |
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,44 @@ | ||
|
||
/* | ||
* MetaphysicsIndustries.Solus | ||
* Copyright (C) 2006-2021 Metaphysics Industries, Inc., Richard Sartor | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
* | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MetaphysicsIndustries.Solus.Compiler.IlExpressions | ||
{ | ||
public class ConvertR4IlExpression : IlExpression | ||
{ | ||
public ConvertR4IlExpression(IlExpression argument) | ||
{ | ||
Argument = argument ?? | ||
throw new ArgumentNullException(nameof(argument)); | ||
} | ||
|
||
public IlExpression Argument { get; } | ||
|
||
public override void GetInstructions(IList<Instruction> instructions) | ||
{ | ||
Argument.GetInstructions(instructions); | ||
instructions.Add(Instruction.ConvertR4()); | ||
} | ||
} | ||
} |
Oops, something went wrong.