Skip to content

Commit

Permalink
Merge pull request #349 from dictu-lang/develop
Browse files Browse the repository at this point in the history
Release 0.14.1
  • Loading branch information
Jason2605 authored Dec 5, 2020
2 parents 4923d44 + e054479 commit 26b342e
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: >-
color_scheme: "dictu" # Custom theme
logo: "/assets/images/dictu-logo/dictu-wordmark.svg"

version: "0.14.0"
version: "0.14.1"
github_username: dictu-lang
search_enabled: true

Expand Down
2 changes: 1 addition & 1 deletion src/include/dictu_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#define DICTU_MAJOR_VERSION "0"
#define DICTU_MINOR_VERSION "14"
#define DICTU_PATCH_VERSION "0"
#define DICTU_PATCH_VERSION "1"

#define DICTU_STRING_VERSION "Dictu Version: " DICTU_MAJOR_VERSION "." DICTU_MINOR_VERSION "." DICTU_PATCH_VERSION "\n"

Expand Down
95 changes: 94 additions & 1 deletion src/vm/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,99 @@ static void expressionStatement(Compiler *compiler) {
}
}

static int getArgCount(uint8_t code, const ValueArray constants, int ip) {
switch (code) {
case OP_NIL:
case OP_TRUE:
case OP_FALSE:
case OP_NEW_LIST:
case OP_ADD_LIST:
case OP_NEW_DICT:
case OP_ADD_DICT:
case OP_SUBSCRIPT:
case OP_SUBSCRIPT_ASSIGN:
case OP_SLICE:
case OP_PUSH:
case OP_POP:
case OP_EQUAL:
case OP_GREATER:
case OP_LESS:
case OP_ADD:
case OP_INCREMENT:
case OP_DECREMENT:
case OP_MULTIPLY:
case OP_DIVIDE:
case OP_POW:
case OP_MOD:
case OP_NOT:
case OP_NEGATE:
case OP_CLOSE_UPVALUE:
case OP_RETURN:
case OP_EMPTY:
case OP_END_CLASS:
case OP_IMPORT_VARIABLE:
case OP_IMPORT_END:
case OP_USE:
case OP_OPEN_FILE:
case OP_CLOSE_FILE:
case OP_BREAK:
case OP_BITWISE_AND:
case OP_BITWISE_XOR:
case OP_BITWISE_OR:
case OP_POP_REPL:
return 0;

case OP_CONSTANT:
case OP_UNPACK_LIST:
case OP_GET_LOCAL:
case OP_SET_LOCAL:
case OP_GET_GLOBAL:
case OP_GET_MODULE:
case OP_DEFINE_MODULE:
case OP_SET_MODULE:
case OP_GET_UPVALUE:
case OP_SET_UPVALUE:
case OP_GET_PROPERTY:
case OP_GET_PROPERTY_NO_POP:
case OP_SET_PROPERTY:
case OP_SET_INIT_PROPERTIES:
case OP_GET_SUPER:
case OP_CALL:
case OP_METHOD:
case OP_IMPORT:
return 1;

case OP_DEFINE_OPTIONAL:
case OP_JUMP:
case OP_JUMP_IF_NIL:
case OP_JUMP_IF_FALSE:
case OP_LOOP:
case OP_INVOKE:
case OP_SUPER:
case OP_CLASS:
case OP_SUBCLASS:
case OP_IMPORT_BUILTIN:
return 2;

case OP_IMPORT_BUILTIN_VARIABLE:
return 3;

case OP_CLOSURE: {
ObjFunction* loadedFn = AS_FUNCTION(constants.values[ip + 1]);

// There is one byte for the constant, then two for each upvalue.
return 1 + (loadedFn->upvalueCount * 2);
}

case OP_IMPORT_FROM: {
int count = constants.values[ip + 1];
return 1 + count;
}
}

return 0;
}

static void endLoop(Compiler *compiler) {
if (compiler->loop->end != -1) {
patchJump(compiler, compiler->loop->end);
Expand All @@ -1694,7 +1787,7 @@ static void endLoop(Compiler *compiler) {
patchJump(compiler, i + 1);
i += 3;
} else {
i++;
i += 1 + getArgCount(compiler->function->chunk.code[i], compiler->function->chunk.constants, i);
}
}

Expand Down

0 comments on commit 26b342e

Please sign in to comment.