Giter Club home page Giter Club logo

gaijinentertainment / dascript Goto Github PK

View Code? Open in Web Editor NEW
797.0 23.0 93.0 83.64 MB

daScript - high-performance statically strong typed scripting language

Home Page: https://daScript.org

License: BSD 3-Clause "New" or "Revised" License

C++ 27.71% CMake 0.29% Shell 0.02% Batchfile 0.01% C 67.99% CSS 0.06% HTML 3.77% Objective-C++ 0.02% SourcePawn 0.07% JavaScript 0.02% Python 0.04%
programming-language scripting-language interpreter game-development static-typing

dascript's People

Contributors

alohaeee avatar andreipotapov avatar antonyudintsev avatar aviktorov avatar boddiul avatar borisbat avatar codeinnovation avatar dmi7ry avatar dmitrinosov avatar einzich avatar hartwork avatar imp5imp5 avatar jacereda avatar jcunningham10 avatar lamapalooza avatar manisandro avatar mtsart avatar nicsavichev avatar olegus8 avatar otakubeam avatar profelis avatar raojm avatar reoil avatar repr-man avatar sattvik avatar songweijia avatar szvyagin-gj avatar tinaynox avatar virt00l avatar wurunduk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dascript's Issues

var declaration outside of function

Why do vars, when declared outside of a function, need a carriage return, so the variable is on the line below the "var" statement? This keeps tripping me up, and personally I wish it were not the case. :-)

e.g. from the pathtracer example

var
RAND_SEED : int4

Whereas within a function, one can write var a:int without any problems.

Does not compile using c++ 17 on msvc

Adding this for visibility: #77 already discusses it, but seems that the fix provided at the time is no longer correct and possibly just a fluke on MSVC compiler or testing setup.

I think changes made by this issue should be reverted as that it was what I had to do to get it to compile and also @thagberg reported having to do the same to get it to compile recently.

How to build under msvs2019

I open daScript project as an cmake folder in msvs2019, but failed to build with an error:
[1/305] cmd.exe /C "cd /D E:\gitroot\g3\g3server\libezgws\daScript\src\builtin && XXD_BIN-NOTFOUND -i fio.das fio.das.inc"
FAILED: ../../../daScript/src/builtin/fio.das.inc
cmd.exe /C "cd /D E:\gitroot\g3\g3server\libezgws\daScript\src\builtin && XXD_BIN-NOTFOUND -i fio.das fio.das.inc"
'XXD_BIN-NOTFOUND' is not a command or executable program.

Wrong string representation/print for fixed size arrays

The following code

let
    N = 2

var 
    a : float[N][N]

[export]
def main
    print("{a}\n")
    return true

should print:
[[ [[ 0; 0]]; [[ 0; 0]] ]]

but instead prints twice as many elements:
[[ [[ 0; 0]]; [[ 0; 0]]; [[ 0; 0]]; [[ 0; 2.10195e-44]]]]

This is a problem for debugging that relies a lot on print()

C++ destructors and/or shared pointers/reference counting?

I've been trying to get daScript to handle shared pointers and destructors with C++ types without success, and I'm not sure if the documentation covers whether this is possible. The section on finalizers and classes does mention that I can't really rely on them being called, but I'm not sure if that also applies to C++ types or if I'm just doing something wrong. The root of the issue is that my C++ destructors are ignored, and I can't get daScript to call them with any combination of annotation overrides, or detect it with any simulate* events. Similarly, anything that wraps types with shared pointers cause them to leak if I pass them to a script.

Simplified example of what I'm trying to do, gen and map being exposed C++ types and the functions that create them similar to the one in your tutorial03.cpp:

[export]
def left_click()
   // wraps a type from a library that use shared pointers internally, and they leak if I do this
   var gen = create_noise_generator(some_settings);
   
   for x in range(some_large_number)
      for y in range(some_large_number)
          // may handle a very large array, so need to be deallocated between each iteration
          var map = create_noise_map(gen,x,y)

For things like gen, I can just let the host manage references and deallocate everything after the script is done, but for things like map the application may run out of memory long before that. Do I need to provide manual deallocator functions for situations like that?

double floating point postfix is different in the code and in the docs

in the documentation double floating point literals are described with "d" postfix. i.e. 0.0d
but in the code it causes a compilation error.
the code compiles only with "lf" posfix. i.e. 0.0lf

link to docs: daScript Reference Manual Release 0.2 beta
https://dascript.org/doc/dascript.pdf

In my opinion d postfix has better readability.
for example 0.0lf reminds me 0.01f. also "lf" consists of 2 characters instead of one. more typing.

Is it possible to make dascript auto promote / convert types

Hi again,

I have a number of c++ functions which take a number of parameters, some of which are floats, and some ints. I've noticed that dascript is strict with making sure types agree exactly, which of course is as it should be.

However, I would like a way to allow some automatic type conversions (int to float, and vice versa) when interfacing with a c++ function.

For example, if I have a c++ function registered in dascript :

float sum(float a, float v)
{
return a+b;
}

And I call it from dascript like this:
var dist:int
dist=4
tot=sum(3.2,dist)

Is it possible to configure dascript to not complain during compilation, but to cast the variable dist to a float, and pass it to the c++ function?

I could define and register functions with every possible combination of variable types - but the combinatorics could make that difficult, so I was wondering if there was a more elegant way of achieving this.

Thanks a lot for any advice you might have.

Matt

Assert failed while running tutorial02_dasAot

I tried to explore tutorials, I ran generate_msvc_2019.bat and try to compile and run tutorials projects from msvs.

