aboutsummaryrefslogtreecommitdiff
path: root/src/checker/checker.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-12-30 15:45:10 +0000
committerGinger Bill <bill@gingerbill.org>2016-12-30 15:45:10 +0000
commit23d32f34e526cfb657a72e5b2dab86d1df765f0f (patch)
tree7998bcf40ca9f581be6296bf4f68c102a5d234c8 /src/checker/checker.c
parentd714bece47ea058e482389452cd428dad9c28fd0 (diff)
Block Expressions and `give`
Diffstat (limited to 'src/checker/checker.c')
-rw-r--r--src/checker/checker.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/checker/checker.c b/src/checker/checker.c
index 2159eb95b..c61884253 100644
--- a/src/checker/checker.c
+++ b/src/checker/checker.c
@@ -32,6 +32,16 @@ typedef struct TypeAndValue {
ExactValue value;
} TypeAndValue;
+bool is_operand_value(Operand o) {
+ switch (o.mode) {
+ case Addressing_Value:
+ case Addressing_Variable:
+ case Addressing_Constant:
+ return true;
+ }
+ return false;
+}
+
typedef struct DeclInfo {
@@ -92,6 +102,14 @@ typedef enum ExprKind {
Expr_Stmt,
} ExprKind;
+// Statements and Declarations
+typedef enum StmtFlag {
+ Stmt_BreakAllowed = 1<<0,
+ Stmt_ContinueAllowed = 1<<1,
+ Stmt_FallthroughAllowed = 1<<2,
+ Stmt_GiveAllowed = 1<<3,
+} StmtFlag;
+
typedef enum BuiltinProcId {
BuiltinProc_Invalid,
@@ -357,9 +375,11 @@ void add_scope(Checker *c, AstNode *node, Scope *scope) {
void check_open_scope(Checker *c, AstNode *node) {
GB_ASSERT(node != NULL);
+ node = unparen_expr(node);
GB_ASSERT(node->kind == AstNode_Invalid ||
is_ast_node_stmt(node) ||
- is_ast_node_type(node));
+ is_ast_node_type(node) ||
+ node->kind == AstNode_BlockExpr);
Scope *scope = make_scope(c->context.scope, c->allocator);
add_scope(c, node, scope);
if (node->kind == AstNode_ProcType) {