Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2019-12-26 15:44:21 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-12-26 15:44:21 +0300
commit2dd08992a5f98a292660f27f2f4cd78154ab44ca (patch)
tree2eda1decccdadf73d339f89d1301cebc28482e29 /src/GCodes/GCodeMachineState.h
parent6a5589d5146ff86151d82e8d8c9c822ebc085271 (diff)
Implemented expression evaluator and 'elif' keyword
Diffstat (limited to 'src/GCodes/GCodeMachineState.h')
-rw-r--r--src/GCodes/GCodeMachineState.h28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/GCodes/GCodeMachineState.h b/src/GCodes/GCodeMachineState.h
index 5b717350..3a636847 100644
--- a/src/GCodes/GCodeMachineState.h
+++ b/src/GCodes/GCodeMachineState.h
@@ -117,40 +117,36 @@ enum class Compatibility : uint8_t
nanoDLP = 6
};
+// Type of the block we are in when processing conditional GCode
+enum class BlockType : uint8_t { plain, ifTrue, ifFalseNoneTrue, ifFalseHadTrue, loop };
+
// Class to hold the state of gcode execution for some input source
class GCodeMachineState
{
public:
typedef uint32_t ResourceBitmap;
- // Class to record the state of blocks whe3n using conditional GCode
+ // Class to record the state of blocks when using conditional GCode
class BlockState
{
public:
- BlockState() : blockType(PlainBlock) {}
+ BlockState() : blockType((uint32_t)BlockType::plain) {}
- bool IsLoop() const { return blockType == LoopBlock; }
- bool IsIfTrueBlock() const { return blockType == IfTrueBlock; }
- bool IsIfFalseBlock() const { return blockType == IfFalseBlock; }
- bool IsPlainBlock() const { return blockType == PlainBlock; }
+ BlockType GetType() const { return (BlockType) blockType; }
uint32_t GetLineNumber() const { return lineNumber; }
FilePosition GetFilePosition() const { return fpos; }
void SetLoopBlock(FilePosition filePos, uint32_t lineNum) { fpos = filePos; lineNumber = lineNum; }
- void SetPlainBlock() { blockType = PlainBlock; }
- void SetIfTrueBlock() { blockType = IfTrueBlock; }
- void SetIfFalseBlock() { blockType = IfFalseBlock; }
+ void SetPlainBlock() { blockType = (uint32_t)BlockType::plain; }
+ void SetIfTrueBlock() { blockType = (uint32_t)BlockType::ifTrue; }
+ void SetIfFalseNoneTrueBlock() { blockType = (uint32_t)BlockType::ifFalseNoneTrue; }
+ void SetIfFalseHadTrueBlock() { blockType = (uint32_t)BlockType::ifFalseHadTrue; }
private:
FilePosition fpos; // the file offset at which the current block started
- uint32_t lineNumber : 30, // the line number at which the current block started
- blockType : 2; // the type of this block
-
- static constexpr uint8_t PlainBlock = 0;
- static constexpr uint8_t IfTrueBlock = 1;
- static constexpr uint8_t IfFalseBlock = 2;
- static constexpr uint8_t LoopBlock = 3;
+ uint32_t lineNumber : 29, // the line number at which the current block started
+ blockType : 3; // the type of this block
};
GCodeMachineState();