Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for constructors and destructors #412

Merged
merged 20 commits into from
Nov 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
circumvent windows snprintf warning; provisions for optional 'void' f…
…un return type
gewang committed Nov 14, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 926bef2e2d48b6c235fa292ff559564345614985
11 changes: 6 additions & 5 deletions examples/oper/oper_post_inc.ck
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// i++ - doesn't fully work yet (1.2.0.1)
// post increment operator

// starting value
4 => int i;
// assign, then increment i
i++ => int j;

<<<"printing i, then j">>>;
<<<i>>>;
<<<j>>>;
if ( i == 5 && j == 4) <<<"success">>>;
// print (i should be 1 higher than j)
<<< i >>>;
<<< j >>>;
3 changes: 2 additions & 1 deletion src/core/chuck_absyn.cpp
Original file line number Diff line number Diff line change
@@ -795,7 +795,8 @@ a_Func_Def new_func_def( ae_Keyword func_decl, ae_Keyword static_decl,
sizeof( struct a_Func_Def_ ) );
a->func_decl = func_decl;
a->static_decl = static_decl;
a->type_decl = type_decl;
// substitute if NULL | 1.5.1.9 (ge) for constructors
a->type_decl = type_decl ? type_decl : new_type_decl(new_id_list("void",0,0),0,0,0);
a->name = insert_symbol( name );
a->arg_list = arg_list;
a->s_type = ae_func_user;
2 changes: 1 addition & 1 deletion src/core/chuck_instr.cpp
Original file line number Diff line number Diff line change
@@ -4261,7 +4261,7 @@ void Chuck_Instr_Pre_Constructor::execute( Chuck_VM * vm, Chuck_VM_Shred * shred
const char * Chuck_Instr_Pre_Constructor::params() const
{
static char buffer[CK_PRINT_BUF_LENGTH];
snprintf( buffer, CK_PRINT_BUF_LENGTH, "ctor='%s', offset=%lu", pre_ctor ? pre_ctor->name.c_str() : "[null]", stack_offset );
snprintf( buffer, CK_PRINT_BUF_LENGTH, "ctor='%s', offset=%lu", pre_ctor ? pre_ctor->name.c_str() : "[null]", (unsigned long)stack_offset );
return buffer;
}