Private
Public Access
Code cleanup
This commit is contained in:
1 parent
72b5db624f
commit
39dc69d7b1
11 files changed
+27
-48
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -12,8 +12,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
/// The drawer is responsible for drawing on the graphics object.
|
/// The drawer is responsible for drawing on the graphics object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Drawer {
|
public class Drawer {
|
||||||
|
private readonly ValueStorage valueStorage = new ValueStorage();
|
||||||
private ValueStorage valueStorage = new ValueStorage();
|
|
||||||
public List<IVerbChunk> verbChunks = new List<IVerbChunk>();
|
public List<IVerbChunk> verbChunks = new List<IVerbChunk>();
|
||||||
public bool verbChunkGeneratingMethod = false;
|
public bool verbChunkGeneratingMethod = false;
|
||||||
public Dictionary<string, MethodChunk> Methods = new Dictionary<string, MethodChunk>();
|
public Dictionary<string, MethodChunk> Methods = new Dictionary<string, MethodChunk>();
|
||||||
@@ -154,7 +153,7 @@ namespace Advanced_Software_Engineering {
|
|||||||
|
|
||||||
//Make it relative to the pen
|
//Make it relative to the pen
|
||||||
for (int pointIndex = 0; pointIndex < points.Length; pointIndex++)
|
for (int pointIndex = 0; pointIndex < points.Length; pointIndex++)
|
||||||
points[pointIndex] = new Point(points[pointIndex].X + penPosition.X, points[pointIndex].Y+ penPosition.Y);
|
points[pointIndex] = new Point(points[pointIndex].X + penPosition.X, points[pointIndex].Y + penPosition.Y);
|
||||||
|
|
||||||
GraphicsPath path = new GraphicsPath {
|
GraphicsPath path = new GraphicsPath {
|
||||||
FillMode = FillMode.Winding
|
FillMode = FillMode.Winding
|
||||||
@@ -202,6 +201,5 @@ namespace Advanced_Software_Engineering {
|
|||||||
public ValueStorage GetValueStorage() {
|
public ValueStorage GetValueStorage() {
|
||||||
return valueStorage;
|
return valueStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-2
@@ -1,7 +1,8 @@
|
|||||||
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs.Actions {
|
namespace Advanced_Software_Engineering.Verbs.DrawingVerbs.Actions {
|
||||||
class NoOp : IVerb {
|
|
||||||
public void ExecuteVerb() {
|
|
||||||
|
|
||||||
|
internal class NoOp : IVerb {
|
||||||
|
|
||||||
|
public void ExecuteVerb() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDescription() {
|
public string GetDescription() {
|
||||||
|
|||||||
+4
-11
@@ -1,15 +1,8 @@
|
|||||||
using Advanced_Software_Engineering.Verbs.Value;
|
namespace Advanced_Software_Engineering.Verbs.Flow {
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Flow {
|
|
||||||
class DeclareMethod : IVerb, IVerbChunk {
|
|
||||||
string methodName;
|
|
||||||
Drawer drawer;
|
|
||||||
|
|
||||||
|
internal class DeclareMethod : IVerb, IVerbChunk {
|
||||||
|
private readonly string methodName;
|
||||||
|
private readonly Drawer drawer;
|
||||||
|
|
||||||
public DeclareMethod(Drawer drawer, string methodName) {
|
public DeclareMethod(Drawer drawer, string methodName) {
|
||||||
this.drawer = drawer;
|
this.drawer = drawer;
|
||||||
|
|||||||
+2
-6
@@ -1,11 +1,7 @@
|
|||||||
using System;
|
namespace Advanced_Software_Engineering.Verbs.Flow {
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Flow {
|
|
||||||
public interface IVerbChunk : IVerb {
|
public interface IVerbChunk : IVerb {
|
||||||
|
|
||||||
void AddVerb(IVerb verb);
|
void AddVerb(IVerb verb);
|
||||||
|
|
||||||
void ExecuteVerb();
|
void ExecuteVerb();
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Flow {
|
namespace Advanced_Software_Engineering.Verbs.Flow {
|
||||||
public class IfChunk : VerbChunk, IVerbChunk, IVerb {
|
|
||||||
|
|
||||||
IValue conditional;
|
public class IfChunk : VerbChunk, IVerbChunk, IVerb {
|
||||||
ValueStorage valueStorage;
|
private readonly IValue conditional;
|
||||||
|
private readonly ValueStorage valueStorage;
|
||||||
|
|
||||||
public IfChunk(ValueStorage valueStorage, IValue conditional) : base() {
|
public IfChunk(ValueStorage valueStorage, IValue conditional) : base() {
|
||||||
this.conditional = conditional;
|
this.conditional = conditional;
|
||||||
@@ -24,6 +24,5 @@ namespace Advanced_Software_Engineering.Verbs.Flow {
|
|||||||
if (conditional.ToBool()) base.ExecuteVerb();
|
if (conditional.ToBool()) base.ExecuteVerb();
|
||||||
valueStorage.DecreaseStack();
|
valueStorage.DecreaseStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-8
@@ -1,16 +1,15 @@
|
|||||||
using Advanced_Software_Engineering.Verbs.Value;
|
using Advanced_Software_Engineering.Verbs.Value;
|
||||||
using Advanced_Software_Engineering.Verbs.Value.ValueTypes;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Flow {
|
namespace Advanced_Software_Engineering.Verbs.Flow {
|
||||||
public class MethodChunk : VerbChunk, IVerb, IValue {
|
|
||||||
|
|
||||||
ValueStorage valueStorage;
|
public class MethodChunk : VerbChunk, IVerb, IValue {
|
||||||
DeclareVariable[] variables;
|
private readonly ValueStorage valueStorage;
|
||||||
UpdateVariable[] updateVariables;
|
private readonly DeclareVariable[] variables;
|
||||||
bool init = false;
|
private UpdateVariable[] updateVariables;
|
||||||
IValue result;
|
private bool init = false;
|
||||||
|
private IValue result;
|
||||||
|
|
||||||
public MethodChunk(ValueStorage valueStorage, DeclareVariable[] variables) : base() {
|
public MethodChunk(ValueStorage valueStorage, DeclareVariable[] variables) : base() {
|
||||||
this.valueStorage = valueStorage;
|
this.valueStorage = valueStorage;
|
||||||
@@ -59,7 +58,6 @@ namespace Advanced_Software_Engineering.Verbs.Flow {
|
|||||||
init = true;
|
init = true;
|
||||||
}
|
}
|
||||||
valueStorage.DecreaseStack();
|
valueStorage.DecreaseStack();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IValue GetResult() {
|
public IValue GetResult() {
|
||||||
|
|||||||
+3
-4
@@ -2,10 +2,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Flow {
|
namespace Advanced_Software_Engineering.Verbs.Flow {
|
||||||
public class WhileChunk : VerbChunk, IVerbChunk, IVerb {
|
|
||||||
|
|
||||||
IValue conditional;
|
public class WhileChunk : VerbChunk, IVerbChunk, IVerb {
|
||||||
ValueStorage valueStorage;
|
private readonly IValue conditional;
|
||||||
|
private readonly ValueStorage valueStorage;
|
||||||
|
|
||||||
public WhileChunk(ValueStorage valueStorage, IValue conditional) : base() {
|
public WhileChunk(ValueStorage valueStorage, IValue conditional) : base() {
|
||||||
this.conditional = conditional;
|
this.conditional = conditional;
|
||||||
@@ -24,6 +24,5 @@ namespace Advanced_Software_Engineering.Verbs.Flow {
|
|||||||
while (conditional.ToBool()) base.ExecuteVerb();
|
while (conditional.ToBool()) base.ExecuteVerb();
|
||||||
valueStorage.DecreaseStack();
|
valueStorage.DecreaseStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -2,8 +2,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Advanced_Software_Engineering.Verbs.Value {
|
namespace Advanced_Software_Engineering.Verbs.Value {
|
||||||
public class ValueStorage {
|
|
||||||
|
|
||||||
|
public class ValueStorage {
|
||||||
protected int currentStack;
|
protected int currentStack;
|
||||||
protected List<Dictionary<string, IValue>> Variables = new List<Dictionary<string, IValue>>();
|
protected List<Dictionary<string, IValue>> Variables = new List<Dictionary<string, IValue>>();
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
if (stack < 0) throw new Exception("Stack cannot be less than 0");
|
if (stack < 0) throw new Exception("Stack cannot be less than 0");
|
||||||
|
|
||||||
//Decreased Stack
|
//Decreased Stack
|
||||||
if(currentStack > stack) {
|
if (currentStack > stack) {
|
||||||
Variables.RemoveAt(currentStack);
|
Variables.RemoveAt(currentStack);
|
||||||
}
|
}
|
||||||
//Increased Stack
|
//Increased Stack
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ namespace Advanced_Software_Engineering.Verbs.Value {
|
|||||||
private readonly IValue variable2;
|
private readonly IValue variable2;
|
||||||
private readonly int operation;
|
private readonly int operation;
|
||||||
|
|
||||||
private bool evaluated = false;
|
private readonly bool evaluated = false;
|
||||||
private IValue evaluatedValue;
|
private IValue evaluatedValue;
|
||||||
|
|
||||||
public ExpressionValue(IValue variable1, IValue variable2, int operation) {
|
public ExpressionValue(IValue variable1, IValue variable2, int operation) {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
public static IVerb MakeVerb(Drawer drawer, string fullCommand) {
|
public static IVerb MakeVerb(Drawer drawer, string fullCommand) {
|
||||||
ValueStorage rootValueStorage = drawer.GetValueStorage();
|
ValueStorage rootValueStorage = drawer.GetValueStorage();
|
||||||
|
|
||||||
|
|
||||||
List<IVerbChunk> verbChunks = drawer.verbChunks;
|
List<IVerbChunk> verbChunks = drawer.verbChunks;
|
||||||
if (verbChunks.Count == 0) verbChunks.Add(null);
|
if (verbChunks.Count == 0) verbChunks.Add(null);
|
||||||
|
|
||||||
@@ -78,7 +77,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Parse flow verbs
|
//Parse flow verbs
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "if":
|
case "if":
|
||||||
@@ -162,7 +160,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
//Handle errors
|
//Handle errors
|
||||||
if (methodVariableNames.Length != parameterLength) throw new Exception("Method " + command + "Has an incorrect number of parameters");
|
if (methodVariableNames.Length != parameterLength) throw new Exception("Method " + command + "Has an incorrect number of parameters");
|
||||||
|
|
||||||
|
|
||||||
/* So something like this:
|
/* So something like this:
|
||||||
* def abc d
|
* def abc d
|
||||||
* circle d
|
* circle d
|
||||||
@@ -177,7 +174,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Update the values of the variables
|
// Update the values of the variables
|
||||||
List<UpdateVariable> UpdateVariableList = new List<UpdateVariable>();
|
List<UpdateVariable> UpdateVariableList = new List<UpdateVariable>();
|
||||||
for (int variableIndex = 0; variableIndex < methodVariableNames.Length; variableIndex++) {
|
for (int variableIndex = 0; variableIndex < methodVariableNames.Length; variableIndex++) {
|
||||||
@@ -338,7 +334,6 @@ namespace Advanced_Software_Engineering {
|
|||||||
tmpVerb = currentChunk;
|
tmpVerb = currentChunk;
|
||||||
currentChunk = verbChunks[chunkDepth];
|
currentChunk = verbChunks[chunkDepth];
|
||||||
rootValueStorage.DecreaseStack();
|
rootValueStorage.DecreaseStack();
|
||||||
|
|
||||||
} else throw new Exception(command + " doesn't take parameters");
|
} else throw new Exception(command + " doesn't take parameters");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user