mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 23:04:08 +10:00
It's bloody never-ending
This commit is contained in:
@@ -32,11 +32,7 @@ DONE: third output stream, for lexer/parser/compiler/interpreter errors
|
|||||||
DONE: Assertion-based test scripts
|
DONE: Assertion-based test scripts
|
||||||
DONE: Import/export keywords
|
DONE: Import/export keywords
|
||||||
DONE: A way to check the type of a variable (typeOf keyword)
|
DONE: A way to check the type of a variable (typeOf keyword)
|
||||||
|
DONE: slice and dot notation around the builtin _index and _dot functions
|
||||||
|
|
||||||
TODO: slice and dot notation around the builtin _index and _dot functions
|
|
||||||
//TODO: check this const-ness
|
|
||||||
//TODO: add arithmetics
|
|
||||||
|
|
||||||
|
|
||||||
TODO: ternary operator
|
TODO: ternary operator
|
||||||
@@ -47,6 +43,8 @@ TODO: external script runner library
|
|||||||
TODO: document how it all works - book?
|
TODO: document how it all works - book?
|
||||||
TODO: maximum recursion/function depth
|
TODO: maximum recursion/function depth
|
||||||
TODO: better API
|
TODO: better API
|
||||||
|
TODO: better sugar for _push and _pop
|
||||||
|
TODO: nested compound assignment
|
||||||
TODO: packaging for release?
|
TODO: packaging for release?
|
||||||
|
|
||||||
NOPE: a = b = c = 1;
|
NOPE: a = b = c = 1;
|
||||||
|
|||||||
10
scripts/small.toy
Normal file
10
scripts/small.toy
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
var t: type = typeas [[int]];
|
||||||
|
|
||||||
|
var a: t = [
|
||||||
|
[1, 2, 3]
|
||||||
|
];
|
||||||
|
|
||||||
|
print a;
|
||||||
|
print typeof a;
|
||||||
@@ -1625,7 +1625,7 @@ static bool execIndexAssign(Interpreter* interpreter) {
|
|||||||
LiteralArray arguments;
|
LiteralArray arguments;
|
||||||
initLiteralArray(&arguments);
|
initLiteralArray(&arguments);
|
||||||
|
|
||||||
pushLiteralArray(&arguments, compound);
|
pushLiteralArray(&arguments, compound); //TODO: nested compounds?
|
||||||
pushLiteralArray(&arguments, first);
|
pushLiteralArray(&arguments, first);
|
||||||
pushLiteralArray(&arguments, second);
|
pushLiteralArray(&arguments, second);
|
||||||
pushLiteralArray(&arguments, third);
|
pushLiteralArray(&arguments, third);
|
||||||
@@ -2267,7 +2267,7 @@ static void readInterpreterSections(Interpreter* interpreter) {
|
|||||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_ARRAY) {
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_ARRAY) {
|
||||||
unsigned short vt = readShort(interpreter->bytecode, &interpreter->count);
|
unsigned short vt = readShort(interpreter->bytecode, &interpreter->count);
|
||||||
|
|
||||||
TYPE_PUSH_SUBTYPE(&typeLiteral, interpreter->literalCache.literals[vt]);
|
TYPE_PUSH_SUBTYPE(&typeLiteral, copyLiteral(interpreter->literalCache.literals[vt]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_DICTIONARY) {
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_DICTIONARY) {
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_ARRAY && !IS_ARRAY(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_ARRAY(value)) {
|
if (IS_ARRAY(value)) {
|
||||||
//check value's type
|
//check value's type
|
||||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_ARRAY) {
|
if (AS_TYPE(typeLiteral).typeOf != LITERAL_ARRAY) {
|
||||||
@@ -69,6 +73,10 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_DICTIONARY && !IS_DICTIONARY(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_DICTIONARY(value)) {
|
if (IS_DICTIONARY(value)) {
|
||||||
//check value's type
|
//check value's type
|
||||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_DICTIONARY) {
|
if (AS_TYPE(typeLiteral).typeOf != LITERAL_DICTIONARY) {
|
||||||
@@ -90,11 +98,8 @@ static bool checkType(Literal typeLiteral, Literal value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_FUNCTION(value)) {
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_FUNCTION && !IS_FUNCTION(value)) {
|
||||||
//check value's type
|
return false;
|
||||||
if (AS_TYPE(typeLiteral).typeOf != LITERAL_FUNCTION) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AS_TYPE(typeLiteral).typeOf == LITERAL_TYPE && !IS_TYPE(value)) {
|
if (AS_TYPE(typeLiteral).typeOf == LITERAL_TYPE && !IS_TYPE(value)) {
|
||||||
@@ -217,11 +222,13 @@ bool setScopeVariable(Scope* scope, Literal key, Literal value, bool constCheck)
|
|||||||
Literal typeLiteral = getLiteralDictionary(&scope->types, key);
|
Literal typeLiteral = getLiteralDictionary(&scope->types, key);
|
||||||
|
|
||||||
if (!checkType(typeLiteral, value)) {
|
if (!checkType(typeLiteral, value)) {
|
||||||
|
freeLiteral(typeLiteral);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//const check
|
//const check
|
||||||
if (constCheck && (AS_TYPE(typeLiteral).constant)) {
|
if (constCheck && (AS_TYPE(typeLiteral).constant)) {
|
||||||
|
freeLiteral(typeLiteral);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,3 @@ bool setScopeVariable(Scope* scope, Literal key, Literal value, bool constCheck)
|
|||||||
bool getScopeVariable(Scope* scope, Literal key, Literal* value);
|
bool getScopeVariable(Scope* scope, Literal key, Literal* value);
|
||||||
|
|
||||||
Literal getScopeType(Scope* scope, Literal key);
|
Literal getScopeType(Scope* scope, Literal key);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user