Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

libfpvm: only access node->label if we have an indentifier

We provide a function node_is_op for the library user to make this
distiction as well (used in parser_helper.c).

Note that this change means that we can't report the name of the
operator that causes an "Operation not supported" error. This is
visible to users in the case of op_not. Fix later.
  • Loading branch information...
commit 44acf61e3d9d46b6d3c418af1c28c02bcda23669 1 parent 9f71dde
@wpwrak wpwrak authored
Showing with 9 additions and 1 deletion.
  1. +8 −0 software/include/fpvm/ast.h
  2. +1 −1  software/libfpvm/fpvm.c
View
8 software/include/fpvm/ast.h
@@ -60,6 +60,9 @@ struct ast_branches {
struct ast_node {
enum ast_op op;
/*
+ * NOTE: don't use the old convention below. Use node->op and/or
+ * node_is_op.
+ *
* label is an empty string:
* node is a constant
* label is not an empty string and branch A is null:
@@ -74,4 +77,9 @@ struct ast_node {
} contents;
};
+static inline int node_is_op(const struct ast_node *n)
+{
+ return n->op >= op_plus;
+}
+
#endif /* __FPVM_AST_H */
View
2  software/libfpvm/fpvm.c
@@ -523,7 +523,7 @@ static int compile(struct fpvm_fragment *fragment, int reg, struct ast_node *nod
opcode = operator2opcode(node->op);
if(opcode < 0) {
snprintf(fragment->last_error, FPVM_MAXERRLEN,
- "Operation not supported: %s", node->label);
+ "Operation not supported: %d", node->op);
return FPVM_INVALID_REG;
}
ADD_ISN(opcode, opa, opb, reg);
Please sign in to comment.
Something went wrong with that request. Please try again.