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

[WIP] chnget/chnset variants for structs #1666

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions Engine/csound_orc_optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ static inline int same_type(char *var, char ty)
}
*/


#define PARSER_DEBUG1 (0)
#define PARSER_DEBUG1 (0)
//static TREE* remove_excess_assigns(CSOUND *csound, TREE* root)
//{
// TREE* current = root;
Expand Down Expand Up @@ -385,7 +384,7 @@ TREE* constant_fold(CSOUND *csound, TREE* root)
}
break;
case S_UMINUS:
case S_UPLUS:
case S_UPLUS:
case '~':
//print_tree(csound, "Folding case?\n", current);
current->right = constant_fold(csound, current->right);
Expand All @@ -405,7 +404,7 @@ TREE* constant_fold(CSOUND *csound, TREE* root)
lval = (MYFLT)(~(int)lval);
break;
case S_UPLUS:
break;
break;
}
current->value = current->right->value;
current->type = NUMBER_TOKEN;
Expand Down Expand Up @@ -443,4 +442,3 @@ TREE * csound_orc_optimize(CSOUND *csound, TREE *root)
return original;
// return remove_excess_assigns(csound,original);
}

8 changes: 4 additions & 4 deletions Engine/csound_orc_semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ char* get_expression_opcode_type(CSOUND* csound, TREE* tree) {
case S_UMINUS:
return "##mul";
case S_UPLUS:
return "##mul";
return "##mul";
case '|':
return "##or";
case '&':
Expand Down Expand Up @@ -2100,7 +2100,7 @@ void initializeStructVar(CSOUND* csound, CS_VARIABLE* var, MYFLT* mem) {
CONS_CELL* members = type->members;
int len = cs_cons_length(members);
int i;

printf("var type0 %p \n", type);
structVar->members = csound->Calloc(csound, len * sizeof(CS_VAR_MEM*));

// csound->Message(csound, "Initializing Struct...\n");
Expand Down Expand Up @@ -2948,7 +2948,7 @@ void print_tree_i(CSOUND *csound, TREE *l, int n)
l->line, csound->filedir[(l->locn)&0xff]); break;
case S_UPLUS:
csound->Message(csound,"S_UPLUS:(%d:%s)\n",
l->line, csound->filedir[(l->locn)&0xff]); break;
l->line, csound->filedir[(l->locn)&0xff]); break;
case '[':
csound->Message(csound,"[:(%d:%s)\n",
l->line, csound->filedir[(l->locn)&0xff]); break;
Expand Down Expand Up @@ -3096,7 +3096,7 @@ static void print_tree_xml(CSOUND *csound, TREE *l, int n, int which)
csound->Message(csound,"name=\"S_UMINUS\""); break;
case S_UPLUS:
csound->Message(csound,"name=\"S_UPLUS\""); break;

case UDO_TOKEN:
csound->Message(csound,"name=\"UDO_TOKEN\""); break;
case UDO_ANS_TOKEN:
Expand Down
9 changes: 5 additions & 4 deletions Engine/entry1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,9 @@ OENTRY opcodlst_1[] = {
{ "loop_le.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_le_p, NULL },
{ "loop_gt.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_g_p, NULL },
{ "loop_ge.k", S(LOOP_OPS),0, 2, "", "kkkl", NULL, (SUBR) loop_ge_p, NULL },
{ "chnget", 0xFFFF, _CR },
{ "chnget.i", S(CHNGET),_CR, 1, "i", "S",
{ "chnget", S(CHNGET), _CR, 1, ".", "S",
(SUBR) chnget_opcode_init_struct, NULL, NULL },
{ "chnget.i", S(CHNGET), _CR, 1, "i", "S",
(SUBR) chnget_opcode_init_i, NULL, NULL },
{ "chnget.k", S(CHNGET),_CR, 3, "k", "S",
(SUBR) chnget_opcode_init_k, (SUBR) notinit_opcode_stub, NULL },
Expand All @@ -1127,8 +1128,8 @@ OENTRY opcodlst_1[] = {
(SUBR) chnget_opcode_init_S, (SUBR) chnget_opcode_perf_S, NULL},
{ "chngetks", S(CHNGET),_CR, 2, "S", "S",
NULL, (SUBR) chnget_opcode_perf_S, NULL},
//{ "chnset", 0xFFFB, _CW },

{ "chnset", S(CHNGETSTRUCT), _CW, 1, "", ".S",
(SUBR) chnset_opcode_init_struct, NULL, NULL },
{ "chnseti.i", S(CHNGET),_CW, 1, "", "i[]S[]",
(SUBR) chnset_array_opcode_init_i, NULL, NULL },
{ "chnsetk.k", S(CHNGET),_CW, 3, "", "k[]S[]",
Expand Down
8 changes: 4 additions & 4 deletions Engine/insert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ void free_instr_var_memory(CSOUND* csound, INSDS* ip) {
return;
}


while (current != NULL) {
CS_TYPE* varType = current->varType;
if (varType->freeVariableMemory != NULL) {
Expand Down Expand Up @@ -1454,7 +1454,7 @@ int useropcdset(CSOUND *csound, UOPCODE *p)
return csound->InitError(csound, Str("Cannot find instr %d (UDO %s)\n"),
instno, inm->name);
/* set local ksmps if defined by user */
/* VL: 9.2.22 we are disabling this unused and confusing feature of
/* VL: 9.2.22 we are disabling this unused and confusing feature of
a hidden local sampling rate parameter on 7.x */
/*
n = p->OUTOCOUNT + p->INCOUNT - 1;
Expand All @@ -1466,10 +1466,10 @@ int useropcdset(CSOUND *csound, UOPCODE *p)
inm->name, i);
}
local_ksmps = i;
}
}
*/
n = p->OUTOCOUNT + p->INCOUNT - 1;


if (!p->ip) {

Expand Down
12 changes: 12 additions & 0 deletions H/bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ typedef struct {
char chname[MAX_CHAN_NAME+1];
} CHNGETARRAY;

typedef struct {
OPDS h;
CSOUND_STRUCT *s;
STRINGDAT *iname;
MYFLT *fp;
spin_lock_t *lock;
int32_t pos;
char chname[MAX_CHAN_NAME+1];
} CHNGETSTRUCT;

typedef struct {
OPDS h;
STRINGDAT *iname[MAX_CHAN_NAME+1];
Expand Down Expand Up @@ -182,11 +192,13 @@ int32_t chnset_array_opcode_perf_a(CSOUND *csound, CHNGETARRAY *p);
int32_t chnset_array_opcode_perf_S(CSOUND *csound, CHNGETARRAY *p);

int32_t notinit_opcode_stub(CSOUND *, void *);
int32_t chnget_opcode_init_struct (CSOUND *, CHNGETSTRUCT *);
int32_t chnget_opcode_init_i(CSOUND *, CHNGET *);
int32_t chnget_opcode_init_k(CSOUND *, CHNGET *);
int32_t chnget_opcode_init_a(CSOUND *, CHNGET *);
int32_t chnget_opcode_init_S(CSOUND *, CHNGET *);
int32_t chnget_opcode_perf_S(CSOUND *, CHNGET *);
int32_t chnset_opcode_init_struct(CSOUND *, CHNGETSTRUCT *);
int32_t chnset_opcode_init_i(CSOUND *, CHNGET *);
int32_t chnset_opcode_init_k(CSOUND *, CHNGET *);
int32_t chnset_opcode_init_a(CSOUND *, CHNGET *);
Expand Down