Open Lecrapouille opened 4 years ago
Thinking: Qt QScriptEngine:
QScriptEngine engine = new QScriptEngine(this);
MyObject* obj = ... ;
QScriptValue scriptObj = engine->NewQObject(obj);
QScprtValue global = engine->globalObject();
global.setProperty("obj", scriptObj);
QString script = ;
QScriptValue result = engine->evaluate(script);
if (result.isError())
... result.toString()
Upgrade words primitive managing the input stream:
Forth primitives such as SOURCE, WORD KEY, >IN, TIB, follow outdated specifications and made my Stream API more ugly. Their idea to allow the Forth interpreter to self-evolve by reading the Forth script is greater but their usage is very limited. For example, my Stream API was mainly made of feed(stream), hasWord() and getWord() and private methods such split() as but these words made me add methods such as split(delimiter) (delimiter is a string but only the 1st is used to follow the standard), skip(offset) (negative offset is badly managed)
We can make think a more modern way primitives words.
dev-refacto branch:
API:
forth::Forth forth;
is not possible =>forth::Forth simforth;
should besimforth::Forth forth;
Issues:
!
store a cell but ANSI cells are 2 bytes and ANSI C! is not possible here (except in HERE = m_here() / 2). 0BRANCH needsT!
because we just need 1 token. How to implementC!
because m_here needs to be moved of 0.5 (HERE shall return * 2 but no longer hold uint16_t).RETURN
KO ANSI-Forth:
T{ : GI5 BEGIN DUP 2 > WHILE DUP 5 < WHILE DUP 1+ REPEAT 123 ELSE 345 THEN ; WORDS -> }T
KOS" 1 2 3 + + ABORT" qqqqq"" EVALUATE 1 .
Finding the first " char seems not correct. Also manage \".ANSI-Forth suxx:
s" 1 One, 2 Two, 3 Three is good." s" \s+" type type
the second string smashs the first and type shows the last string. Better idea would be to use C pointer and different space memory.Travis CI / Unit tests:
valgrind finds 2 bugs when doing unit tests => ABORT"' . EXECUTE
and: FOO . ; ' FOO EXECUTE
.Endian:
private Cell: public Endian
with methods such asswap, set, get(char*)
. Make dico.append(X) delegate this operation to Endian.TODO/improvements:
~/.SimForth
folder: 1/ Create it before needed by the interactive prompt loads its history. 2/ Create a sub-folderMinimal Forth system:
0 0 !
... FILL, ERASE, CMOVEFILE? <word>
returns the file path and the line where the word is defined.USING? <word>
returns files using this word.Dictionary:
CLib improvements:
C-FUNCTION FOO foo n -- void
orC-FUNCTION FOO foo n --
Improvements:
HELP + returns ( n n -- n + n )
. Idea:: HELP( ')' WORD DROP >H ; IMMEDIATE : + .HELP( n -- n + n )"
SimForth -f "f1.fth" -f "f2.fth"
givesok ok
but could beok f1.fth ok f2.fth
Debugger:
Benchmark:
[DONE] Implement a benchmark for SimForth vs SimTaDyn vs pforth. For the moment on Fibonacci: gforth 0.9s pforth 1s. SimForth: 3s. SimTaDyn: 7s.cat *.fs
from gforth|pforth > all.fs Then:sort -k2 -n res.txt
Done:
[DONE] Primitives reforth: regexp, execve, fork[DONE] DEFER[DONE] MAJOR: to be fixed VALUE is not equivalent of VARIABLE[DONE] MAJOR: COMPILE inside a definition : KO. => Failed on https://rosettacode.org/wiki/Tree_traversal#Forth[DONE]: FOO 4 + DUP 4 - DUP ;
broken display:(TOKEN) 4 + DUP (TOKEN) 4 - DUP
the 2nd (TOKEN) when executed maked the word - underlined.[DONE] MINOR: Optimize Cell integer operations (for the moment using float computation). TBD: Ne plus utiliser f+ f/ f- mais + / - des qu'il y a un float retourne un float. Si on veut un int on utilise >INT ou CEIL, FLOOR, ROUND[WONT DO] Do not show the whole dictionary but the last N words.(SEE word is ok)[DONE] Autocompletion of the NOP (last word inside the dictionary: infinite loop).[DONE] CI: download LinkAgainstMyLibs and compile Forth example[DONE] DOES> ABORT" ROLL MODULES, static String, structure, array[DONE] Dico display regressions:(DOES) 1681 EXIT 10 NOP NOP
instead of(DOES) 1681 EXIT 10 0 0
[DONE] regression: literals after EXIT are displayed as tokens[DONE] Dico display regressions after (TOKEN) bad underlined tokens:002f 0004 0069 \0082\ (TOKEN) 4 + \DUP\
withWord + is a primitive
instead of underlining 0069 and +.[DONE] gcov not working with g++-8 in Travis CIProblem was lcov 1.13 not compatible with gcc >= 8. Install lcov 1.14[DONE] Makefile: Create a shared library of SimForth (problem: makefile multi-target). See Makefile-lib.[DONE] Makefile: Generate a config.hpp instead of version.h[DONE]: FOOBAR [ 123 ] LITERAL ;
should store 123 on data-satck[DONE]T{ : GDX 123 ; : GDX GDX 234 ; GDX -> 123 234 }T
is not working on SimForth because of prefered recursivity. To be fixed because of: / dup 0= if -10 throw endif / ;
is not working/
is not refering to the older / operator. If we want to refer to defining word we have to use :factorial recursive ... factorial
else: factorial ... recurse
[DONE] Autocompletion: >FL does not complete >FLOAT[DONE] Word autocompletion with lower cases[DONE] 2432902008176640000 =>warning "too large" + convert it to float.[WONTDO] 'r' marche mais pas '\n'.(I could not find a 'fromascii' fonction for control chars~~[DONE] Stream cannot parse MSDOS files[DONE] Show unprintable char on unknown words[DONE] Unknown word '\ VALUE:' because an non visible data is store. We should show non printable char in the word.[DONE] Copier/Coller d'une fonction de plusieurs lignes dans la console interactive ne fonctionne pas: "Error EOF reached"[DONE] Compilation of unit-tests seems to have more warnings activated than standalone[DONE] make check does not make Travis failed[DONE] 0 VALUE TOTO => VARIABLE TOTO 0 TOTO @[DONE] Append dumped dictionaries.[DONE] Implement a debuger.[DONE] Debugger: show IP[DONE] Proper dico display and debuger definition display: create separate functions[DONE] \EOF for ending a streaming[DONE] findWord(std::string const& word, Token& xt, bool& immediate). Returned xt is not really the XT (code field) but the CFA (== dictionary index). executeToken(xt) needs the CFA. TICK returns the CFA but should return the CF (1 ' DUP EXECUTE
) Rename xt, tokens and give better names.[DONE] Dictionary displayCOMPILE 0BRANCH 02ab
instead ofCOMPILE 0BRANCH >MARK
[WONTDO] CLib: include ?? Data stack + typedef Cell/Token ?? (For the moment the generated C code is fine).~~[WONTDO] Upgrade: Push/pop Stream is error prone. Stack Stream has no RAI: no automatic file descriptor closed[DONE] Bug C Lib several 0 parameter + 1 return code: dsp[0] instead of dsp[-1][DONE] Tracer: difficult to know the "depth" of secondary words currently executed. For example error of DUP inside a DO WHILE makes difficil to know which secondary words the DUP comes from.[DONE] Float sqrt, ln, log, exp, sin, cos (+ tester si on passe un int)[DONE] Recurse[DONE] FLITERAL (float literals)[DONE] LITERAL (with int > int16_t)[DONE] Regression: dictionary display: literals are displayed as unsigned.[DONE] Dictionary: display float and manage int and float literal > 65535[DONE] Config::expand("makefile") CLib::end() and also boot() /usr/share/SimForth/0.1/data[DONE] Conflits between TRACES.ON et WORDS ou -p: broken display[DONE] BUG MAJEUR: token des secondary words. TODO ecrire tests unitaires[DONE] Dictionary::createEntry() strlen("FOO") + 1. The +1 is error proneReplace Glib::Module by my own lib to break the dependence with GTK+[DONE] BUG MAJEUR Code field peut ne pas etre aligné correctement[DONE] BUG stream EOL[DONE] BUG "\ foo" a la fin d'un fichier => Failed opening 'f4.fs'. Reason 'Success'[DONE] Colorful logs[DONE] Regression avec autocompletion.[DONE] C Lib[DONE] Smudge some primitives (EXIT ...)[DONE] Display dico 4 par 4 mots + display literals in the current base[DONE] broken dico display: smudge words, additional columns with literals, show memory after EXIT[DONE] Display stack toujours en hexa[DONE] Faire trace word(pour le moment verbose)[DONE] Mettre les primitives dans le bon ordre (s'inspirer de 4th ?)[DONE] : FOO 1 2 et ; manquant => pas d'erreur[DONE] Data Stack est toujours affichee en hexa[DONE] Better stack underflow with words . DUP OVER. Check data stack underflow and display which words produced the error[WONT DO] Clear to 0 stack canaries zone for Stack::reset() ?Because of stack overflow checks[DONE] ./build/SimForth -f core/System/Core.fth -i + faire une erreur ca part en boucle infinie [ERROR] from core/System/Core.fth:83:0: Failed opening 'core/System/Core.fth'. Reason 'Success'