I have some troubles with running tutorial02_dasAotStub. It return error by default, searching file tutorial02.das in daScript root folder (maybe it's some misconfiguration of msvs cmake). When I copy das file to root directory, script found it, but failed with assert:

Module `debugapi` already createdAssertion failed: 0 && "fatal error", file D:\src\daScript\src\ast\ast_module.cpp, line 177

I got same error both if running tutorial02_dasAotStub project from msvs, and also if just execute command line:
>tutorial02_dasAot -aot tutorial2.das tutorial2.das.cpp

Looks like it really define modules twice:
https://github.com/GaijinEntertainment/daScript/blob/master/examples/tutorial/tutorial02_dasaot.cpp#L9
And:
https://github.com/GaijinEntertainment/daScript/blob/master/utils/daScript/main.cpp#L211

Is it bug, or I did something wrong while configuring solution?

Is it possible to config aot about required modules? Also, looks like it try to require StbImage modules by default by generating file external_need.inc with content:

NEED_MODULE(Module_StbImage);
NEED_MODULE(Module_StbTrueType);

failed to build: free(): invalid pointer

Here's the make command's output:

[  0%] Building CXX object CMakeFiles/libDasModuleStbImage.dir/modules/dasStbImage/src/dasStbImage.cpp.o
[  0%] Linking CXX static library liblibDasModuleStbImage.a
[  0%] Built target libDasModuleStbImage
[  0%] Building CXX object CMakeFiles/libDasModuleStbTrueType.dir/modules/dasStbTrueType/src/dasStbTrueType.cpp.o
[  0%] Linking CXX static library liblibDasModuleStbTrueType.a
[  0%] Built target libDasModuleStbTrueType
[  0%] Building CXX object CMakeFiles/libDasModuleStdDlg.dir/modules/dasStdDlg/src/dasStdDlg.cpp.o
[  1%] Building CXX object CMakeFiles/libDasModuleStdDlg.dir/modules/dasStdDlg/src/dasStdDlgNotImplemented.cpp.o
[  1%] Linking CXX static library liblibDasModuleStdDlg.a
[  1%] Built target libDasModuleStdDlg
[  2%] Generating include/modules/external_need.inc
[  2%] Generating include/modules/external_resolve.inc
[  2%] Built target need_and_resolve
[  2%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriCommon.c.o
[  2%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriCompare.c.o
[  2%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriEscape.c.o
[  2%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriFile.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriIp4.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriIp4Base.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriNormalize.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriNormalizeBase.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriParse.c.o
[  3%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriParseBase.c.o
[  4%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriQuery.c.o
[  4%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriRecompose.c.o
[  4%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriResolve.c.o
[  4%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriShorten.c.o
[  4%] Building C object CMakeFiles/libUriParser.dir/3rdparty/uriparser/src/UriMemory.c.o
[  4%] Linking C static library liblibUriParser.a
[  4%] Built target libUriParser
[  5%] Built target libDaScript_xxd
[  5%] bison (v 3.8.2) src/parser/ds_parser.ypp to /home/lyh/Documents/CS/projects/cpp/daScript/src/parser/ds_parser.cpp + /hom
e/lyh/Documents/CS/projects/cpp/daScript/src/parser/ds_parser.hpp + /home/lyh/Documents/CS/projects/cpp/daScript/src/parser/ds_
parser.output
ds_parser.ypp: warning: 29 shift/reduce conflicts [-Wconflicts-sr]
ds_parser.ypp: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
[  5%] Building CXX object CMakeFiles/libDaScript.dir/src/parser/ds_parser.cpp.o
[  5%] Building CXX object CMakeFiles/libDaScript.dir/src/parser/ds_lexer.cpp.o
[  5%] Building CXX object CMakeFiles/libDaScript.dir/src/parser/parser_impl.cpp.o
[  5%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast.cpp.o
[  5%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_allocate_stack.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_annotations.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_aot_cpp.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_block_folding.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_const_folding.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_debug_info_helper.cpp.o
[  6%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_export.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_generate.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_handle.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_infer_type.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_lint.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_match.cpp.o
[  7%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_module.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_parse.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_print.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_simulate.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_tls.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_typedecl.cpp.o
[  8%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_unused.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/ast/ast_visitor.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_array.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_ast.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_ast_adapters.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_ast_annotations.cpp.o
[  9%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_ast_flags.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_das.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_dasbind.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_debugger.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_fio.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_jobque.cpp.o
[ 10%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_math.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_misc_types.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_network.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_rtti.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_runtime.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_runtime_lockcheck.cpp.o
[ 11%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_runtime_sort.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_string.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_uriparser.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_vector.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_builtin_vector_ctor.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/builtin/module_file_access.cpp.o
[ 12%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/daScriptC.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/free_list.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/job_que.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/memory_model.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/string_writer.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/sysos.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/uric.cpp.o
[ 13%] Building CXX object CMakeFiles/libDaScript.dir/src/hal/debug_break.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/hal/performance_time.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/hal/project_specific.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/hal/project_specific_file_info.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/misc/network.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/bin_serializer.cpp.o
[ 14%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/data_walker.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/debug_info.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/debug_print.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/fs_file_info.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/hash.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/heap.cpp.o
[ 15%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/runtime_array.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/runtime_profile.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/runtime_range.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/runtime_string.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/runtime_table.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate.cpp.o
[ 16%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fn_hash.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_gc.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_instrument.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_print.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_tracking.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_visit.cpp.o
[ 17%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_at.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_at_array.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_call1.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_call2.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_if.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_misc_copy.cpp.o
[ 18%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op1.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op1_return.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_bin.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_bin_vec.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_bool.cpp.o
[ 19%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_bool_vec.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_scalar_vec.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_set.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_set_vec.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_op2_vec.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simulate/simulate_fusion_ptrfdr.cpp.o
[ 20%] Building CXX object CMakeFiles/libDaScript.dir/src/simul
ate/simulate_fusion_tableindex.cpp.o
[ 21%] Linking CXX static library liblibDaScript.a
[ 23%] Built target libDaScript
[ 23%] Building CXX object CMakeFiles/libDaScriptProfile.dir/examples/profile/test_profile.cpp.o
[ 23%] Linking CXX static library liblibDaScriptProfile.a
[ 23%] Built target libDaScriptProfile
[ 23%] Built target libDaScriptTest_xxd
[ 23%] Building CXX object CMakeFiles/libDaScriptTest.dir/examples/test/test_handles.cpp.o
[ 23%] Building CXX object CMakeFiles/libDaScriptTest.dir/examples/test/test_enum.cpp.o
[ 24%] Linking CXX static library liblibDaScriptTest.a
[ 24%] Built target libDaScriptTest
[ 24%] Building CXX object CMakeFiles/daScript.dir/utils/daScript/main.cpp.o
[ 24%] Linking CXX executable bin/daScript
[ 24%] Built target daScript
[ 24%] AOT precompiling /home/lyh/Documents/CS/projects/cpp/daScript/examples/test/unit_tests/_a.das -> /home/lyh/Documents/CS/
projects/cpp/daScript/examples/test/unit_tests/_aot_generated/_a.das.cpp
saving to /home/lyh/Documents/CS/projects/cpp/daScript/examples/test/unit_tests/_aot_generated/_a.das.cpp
free(): invalid pointer
make[2]: *** [CMakeFiles/daScriptTestAot_0_aot.dir/build.make:83: examples/test/unit_tests/_aot_generated/_a.das.cpp] Aborted (
core dumped)
make[2]: *** Deleting file 'examples/test/unit_tests/_aot_generated/_a.das.cpp'
make[1]: *** [CMakeFiles/Makefile2:735: CMakeFiles/daScriptTestAot_0_aot.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
⏎

addExtern<DAS_BIND_MEMBER_FUN example

Hi!
Please, help me figure out the proper code for exposing a member function. I didn't find an example in your codebase.
I have a hierarchy similar below:

class MainClass {
    class SubClass  : public das::Module {
        FuncName(){}
        SubClass() : Module("moduleName")
            ....
            addExtern<DAS_BIND_MEMBER_FUN(FuncName)>(*this, lib, "FuncName", das::SideEffects::none, "FuncName");
            ...
    }
}

It spams errors. I tried to change it, but nothing helped.

how can I get a pointer of an array?

[export]
def main
    var tc = new array<int>


 .code.tio:7:13:
     var tc = new array<int>             ^^^
 13:7 - 15:7

30109: can only new tuples, variants, structures or handled types, not array<int>

P.S.
"Arrays can not be copied, only cloned or moved."
why does the doc say that?

Functions in ManagedStructureAnnotation

Hi!

I've been evaluating daScript as a possible fit for my game engine and so far it's been really amazing. Only thing I can't seem to find examples of (if it is actually possible) is how to bind functions to a ManagedStructureAnnotation.

What I am trying to do is expose, lets say the Entity class via an annotation (which I already can do) and add functions to it so that I can have Entity.Function() syntax, rather than having to expose a global function that takes the entity as a parameter to call the correct function inside the class.

Any help would be greatly appreciated!
Keep up the great work.

Cheers

Can there be an explination in the doc on how to install and execute scripts.

As it stands, on arch linux, after building, I am way too in the weeds to understand how to get it to work and, trying to figure it out isn't justifying the time. I don't think it would be very hard to do some bash scripting; hell, if you explain it to me I'll write the bash script that compiles and install the scripts.

Missing check in AOT for conflicting enum names

In path tracer example change no_aot to false, generated code wont work because there are 2 enums called type, one from dascript and one from debug_info.h

Workaround: change all occurrences of type in dascript to typer(or anything)

It would be nice to scramble the enum names from dascript.

Init parameters reflection

Hi, I'm working getting the default initialization parameters from the scripts.
I've managed to make it work for aliased and builtin data types, but I can't find a way of getting the value out of custom ones.

For example here:
image
testQuat is a custom type that has an inplace constructor which generates this SimNode:
image
I have been looking to no avail how to properly simulate the constructor to get the data as a vec4f.

Any help will be greatly appreciated.

PD: I know I can probably alias the quaternion as a float4, but it would be good to know the proper approach as I will be adding more data types in the future. Thanks!

about live

I am trying the live library for hot reloading, but I found that the data is lost during runtime after reloading, how can I solve this problem, thank you.

Array initialization issues

  1. The documentation (https://dascript.org/doc/reference/language/expressions.html?highlight=initalization) in 2.4.4. gives a , syntax for array initalization (leading to a syntax error) but 2.6 uses ;. Therefore d = [[int[] 1, 2]] // creates array of two elements as provided as example in 2.4 does not work

  2. Could you please provide an example for a multidimensional array initialization? (no example can be found in the documentation). The following do not work.
    var arr : float[2][2] = [[ float[2] [1.; 2.]; [3.; 4.] ]] // does not work
    var arr : float[2][2] = [[ float [1.; 2.]; [3.; 4.] ]] // doesn't work either

generate_xcode.sh fails

cmake version: 3.19.3
xcode version: 12.5.1
dascript commit: 48495ac (7/9/2021)

-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found BISON: /usr/bin/bison (found version "2.3") 
-- Found FLEX: /usr/bin/flex (found version "2.5.35") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- dasStdDlg module included.
-- dasGenForEach module not found. Pre-generated files will be used.
-- Configuring done
-- Generating done
CMake Error in CMakeLists.txt:
  The custom command generating

    /Users/stephen/daScript/include/modules/external_resolve.inc

  is attached to multiple targets:

    libDaScript
    need_and_resolve

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".


CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE


CMake Generate step failed.  Build files cannot be regenerated correctly.

real	0m10.176s
user	0m3.450s
sys	0m1.717s

Auto exporting of dascript functions

Is there a way to make a dascript function visible from C code, without needing the [export] line? Perhaps an option to make all functions visible by default?

Error building daScript on CentOS

Hi,
I wanted to give daScript a try and was attempting to compile it on CentOS with gcc 7.3.0 but got the following error:

[ 26%] Built target libDaScriptJson
Scanning dependencies of target jsonTest
[ 26%] Building CXX object CMakeFiles/jsonTest.dir/examples/json/main.cpp.o
/env/ig/soft/ig/gcc-7.3.0/el6-x86_64-generic/bin/ld: liblibDaScript.a(performance_time.cpp.o): undefined reference to symbol 'clock_gettime@@GLIBC_2.2.5'
/env/ig/soft/ig/gcc-7.3.0/el6-x86_64-generic/bin/ld: /lib64/librt.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [curlTest] Erreur 1
make[1]: *** [CMakeFiles/curlTest.dir/all] Erreur 2
make[1]: *** Attente des tΓ’ches non terminΓ©es....
[ 26%] Linking CXX static library liblibDaScriptProfile.a
[ 26%] Built target libDaScriptProfile
[ 27%] Linking CXX static library liblibDaScriptTest.a
[ 27%] Built target libDaScriptTest
[ 28%] Linking CXX executable jsonTest
/env/ig/soft/ig/gcc-7.3.0/el6-x86_64-generic/bin/ld: liblibDaScript.a(performance_time.cpp.o): in function `ref_time_ticks':
performance_time.cpp:(.text+0x15): undefined reference to `clock_gettime'
collect2: error: ld returned 1 exit status
make[2]: *** [jsonTest] Erreur 1
make[1]: *** [CMakeFiles/jsonTest.dir/all] Erreur 2
make: *** [all] Erreur 2
srun: error: etna59: task 0: Exited with exit code 2

Do you think the error comes from my side or would that be something you can fix?

calling a function with default parameters breaks compilation

Hi! The code below cases a compile error

class TestClass
def Test(i : int = -1) : int
return -1

[export]
def main
var tc = new TestClass()
let i : int = tc->Test()

.code.tio:8:20:
let i : int = tc->Test()
^^
20:8 - 21:8
30301: casting to undefined type auto

I suppose tc->Test() should be compiled fine because Test function has a default parameter -1

Some submodules require configure ssh key

https://github.com/GaijinEntertainment/daScript/blob/master/.gitmodules
НС знаю, тянСт Π»ΠΈ Π½Π° issue, Π½ΠΎ Ρ‡Π°ΡΡ‚ΡŒ сабмодулСй Π΄ΠΎΠ±Π°Π²Π»Π΅Π½Ρ‹ Π² Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Π΅ адрСса https://github.com/borisbat/dasBGFX.git (пуллятся Ρ‡Π΅Ρ€Π΅Π· https), Π΄Ρ€ΡƒΠ³ΠΈΠ΅ - [email protected]:imp5imp5/dasSound.git - Ρ‡Π΅Ρ€Π΅Π· ssh. Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, Ρ‡ΡƒΡ‚ΡŒ Π±ΠΎΠ»Π΅Π΅ ΡƒΠ΄ΠΎΠ±Π½Π΅Π΅ всС Π² ΠΎΠ΄Π½ΠΎΠΌ Π²ΠΈΠ΄Π΅ ΠΏΠ΅Ρ€Π΅Ρ‡ΠΈΡΠ»ΠΈΡ‚ΡŒ

Why so big executable daScript 60MB ?

Hello !
Interesting project !
When I compile through "generate_gcc_release.sh" and striping "bin/daScript" it ends up with 60MB:

-rwxrwxr-x 1 xxxx xxxx 62013056 sep 22 11:20 daScript

It's a strange big executable size for a scripting language, what's the rationale for that ?

Cheers !

How to do garbage collection?

(tl;dr for anyone finding this issue, there is a fix for the string heap below, the other heap did not have gc implemented yet)

Hi again!

We've been looking at trying out the GC features, but I can't seem to get it right and the documentation doesn't say very much about it.

What I'm currently doing:

We use this code to execute functions:

auto fun = ctx->findFunction("left_click");
ctx->eval(fun, nullptr);
ctx->stringHeap->mark();
ctx->stringHeap->sweep();

The extern function we have to allocate strings on your heap:

char const* get_string_param(char const* path, das::Context * ctx)
{
  auto str = get_json_unsafe<std::string>(path);
  return ctx->stringHeap->allocateString(str.c_str(),str.size());
}

The daScript code we use to call it (temporarily worstDefault so it won't be optimized away):

[export]
def left_click()
    get_string_param("some key")

But this is leaking memory, are we doing something wrong? I noticed there was a slightly more involved function with Context#collectStringHeap, but that one doesn't seem to work either.

acces to enum members is very unusual

//For example:
enum TestEnum
First
Second

let a = TestEnum First

why not use symbols like in common languages like Python, C#, C++? I mean "." or "::"
White space resembles nothing even in the daScript language.

why not make the syntax more pythonic?

hi ,i just saw this new language, the cpp mentioned made me want to go away, then i found the code sample which just attract me at once.

i was thinking since its just the begining, if that's not require much change, why not just use the python syntax, like require => import, this will help much more pythoner to use this language, and as i knew, there were many go user who turned from python complains the syntax

Missing simple example

Hello,

I've found that many interesting complex projects (like daScript) normally lack a very simple example to get started, so I hope that can be remedied πŸ˜ƒ. The closest I've found is the code inside examples/test but that's far from simple.

It will be really helpful if an example with only setting up the VM context, running a simple embedded script with print("hello world") or equivalent, then proceeding to shutdown the library is added to either the docs or this repo.

Thanks and keep up the good work!

GCC / C++ 11 compatibility

I tried to compile with GCC 4.8.2 on Ubuntu 14.4 LTS. Since you state on your website "you only need C++11 compiler" this setup should work, but it doesn't.

First of all I had to add the following to CMakeLists.txt:
set (CMAKE_CXX_STANDARD 11)
add_compile_options(-mssse3)

Then I had to replace all make_unique and make_shared in ast.cpp and ast_module.cpp.

Then I had to replace the variadic method template addCall in ast.h line 519 by two versions, one with one and the other with two parameters, because passing the template parameter pack to the innermost constructor (by lambda capture) doesn't seem to work in C++11.

But now I'm stuck because I get hundereds of errors in module_builtin.cpp, see
errors.txt

Would be really great if I could compile it with C++11, but seems like a lot of work to make this happen; or did I miss something?

missing _aligned_msize() for mingw

We met an error when compiling it with mingw. There is no _aligned_msize() function in stdlib.h of mingw.
Is there any plan to support mingw? Or how can I skip this error?

Multiline code

Is there a way to continue a line of code from a new line? Did not find anything in the documentation and examples
Something like:

>>> 1 + \
... 2

in python

verifyCall with string return types

I got a das file like this:

[export]
def title(): string
    return "Noise Brush";

Then in C++:

if(!verifyCall<const char*>(title_fun->debugInfo,dummyLibGroup));
{
    get_cur_tool()->addLog("Incorrect title type!");
    break;
}

This check always fails. Tried every combination of char* pointers and das::string but it doesn't seem to accept anything. Could only find examples of primitive types with verifyCall in your repo and the docs, so I might've missed something. Reading the result still works fine:

auto result = cast<const char*>::to(ctx.eval(title_fun));

Returning multiple items from c++ function to dascript

Is dascript able to return multiple variables from a c++ function, back into script? Something along the lines of:

[length,colour,angle] = docalc()

Where docalc() is a c++ function registered to be callable from dascript

Thanks for your help

Matt

Can't run scripts with compiled 'daScript' executable on linux.

So, i did my very best to figure this out, but since there is no installation readme I'm blind, in a dark maze.

I did this


`git clone https://github.com/GaijinEntertainment/daScript/


cd daScript


chmod a+xgenerate_gcc_linux.sh ((for some reason only some scripts are marked 

executable, please fix))

sudo ./generate_gcc_linux.sh

cd cmake_temp

make -i`

it compiles to /bin/ but any script i run in /example/Test usually returns a main error; which is a C issue? and if it isn't why do the scripts provided by the git have syntax errors...

Can you post an article about memory management in daScript

I think daScript is a great script language with modern features , and it works seamlessly with c++, I am trying to adopt it in my game.

But I have some questions 。Words about memory management in daScript document just one line:
semi-manual memory management:

Can you explain more, or give some rules?
Thank you.

Would you mind publishing some stable versions for some platforms?

daScript is a little complex comparing to lua. So would you mind publishing some stable versions for some main platforms? It could be very helpful for us especially if we don't have some cpu or memory resources or time to compile the engine and libraries totally.

Does it support passing string/blob objects by zero-copy?

Dascript is a performance-oriented scripting language. As we all know, the memory copy and encoding conversion caused by the parameter transfer between Native Code and Script are important factors that slow down the overall performance of the script.

Therefore, does dascript currently support zero-copy transfer of string / blob and other types of parameters between Natvie Code and Script?

AFAIK, AngleScript can support this type of optimization. In AngleScript, the string and blob types used by the script can be implemented by the developer. Therefore, as long as the string and blob types used by developers in Native Code support reference counting and copy-on-write, these parameters can be passed between the script and Native Code in a zero-copy manner.

I wonder if daScript also supports such optimization?

Thanks :-)

Grammar railroad diagram

Using this tool https://www.bottlecaps.de/convert/ (commenting the frist line of ds_parser.ypp) and manually adding the tokens from ds_lexer.lpp we can see a railroad diagram for the grammar in ds_parser.ypp copy and paste the EBNF shown bellow on https://www.bottlecaps.de/rr/ui in the tab Edit Grammar then switching to the tab View Diagram.

/* converted on Sun Jul 11, 2021, 19:42 (UTC+02) by bison-to-w3c v0.51 which is Copyright (c) 2011-2021 by Gunther Rademacher <[email protected]> */

program  ::= ( module_declaration | structure_declaration | enum_declaration | global_let | global_function_declaration | expect_declaration | require_declaration | options_declaration | alias_declaration | variant_alias_declaration | bitfield_alias_declaration | ';' )*
module_declaration
         ::= DAS_MODULE NAME optional_shared
character_sequence
         ::= STRING_CHARACTER+
string_constant
         ::= BEGIN_STRING character_sequence END_STRING
string_builder
         ::= BEGIN_STRING ( character_sequence | BEGIN_STRING_EXPR expr END_STRING_EXPR )* END_STRING
expr_reader
         ::= '%' name_in_namespace STRING_CHARACTER+
options_declaration
         ::= DAS_OPTIONS annotation_argument_list
require_declaration
         ::= DAS_REQUIRE require_module
require_module_name
         ::= NAME ( ( '.' | '/' ) NAME )*
require_module
         ::= require_module_name ( DAS_AS NAME )? is_public_module
is_public_module
         ::= DAS_PUBLIC?
expect_declaration
         ::= DAS_EXPECT expect_error ( ',' expect_error )*
expect_error
         ::= INTEGER ( ':' INTEGER )?
expression_label
         ::= DAS_LABEL INTEGER ':'
expression_goto
         ::= DAS_GOTO ( DAS_LABEL INTEGER | expr )
elif_or_static_elif
         ::= DAS_ELIF
           | DAS_STATIC_ELIF
if_or_static_if
         ::= DAS_IF
           | DAS_STATIC_IF
expression_if_then_else
         ::= if_or_static_if expr expression_block ( elif_or_static_elif expr expression_block )* ( DAS_ELSE expression_block )?
expression_for_loop
         ::= DAS_FOR variable_name_with_pos_list DAS_IN expr_list ';' expression_block
expression_unsafe
         ::= DAS_UNSAFE expression_block
expression_while_loop
         ::= DAS_WHILE expr expression_block
expression_with
         ::= DAS_WITH expr expression_block
annotation_argument_value
         ::= string_constant
           | NAME
           | INTEGER
           | FLOAT
           | DAS_TRUE
           | DAS_FALSE
annotation_argument
         ::= NAME ( '=' ( string_constant | NAME | INTEGER | FLOAT | DAS_TRUE | DAS_FALSE | '(' annotation_argument_value ( ',' annotation_argument_value )* ')' ) )?
annotation_argument_list
         ::= annotation_argument ( ',' annotation_argument )*
annotation_declaration_name
         ::= name_in_namespace
           | DAS_REQUIRE
           | DAS_PRIVATE
annotation_declaration
         ::= annotation_declaration_name ( '(' annotation_argument_list ')' )?
annotation_list
         ::= annotation_declaration ( ',' annotation_declaration )*
optional_annotation_list
         ::= ( '[' annotation_list ']' )?
optional_function_argument_list
         ::= ( '(' ( function_argument_declaration ( ';' function_argument_declaration )* )? ')' )?
optional_function_type
         ::= ( ':' type_declaration )?
function_name
         ::= NAME
           | DAS_OPERATOR ( '!' | '~' | ADDEQU | SUBEQU | MULEQU | DIVEQU | MODEQU | ANDEQU | OREQU | XOREQU | ANDANDEQU | OROREQU | XORXOREQU | ANDAND | OROR | XORXOR | '+' | '-' | '*' | '/' | '%' | '<' | '>' | EQUEQU | NOTEQU | LEEQU | GREQU | '&' | '|' | '^' | ADDADD | SUBSUB | SHL | SHR | SHLEQU | SHREQU | ROTL | ROTR | ROTLEQU | ROTREQU )
           | ( ADDADD | SUBSUB ) DAS_OPERATOR
global_function_declaration
         ::= optional_annotation_list DAS_DEF function_declaration
function_declaration_header
         ::= function_name optional_function_argument_list optional_function_type
function_declaration
         ::= function_declaration_header expression_block
expression_block
         ::= '{' expressions '}' ( DAS_FINALLY '{' expressions '}' )?
expression_any
         ::= ( expr_assign | expression_delete | expression_break | expression_continue | expression_label | expression_goto | DAS_PASS )? ';'
           | expr_pipe
           | expr_assign_pipe
           | expression_let
           | expression_while_loop
           | expression_unsafe
           | expression_with
           | expression_for_loop
           | expression_return
           | expression_yield
           | expression_if_then_else
           | expression_try_catch
expressions
         ::= ( expression_any | error )*
expr_pipe
         ::= ( expr_assign LBPIPE | LAPIPE | LFPIPE ) expr_block
name_in_namespace
         ::= ( NAME? COLCOL )? NAME
expression_delete
         ::= DAS_DELETE expr
expr_new ::= DAS_NEWT ( type_declaration ( '(' expr_list? ')' )? | make_decl )
expression_break
         ::= DAS_BREAK
expression_continue
         ::= DAS_CONTINUE
expression_return
         ::= DAS_RETURN ( expr? ';' | LARROW ( expr ';' | expr_pipe ) | expr_pipe )
expression_yield
         ::= DAS_YIELD LARROW? ( expr ';' | expr_pipe )
expression_try_catch
         ::= DAS_TRY expression_block DAS_CATCH expression_block
kwd_let  ::= DAS_LET
           | DAS_VAR
expression_let
         ::= kwd_let let_variable_declaration
expr_cast
         ::= ( DAS_CAST | DAS_UPCAST | DAS_REINTERPRET ) '<' type_declaration '>' expr
expr_type_decl
         ::= DAS_TYPE '<' type_declaration '>'
expr_type_info
         ::= DAS_TYPEINFO '(' name_in_namespace ( '<' NAME ( ';' NAME )? '>' )? expr ')'
expr_list
         ::= expr ( ',' expr )*
block_or_simple_block
         ::= expression_block
           | MAPTO LARROW? expr
block_or_lambda
         ::= '$'
           | '@' '@'?
capture_entry
         ::= ( '&' | '=' | LARROW | CLONEEQU ) NAME
optional_capture_list
         ::= ( BRABRAB capture_entry ( ',' capture_entry )* ']' ']' )?
expr_block
         ::= expression_block
           | block_or_lambda optional_annotation_list optional_capture_list optional_function_argument_list optional_function_type block_or_simple_block
expr_numeric_const
         ::= INTEGER
           | UNSIGNED_INTEGER
           | LONG_INTEGER
           | UNSIGNED_LONG_INTEGER
           | FLOAT
           | DOUBLE
expr_assign
         ::= expr ( ( '=' | LARROW | CLONEEQU | ANDEQU | OREQU | XOREQU | ANDANDEQU | OROREQU | XORXOREQU | ADDEQU | SUBEQU | MULEQU | DIVEQU | MODEQU | SHLEQU | SHREQU | ROTLEQU | ROTREQU ) expr )?
expr_assign_pipe
         ::= expr ( '=' | LARROW ) ( LAPIPE | LFPIPE ) expr
expr_named_call
         ::= name_in_namespace '(' '[' make_struct_fields ']' ')'
expr_method_call
         ::= expr RARROW NAME '(' expr_list? ')'
func_addr_expr
         ::= '@' '@' ( '<' ( type_declaration | optional_function_argument_list optional_function_type ) '>' )? name_in_namespace
expr_field
         ::= expr '.' ( NAME | error )
expr     ::= DAS_NULL
           | name_in_namespace
           | expr_numeric_const
           | expr_reader
           | string_builder
           | make_decl
           | DAS_TRUE
           | DAS_FALSE
           | expr_field
           | '!' expr
           | '~' expr
           | '+' expr
           | '-' expr
           | expr SHL expr
           | expr SHR expr
           | expr ROTL expr
           | expr ROTR expr
           | expr '+' expr
           | expr '-' expr
           | expr '*' expr
           | expr '/' expr
           | expr '%' expr
           | expr '<' expr
           | expr '>' expr
           | expr EQUEQU expr
           | expr NOTEQU expr
           | expr LEEQU expr
           | expr GREQU expr
           | expr '&' expr
           | expr '|' expr
           | expr '^' expr
           | expr ANDAND expr
           | expr OROR expr
           | expr XORXOR expr
           | ADDADD expr
           | SUBSUB expr
           | expr ADDADD
           | expr SUBSUB
           | '(' expr ')'
           | expr '[' expr ']'
           | expr QBRA expr ']'
           | expr QDOT NAME
           | func_addr_expr
           | name_in_namespace '(' ')'
           | name_in_namespace '(' expr_list ')'
           | basic_type_declaration '(' ')'
           | basic_type_declaration '(' expr_list ')'
           | '*' expr
           | DAS_DEREF '(' expr ')'
           | DAS_ADDR '(' expr ')'
           | DAS_GENERATOR '<' type_declaration '>' optional_capture_list '(' ')'
           | DAS_GENERATOR '<' type_declaration '>' optional_capture_list '(' expr ')'
           | expr QQ expr
           | expr '?' expr ':' expr
           | expr DAS_IS DAS_TYPE '<' type_declaration '>'
           | expr DAS_IS NAME
           | expr DAS_AS NAME
           | expr '?' DAS_AS NAME
           | expr_type_info
           | expr_type_decl
           | expr_cast
           | expr_new
           | expr_method_call
           | expr_named_call
           | expr_block
           | expr LPIPE expr
           | expr RPIPE expr
           | name_in_namespace NAME
optional_field_annotation
         ::= ( BRABRAB annotation_argument_list ']' ']' )?
optional_override
         ::= DAS_OVERRIDE?
structure_variable_declaration
         ::= optional_field_annotation optional_override variable_declaration
function_argument_declaration
         ::= optional_field_annotation DAS_VAR? variable_declaration
tuple_type
         ::= ( NAME ':' )? type_declaration
variant_type
         ::= NAME ':' type_declaration
variant_type_list
         ::= variant_type ( ';' variant_type )*
copy_or_move
         ::= '='
           | LARROW
variable_declaration
         ::= variable_name_with_pos_list ( '&' | ':' type_declaration ( copy_or_move expr )? | copy_or_move ( expr | expr_pipe ) )?
copy_or_move_or_clone
         ::= '='
           | LARROW
           | CLONEEQU
optional_ref
         ::= '&'?
let_variable_declaration
         ::= variable_name_with_pos_list ( ':' type_declaration ( ';' | copy_or_move_or_clone ( expr ';' | expr_pipe ) ) | optional_ref copy_or_move_or_clone ( expr ';' | expr_pipe ) )
optional_shared
         ::= DAS_SHARED?
optional_shared_or_private
         ::= ( DAS_SHARED | DAS_PRIVATE )?
global_let
         ::= kwd_let optional_shared_or_private ( '{' let_variable_declaration* '}' | let_variable_declaration )
enum_list
         ::= ( NAME ( '=' expr )? ';' )*
single_alias
         ::= NAME '=' type_declaration ';'
alias_declaration
         ::= DAS_TYPEDEF '{' single_alias+ '}'
enum_declaration
         ::= DAS_ENUM NAME ( ':' enum_basic_type_declaration )? '{' enum_list '}'
optional_structure_parent
         ::= ( ':' name_in_namespace )?
structure_name
         ::= NAME optional_structure_parent
class_or_struct
         ::= DAS_CLASS
           | DAS_STRUCT
structure_declaration
         ::= optional_annotation_list class_or_struct structure_name '{' ( ( structure_variable_declaration | '[' annotation_list ']' ) ';' | optional_annotation_list DAS_DEF ( DAS_ABSTRACT function_declaration_header ';' | optional_override function_declaration ) )* '}'
variable_name_with_pos_list
         ::= NAME ( ',' NAME )*
basic_type_declaration
         ::= DAS_TBOOL
           | DAS_TSTRING
           | DAS_TINT
           | DAS_TINT8
           | DAS_TINT16
           | DAS_TINT64
           | DAS_TINT2
           | DAS_TINT3
           | DAS_TINT4
           | DAS_TUINT
           | DAS_TUINT8
           | DAS_TUINT16
           | DAS_TUINT64
           | DAS_TUINT2
           | DAS_TUINT3
           | DAS_TUINT4
           | DAS_TFLOAT
           | DAS_TFLOAT2
           | DAS_TFLOAT3
           | DAS_TFLOAT4
           | DAS_TVOID
           | DAS_TRANGE
           | DAS_TURANGE
           | DAS_TDOUBLE
           | DAS_TBITFIELD
enum_basic_type_declaration
         ::= DAS_TINT
           | DAS_TINT8
           | DAS_TINT16
           | DAS_TUINT
           | DAS_TUINT8
           | DAS_TUINT16
structure_type_declaration
         ::= name_in_namespace
auto_type_declaration
         ::= DAS_TAUTO ( '(' NAME ')' )?
bitfield_bits
         ::= NAME ( ';' NAME )*
bitfield_type_declaration
         ::= DAS_TBITFIELD '<' bitfield_bits '>'
type_declaration
         ::= basic_type_declaration
           | auto_type_declaration
           | bitfield_type_declaration
           | structure_type_declaration
           | type_declaration ( '[' expr? ']' | '-' ( '[' ']' | DAS_CONST | '&' | '#' ) | DAS_EXPLICIT | '='? DAS_CONST | '&' | '#' | DAS_IMPLICIT | '?' | QQ )
           | ( ( ( DAS_SMART_PTR | DAS_ARRAY | DAS_ITERATOR ) '<' | DAS_TABLE '<' type_declaration ';' ) type_declaration | DAS_TTUPLE '<' tuple_type ( ';' tuple_type )* | DAS_TVARIANT '<' variant_type_list ) '>'
           | ( DAS_TBLOCK | DAS_TFUNCTION | DAS_TLAMBDA ) ( '<' ( type_declaration | optional_function_argument_list optional_function_type ) '>' )?
variant_alias_declaration
         ::= DAS_TVARIANT NAME '{' variant_type_list ';' '}'
bitfield_alias_declaration
         ::= DAS_TBITFIELD NAME '{' bitfield_bits ';' '}'
make_decl
         ::= make_struct_decl
           | make_dim_decl
           | make_table_decl
           | array_comprehension
make_struct_fields
         ::= NAME ( copy_or_move | CLONEEQU ) expr ( ',' NAME ( copy_or_move | CLONEEQU ) expr )*
make_struct_dim
         ::= make_struct_fields ( ';' make_struct_fields )*
optional_block
         ::= ( DAS_WHERE expr_block )?
make_struct_decl
         ::= ( BRABRAB type_declaration ( '(' ')' )? make_struct_dim? optional_block ']' | BRACBRB type_declaration ( '(' ')' )? make_struct_dim optional_block '}' ) ']'
make_map_tuple
         ::= expr MAPTO expr
make_any_tuple
         ::= expr ( ',' expr )*
           | make_map_tuple
make_dim ::= make_any_tuple ( ';' make_any_tuple )*
make_dim_decl
         ::= ( BRABRAB type_declaration make_dim ']' | BRACBRB type_declaration make_dim '}' ) ']'
make_table_decl
         ::= CBRCBRB make_map_tuple ( ';' make_map_tuple )* '}' '}'
array_comprehension_where
         ::= ( ';' DAS_WHERE expr )?
array_comprehension
         ::= ( BRABRAB DAS_FOR variable_name_with_pos_list DAS_IN expr_list ';' expr array_comprehension_where ']' | BRACBRB DAS_FOR variable_name_with_pos_list DAS_IN expr_list ';' expr array_comprehension_where '}' ) ']'

// Tokens from ds_lexer.lpp

DAS_FOR ::= "for"
DAS_WHILE ::= "while"
DAS_IF ::= "if"
DAS_STATIC_IF ::= "static_if"
DAS_ELIF ::= "elif"
DAS_STATIC_ELIF ::= "static_elif"
DAS_ELSE ::= "else"
DAS_FINALLY ::= "finally"
DAS_DEF ::= "def"
DAS_WITH ::= "with"
DAS_LET ::= "let"
DAS_VAR ::= "var"
DAS_STRUCT ::= "struct"
DAS_CLASS ::= "class"
DAS_ENUM ::= "enum"
DAS_TRY ::= "try"
DAS_CATCH ::= "recover"
DAS_TYPEDEF ::= "typedef"
DAS_LABEL ::= "label"
DAS_GOTO ::= "goto"
DAS_MODULE ::= "module"
DAS_PUBLIC ::= "public"
DAS_OPTIONS ::= "options"
DAS_OPERATOR ::= "operator"
DAS_REQUIRE ::= "require"
DAS_TBLOCK ::= "block"
DAS_TFUNCTION ::= "function"
DAS_TLAMBDA ::= "lambda"
DAS_GENERATOR ::= "generator"
DAS_TTUPLE ::= "tuple"
DAS_TVARIANT ::= "variant"
DAS_CONST ::= "const"
DAS_CONTINUE ::= "continue"
DAS_WHERE ::= "where"
DAS_CAST ::= "cast"
DAS_UPCAST ::= "upcast"
DAS_PASS ::= "pass"
DAS_REINTERPRET ::= "reinterpret"
DAS_OVERRIDE ::= "override"
DAS_ABSTRACT ::= "abstract"
DAS_EXPECT ::= "expect"
DAS_TABLE ::= "table"
DAS_ARRAY ::= "array"
DAS_ITERATOR ::= "iterator"
DAS_IN ::= "in"
DAS_IMPLICIT ::= "implicit"
DAS_EXPLICIT ::= "explicit"
DAS_SHARED ::= "shared"
DAS_PRIVATE ::= "private"
DAS_SMART_PTR ::= "smart_ptr"
DAS_UNSAFE ::= "unsafe"
DAS_AS ::= "as"
DAS_IS ::= "is"
DAS_DEREF ::= "deref"
DAS_ADDR ::= "addr"
DAS_NULL ::= "null"
DAS_RETURN ::= "return"
DAS_YIELD ::= "yield"
DAS_BREAK ::= "break"
DAS_TYPEINFO ::= "typeinfo"
DAS_TYPE ::= "type"
DAS_NEWT ::= "new"
DAS_DELETE ::= "delete"
DAS_TRUE ::= "true"
DAS_FALSE ::= "false"
DAS_TAUTO ::= "auto"
DAS_TBOOL ::= "bool"
DAS_TVOID ::= "void"
DAS_TSTRING ::= "string"
DAS_TRANGE ::= "range"
DAS_TURANGE ::= "urange"
DAS_TINT ::= "int"
DAS_TINT8 ::= "int8"
DAS_TINT16 ::= "int16"
DAS_TINT64 ::= "int64"
DAS_TINT2 ::= "int2"
DAS_TINT3 ::= "int3"
DAS_TINT4 ::= "int4"
DAS_TUINT ::= "uint"
DAS_TBITFIELD ::= "bitfield"
DAS_TUINT8 ::= "uint8"
DAS_TUINT16 ::= "uint16"
DAS_TUINT64 ::= "uint64"
DAS_TUINT2 ::= "uint2"
DAS_TUINT3 ::= "uint3"
DAS_TUINT4 ::= "uint4"
DAS_TDOUBLE ::= "double"
DAS_TFLOAT ::= "float"
DAS_TFLOAT2 ::= "float2"
DAS_TFLOAT3 ::= "float3"
DAS_TFLOAT4 ::= "float4"

COLCOL ::= "::"
RPIPE ::= "|>"
LBPIPE ::= "<|["
LAPIPE ::= "@<|"
QQ ::= "??"
QBRA ::= "?["

QDOT ::= "?."
CLONEEQU ::= ":="
RARROW ::= "->"
LARROW ::= "<-"
ADDEQU ::= "+="
SUBEQU ::= "-="
DIVEQU ::= "/="
MULEQU ::= "*="
MODEQU ::= "%="
ANDANDEQU ::= "&&="
OROREQU ::= "||="
XORXOREQU ::= "^^="
ANDAND ::= "&&"
OROR ::= "||"
XORXOR ::= "^^"
ANDEQU ::= "&="
OREQU ::= "|="
XOREQU ::= "^="
ADDADD ::= "++"
SUBSUB ::= "--"
LEEQU ::= "<="
GREQU ::= ">="
EQUEQU ::= "=="
NOTEQU ::= "!="
ROTR ::= ">>>"
SHR ::= ">>"
ROTL ::= "<<<"
SHL ::= "<<"
SHREQU ::= ">>="
SHLEQU ::= "<<="
ROTREQU ::= ">>>="
ROTLEQU ::= "<<<="
MAPTO ::= "=>"
BRABRAB ::= "[["
BRACBRB ::= "[{"
CBRCBRB ::= "{{"

err = das_yyparse(); // TODO: add mutex or make thread safe?

I run a simple example and it worked very well until it wasn't run concurrently. Then I put the code below into threads and fired them simultaneously, the program started crashing all the way.
there is the code below I borrowed from an example:

	NEED_ALL_DEFAULT_MODULES;
	NEED_MODULE(Module_Tutorial02);
	das::Module::Initialize();	
	// run the tutorial
	das::ModuleGroup dummyLibGroup;                      // module group for compiled program
	auto fAccess = das::make_smart<das::FsFileAccess>();      // default file access
	// compile program
	#define TUTORIAL_NAME   "test.das"
	program = compileDaScript(das::getDasRoot() + "/" + TUTORIAL_NAME, fAccess, tout, dummyLibGroup);
	...

Looking up the call stack I found one interesting line:
err = das_yyparse(); // TODO: add mutex or make thread safe?
it's from ast_parse.cpp and it's still in the recent branch.

may it be a reason for those crashes?
Is it possible to use daScript concurrently for now?

Mac build doesn't seem to work.

The last OS mentioned was 10.12 in the generate_xcode. I'm on 10.15.

Do I need a particular version of Xcode to make the build? I'm getting errors on the func usage, which is a reserved word. It shouldn't be used as a variable.

In file included from daScript/src/builtin/module_builtin_debugger.cpp:43:
daScript/src/builtin/debugapi_gen.inc:151:81: error: expected ')'
static __forceinline bool invoke_canVisitHandle ( Context * context, Func func, void * self, void * const ps, TypeInfo const & ti ) {
^
daScript/src/builtin/debugapi_gen.inc:151:51: note: to match this '('
static __forceinline bool invoke_canVisitHandle ( Context * context, Func func, void * self, void * const ps, TypeInfo const & ti ) {
^
daScript/src/builtin/debugapi_gen.inc:160:84: error: expected ')'
static __forceinline bool invoke_canVisitStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:160:54: note: to match this '('
static __forceinline bool invoke_canVisitStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:169:82: error: expected ')'
static __forceinline void invoke_beforeStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:169:52: note: to match this '('
static __forceinline void invoke_beforeStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:178:81: error: expected ')'
static __forceinline void invoke_afterStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:178:51: note: to match this '('
static __forceinline void invoke_afterStructure ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {
^
daScript/src/builtin/debugapi_gen.inc:187:87: error: expected ')'
static __forceinline void invoke_afterStructureCancel ( Context * context, Func func, void * self, void * const ps, StructInfo const & si ) {Func

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.