/[svn]/linuxsampler/trunk/src/scriptvm/parser.y
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/parser.y

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3556 by schoenebeck, Sat Jul 15 16:24:59 2017 UTC revision 3557 by schoenebeck, Sun Aug 18 00:06:04 2019 UTC
# Line 229  statement: Line 229  statement:
229                  PARSE_WRN(@2, (String("Variable '") + name + "' declared as string, integer expression assigned though.").c_str());                  PARSE_WRN(@2, (String("Variable '") + name + "' declared as string, integer expression assigned though.").c_str());
230              IntExprRef expr = $4;              IntExprRef expr = $4;
231              if (expr->isConstExpr()) {              if (expr->isConstExpr()) {
232                  const int i = expr->evalInt();                  const vmint i = expr->evalInt();
233                  IntVariableRef var = new IntVariable(context);                  IntVariableRef var = new IntVariable(context);
234                  context->vartable[name] = var;                  context->vartable[name] = var;
235                  $$ = new Assignment(var, new IntLiteral(i));                  $$ = new Assignment(var, new IntLiteral(i));
# Line 254  statement: Line 254  statement:
254              $$ = new FunctionCall("nothing", new Args, NULL); // whatever              $$ = new FunctionCall("nothing", new Args, NULL); // whatever
255          } else {          } else {
256              IntExprRef expr = $4;              IntExprRef expr = $4;
257              int size = expr->evalInt();              vmint size = expr->evalInt();
258              if (size <= 0) {              if (size <= 0) {
259                  PARSE_ERR(@4, (String("Array variable '") + name + "' declared with array size " + ToString(size) + ".").c_str());                  PARSE_ERR(@4, (String("Array variable '") + name + "' declared with array size " + ToString(size) + ".").c_str());
260                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever
# Line 278  statement: Line 278  statement:
278          } else {          } else {
279              IntExprRef sizeExpr = $4;              IntExprRef sizeExpr = $4;
280              ArgsRef args = $8;              ArgsRef args = $8;
281              int size = sizeExpr->evalInt();              vmint size = sizeExpr->evalInt();
282              if (size <= 0) {              if (size <= 0) {
283                  PARSE_ERR(@4, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());                  PARSE_ERR(@4, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());
284                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever
# Line 290  statement: Line 290  statement:
290                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever                            $$ = new FunctionCall("nothing", new Args, NULL); // whatever          
291              } else {              } else {
292                  bool argsOK = true;                  bool argsOK = true;
293                  for (int i = 0; i < args->argsCount(); ++i) {                  for (vmint i = 0; i < args->argsCount(); ++i) {
294                      if (args->arg(i)->exprType() != INT_EXPR) {                      if (args->arg(i)->exprType() != INT_EXPR) {
295                          PARSE_ERR(                          PARSE_ERR(
296                              @8,                              @8,
# Line 324  statement: Line 324  statement:
324          } else {          } else {
325              IntExprRef sizeExpr = $5;              IntExprRef sizeExpr = $5;
326              ArgsRef args = $9;              ArgsRef args = $9;
327              int size = sizeExpr->evalInt();              vmint size = sizeExpr->evalInt();
328              if (size <= 0) {              if (size <= 0) {
329                  PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());                  PARSE_ERR(@5, (String("Array variable '") + name + "' must be declared with positive array size.").c_str());
330                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever
# Line 336  statement: Line 336  statement:
336                  $$ = new FunctionCall("nothing", new Args, NULL); // whatever                            $$ = new FunctionCall("nothing", new Args, NULL); // whatever          
337              } else {              } else {
338                  bool argsOK = true;                  bool argsOK = true;
339                  for (int i = 0; i < args->argsCount(); ++i) {                  for (vmint i = 0; i < args->argsCount(); ++i) {
340                      if (args->arg(i)->exprType() != INT_EXPR) {                      if (args->arg(i)->exprType() != INT_EXPR) {
341                          PARSE_ERR(                          PARSE_ERR(
342                              @9,                              @9,
# Line 384  statement: Line 384  statement:
384          } else {          } else {
385              if (name[0] == '@')              if (name[0] == '@')
386                  PARSE_WRN(@5, "Variable declared as string, integer expression assigned though.");                  PARSE_WRN(@5, "Variable declared as string, integer expression assigned though.");
387              int i = 0;              vmint i = 0;
388              IntExprRef expr = $5;              IntExprRef expr = $5;
389              if (expr->isConstExpr())              if (expr->isConstExpr())
390                  i = expr->evalInt();                  i = expr->evalInt();
# Line 486  functioncall: Line 486  functioncall:
486              $$ = new FunctionCall(name, args, NULL);              $$ = new FunctionCall(name, args, NULL);
487          } else {          } else {
488              bool argsOK = true;              bool argsOK = true;
489              for (int i = 0; i < args->argsCount(); ++i) {              for (vmint i = 0; i < args->argsCount(); ++i) {
490                  if (args->arg(i)->exprType() != fn->argType(i) && !fn->acceptsArgType(i, args->arg(i)->exprType())) {                  if (args->arg(i)->exprType() != fn->argType(i) && !fn->acceptsArgType(i, args->arg(i)->exprType())) {
491                      PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects " + typeStr(fn->argType(i)) + " type, but type " + typeStr(args->arg(i)->exprType()) + " was given instead.").c_str());                      PARSE_ERR(@3, (String("Argument ") + ToString(i+1) + " of built-in function '" + name + "' expects " + typeStr(fn->argType(i)) + " type, but type " + typeStr(args->arg(i)->exprType()) + " was given instead.").c_str());
492                      argsOK = false;                      argsOK = false;

Legend:
Removed from v.3556  
changed lines
  Added in v.3557

  ViewVC Help
Powered by ViewVC