/[svn]/linuxsampler/trunk/src/scriptvm/tree.cpp
ViewVC logotype

Contents of /linuxsampler/trunk/src/scriptvm/tree.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2581 - (show annotations) (download)
Fri May 30 12:48:05 2014 UTC (5 years, 4 months ago) by schoenebeck
File size: 20224 byte(s)
* (WIP) Implemented parser and VM for upcoming new real-time instrument
  script support. It needs yet to be integrated into the sampler's
  sampler engines. You can toy around for now with the command line tool
  "ls_instr_script" and i.e. examples showing the core language features
  under src/scriptvm/examples/.
* Bumped version (1.0.0.svn41).

1 /*
2 * Copyright (c) 2014 Christian Schoenebeck and Andreas Persson
3 *
4 * http://www.linuxsampler.org
5 *
6 * This file is part of LinuxSampler and released under the same terms.
7 * See README file for details.
8 */
9
10 #include <cstdio>
11 #include <string.h>
12 #include "tree.h"
13 #include "../common/global_private.h"
14
15 namespace LinuxSampler {
16
17 bool isNoOperation(StatementRef statement) {
18 NoOperation* noOp = dynamic_cast<NoOperation*>(&*statement);
19 return noOp;
20 }
21
22 Node::Node() {
23 }
24
25 Node::~Node() {
26 }
27
28 void Node::printIndents(int n) {
29 for (int i = 0; i < n; ++i) printf(" ");
30 fflush(stdout);
31 }
32
33 String IntExpr::evalCastToStr() {
34 return ToString(evalInt());
35 }
36
37 int IntLiteral::evalInt() {
38 return value;
39 }
40
41 void IntLiteral::dump(int level) {
42 printIndents(level);
43 printf("IntLiteral %d\n", value);
44 }
45
46 void StringLiteral::dump(int level) {
47 printIndents(level);
48 printf("StringLiteral: '%s'\n", value.c_str());
49 }
50
51 int Add::evalInt() {
52 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
53 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
54 return (pLHS && pRHS) ? pLHS->evalInt() + pRHS->evalInt() : 0;
55 }
56
57 void Add::dump(int level) {
58 printIndents(level);
59 printf("Add(\n");
60 lhs->dump(level+1);
61 printIndents(level);
62 printf(",\n");
63 rhs->dump(level+1);
64 printIndents(level);
65 printf(")\n");
66 }
67
68 int Sub::evalInt() {
69 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
70 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
71 return (pLHS && pRHS) ? pLHS->evalInt() - pRHS->evalInt() : 0;
72 }
73
74 void Sub::dump(int level) {
75 printIndents(level);
76 printf("Sub(\n");
77 lhs->dump(level+1);
78 printIndents(level);
79 printf(",\n");
80 rhs->dump(level+1);
81 printIndents(level);
82 printf(")\n");
83 }
84
85 int Mul::evalInt() {
86 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
87 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
88 return (pLHS && pRHS) ? pLHS->evalInt() * pRHS->evalInt() : 0;
89 }
90
91 void Mul::dump(int level) {
92 printIndents(level);
93 printf("Mul(\n");
94 lhs->dump(level+1);
95 printIndents(level);
96 printf(",\n");
97 rhs->dump(level+1);
98 printIndents(level);
99 printf(")\n");
100 }
101
102 int Div::evalInt() {
103 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
104 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
105 return (pLHS && pRHS) ? pRHS->evalInt() == 0 ? 0 : pLHS->evalInt() / pRHS->evalInt() : 0;
106 }
107
108 void Div::dump(int level) {
109 printIndents(level);
110 printf("Div(\n");
111 lhs->dump(level+1);
112 printIndents(level);
113 printf(",\n");
114 rhs->dump(level+1);
115 printIndents(level);
116 printf(")\n");
117 }
118
119 int Mod::evalInt() {
120 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
121 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
122 return (pLHS && pRHS) ? pLHS->evalInt() % pRHS->evalInt() : 0;
123 }
124
125 void Mod::dump(int level) {
126 printIndents(level);
127 printf("Mod(\n");
128 lhs->dump(level+1);
129 printIndents(level);
130 printf(",\n");
131 rhs->dump(level+1);
132 printIndents(level);
133 printf(")\n");
134 }
135
136 void Args::dump(int level) {
137 printIndents(level);
138 printf("Args(\n");
139 for (std::vector<ExpressionRef>::iterator it = args.begin() ; it != args.end() ; ++it) {
140 (*it)->dump(level+1);
141 }
142 printIndents(level);
143 printf(")\n");
144 }
145
146 EventHandlers::EventHandlers() {
147 //printf("EventHandlers::Constructor 0x%lx\n", (long long)this);
148 }
149
150 EventHandlers::~EventHandlers() {
151 }
152
153 void EventHandlers::add(EventHandlerRef arg) {
154 args.push_back(arg);
155 }
156
157 void EventHandlers::dump(int level) {
158 printIndents(level);
159 printf("EventHandlers {\n");
160 for (std::vector<EventHandlerRef>::iterator it = args.begin() ; it != args.end() ; ++it) {
161 (*it)->dump(level+1);
162 }
163 printIndents(level);
164 printf("}\n");
165 }
166
167 EventHandler* EventHandlers::eventHandlerByName(const String& name) const {
168 for (int i = 0; i < args.size(); ++i)
169 if (args.at(i)->eventHandlerName() == name)
170 return const_cast<EventHandler*>(&*args.at(i));
171 return NULL;
172 }
173
174 EventHandler* EventHandlers::eventHandler(uint index) const {
175 if (index >= args.size()) return NULL;
176 return const_cast<EventHandler*>(&*args.at(index));
177 }
178
179 Assignment::Assignment(VariableRef variable, ExpressionRef value)
180 : variable(variable), value(value)
181 {
182 }
183
184 void Assignment::dump(int level) {
185 printIndents(level);
186 printf("Assignment\n");
187 }
188
189 StmtFlags_t Assignment::exec() {
190 if (!variable)
191 return StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED);
192 variable->assign(&*value);
193 return STMT_SUCCESS;
194 }
195
196 void EventHandler::dump(int level) {
197 printIndents(level);
198 printf("EventHandler {\n");
199 statements->dump(level+1);
200 printIndents(level);
201 printf("}\n");
202 }
203
204 void Statements::dump(int level) {
205 printIndents(level);
206 printf("Statements {\n");
207 for (std::vector<StatementRef>::iterator it = args.begin() ; it != args.end() ; ++it) {
208 (*it)->dump(level+1);
209 }
210 printIndents(level);
211 printf("}\n");
212 }
213
214 Statement* Statements::statement(uint i) {
215 if (i >= args.size()) return NULL;
216 return &*args.at(i);
217 }
218
219 void FunctionCall::dump(int level) {
220 printIndents(level);
221 printf("FunctionCall '%s' args={\n", functionName.c_str());
222 args->dump(level+1);
223 printIndents(level);
224 printf("}\n");
225 }
226
227 ExprType_t FunctionCall::exprType() const {
228 if (!fn) return EMPTY_EXPR;
229 return fn->returnType();
230 }
231
232 VMFnResult* FunctionCall::execVMFn() {
233 if (!fn) return NULL;
234 // assuming here that all argument checks (amount and types) have been made
235 // at parse time, to avoid time intensive checks on each function call
236 return fn->exec(dynamic_cast<VMFnArgs*>(&*args));
237 }
238
239 StmtFlags_t FunctionCall::exec() {
240 VMFnResult* result = execVMFn();
241 if (!result)
242 return StmtFlags_t(STMT_ABORT_SIGNALLED | STMT_ERROR_OCCURRED);
243 return result->resultFlags();
244 }
245
246 int FunctionCall::evalInt() {
247 VMFnResult* result = execVMFn();
248 if (!result) return 0;
249 VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());
250 if (!intExpr) return 0;
251 return intExpr->evalInt();
252 }
253
254 String FunctionCall::evalStr() {
255 VMFnResult* result = execVMFn();
256 if (!result) return "";
257 VMStringExpr* strExpr = dynamic_cast<VMStringExpr*>(result->resultValue());
258 if (!strExpr) return "";
259 return strExpr->evalStr();
260 }
261
262 String FunctionCall::evalCastToStr() {
263 VMFnResult* result = execVMFn();
264 if (!result) return "";
265 if (result->resultValue()->exprType() == STRING_EXPR) {
266 VMStringExpr* strExpr = dynamic_cast<VMStringExpr*>(result->resultValue());
267 return strExpr ? strExpr->evalStr() : "";
268 } else {
269 VMIntExpr* intExpr = dynamic_cast<VMIntExpr*>(result->resultValue());
270 return intExpr ? ToString(intExpr->evalInt()) : "";
271 }
272 }
273
274 IntVariable::IntVariable(ParserContext* ctx)
275 : Variable(ctx, ctx ? ctx->globalIntVarCount++ : 0, false), polyphonic(false)
276 {
277 }
278
279 IntVariable::IntVariable(ParserContext* ctx, bool polyphonic, bool bConst, int size)
280 : Variable(ctx, !ctx ? 0 : polyphonic ? ctx->polyphonicIntVarCount += size : ctx->globalIntVarCount += size, bConst),
281 polyphonic(polyphonic)
282 {
283 }
284
285 void IntVariable::assign(Expression* expr) {
286 IntExpr* intExpr = dynamic_cast<IntExpr*>(expr);
287 if (intExpr)
288 if (polyphonic)
289 context->execContext->polyphonicIntMemory[memPos] = intExpr->evalInt();
290 else
291 (*context->globalIntMemory)[memPos] = intExpr->evalInt();
292 }
293
294 int IntVariable::evalInt() {
295 //printf("IntVariable::eval pos=%d\n", memPos);
296 if (polyphonic)
297 return context->execContext->polyphonicIntMemory[memPos];
298 return (*context->globalIntMemory)[memPos];
299 }
300
301 void IntVariable::dump(int level) {
302 printIndents(level);
303 printf("IntVariable memPos=%d\n", memPos);
304 }
305
306 //ConstIntVariable::ConstIntVariable(ParserContext* ctx, int value)
307 ConstIntVariable::ConstIntVariable(int value)
308 : IntVariable(NULL,false,true), value(value)
309 {
310 }
311
312 void ConstIntVariable::assign(Expression* expr) {
313 // ignore assignment
314 /*
315 printf("ConstIntVariable::assign()\n");
316 IntExpr* intExpr = dynamic_cast<IntExpr*>(expr);
317 if (intExpr) {
318 value = intExpr->evalInt();
319 }
320 */
321 }
322
323 int ConstIntVariable::evalInt() {
324 return value;
325 }
326
327 void ConstIntVariable::dump(int level) {
328 printIndents(level);
329 printf("ConstIntVariable val=%d\n", value);
330 }
331
332 PolyphonicIntVariable::PolyphonicIntVariable(ParserContext* ctx)
333 : IntVariable(ctx,true,false)
334 {
335 }
336
337 void PolyphonicIntVariable::dump(int level) {
338 printIndents(level);
339 printf("PolyphonicIntVariable\n");
340 }
341
342 IntArrayVariable::IntArrayVariable(ParserContext* ctx, int size)
343 : Variable(ctx, 0, false)
344 {
345 values.resize(size);
346 memset(&values[0], 0, size * sizeof(int));
347 }
348
349 IntArrayVariable::IntArrayVariable(ParserContext* ctx, int size, ArgsRef values)
350 : Variable(ctx, 0, false)
351 {
352 this->values.resize(size);
353 for (int i = 0; i < values->argsCount(); ++i) {
354 VMIntExpr* expr = dynamic_cast<VMIntExpr*>(values->arg(i));
355 if (expr) this->values[i] = expr->evalInt();
356 }
357 }
358
359 int IntArrayVariable::evalIntElement(uint i) {
360 if (i >= values.size()) return 0;
361 return values[i];
362 }
363
364 void IntArrayVariable::assignIntElement(uint i, int value) {
365 if (i >= values.size()) return;
366 values[i] = value;
367 }
368
369 void IntArrayVariable::dump(int level) {
370 printIndents(level);
371 printf("IntArray(");
372 for (int i = 0; i < values.size(); ++i) {
373 if (i % 12 == 0) {
374 printf("\n");
375 printIndents(level+1);
376 }
377 printf("%d, ", values[i]);
378 }
379 printIndents(level);
380 printf(")\n");
381 }
382
383 IntArrayElement::IntArrayElement(IntArrayVariableRef array, IntExprRef arrayIndex)
384 : IntVariable(NULL, false, false, 0), array(array), index(arrayIndex)
385 {
386 }
387
388 void IntArrayElement::assign(Expression* expr) {
389 IntExpr* valueExpr = dynamic_cast<IntExpr*>(expr);
390 if (!valueExpr) return;
391 int value = valueExpr->evalInt();
392
393 if (!index) return;
394 int idx = index->evalInt();
395 if (idx < 0 || idx >= array->arraySize()) return;
396
397 array->assignIntElement(idx, value);
398 }
399
400 int IntArrayElement::evalInt() {
401 if (!index) return 0;
402 int idx = index->evalInt();
403 if (idx < 0 || idx >= array->arraySize()) return 0;
404
405 return array->evalIntElement(idx);
406 }
407
408 void IntArrayElement::dump(int level) {
409 printIndents(level);
410 printf("IntArrayElement\n");
411 }
412
413 StringVariable::StringVariable(ParserContext* ctx)
414 : Variable(ctx,ctx->globalStrVarCount++,false)
415 {
416 }
417
418 StringVariable::StringVariable(ParserContext* ctx, bool bConst)
419 : Variable(ctx,0,bConst)
420 {
421 }
422
423 void StringVariable::assign(Expression* expr) {
424 StringExpr* strExpr = dynamic_cast<StringExpr*>(expr);
425 (*context->globalStrMemory)[memPos] = strExpr->evalStr();
426 }
427
428 String StringVariable::evalStr() {
429 //printf("StringVariable::eval pos=%d\n", memPos);
430 return (*context->globalStrMemory)[memPos];
431 }
432
433 void StringVariable::dump(int level) {
434 printIndents(level);
435 printf("StringVariable memPos=%d\n", memPos);
436 }
437
438 ConstStringVariable::ConstStringVariable(ParserContext* ctx, String _value)
439 : StringVariable(ctx,true), value(_value)
440 {
441 }
442
443 void ConstStringVariable::assign(Expression* expr) {
444 // ignore assignment
445 // StringExpr* strExpr = dynamic_cast<StringExpr*>(expr);
446 // if (strExpr) value = strExpr->evalStr();
447 }
448
449 String ConstStringVariable::evalStr() {
450 return value;
451 }
452
453 void ConstStringVariable::dump(int level) {
454 printIndents(level);
455 printf("ConstStringVariable val='%s'\n", value.c_str());
456 }
457
458 void If::dump(int level) {
459 printIndents(level);
460 if (ifStatements && elseStatements)
461 printf("if cond stmts1 else stmts2 end if\n");
462 else if (ifStatements)
463 printf("if cond statements end if\n");
464 else
465 printf("if [INVALID]\n");
466 }
467
468 int If::evalBranch() {
469 if (condition->evalInt()) return 0;
470 if (elseStatements) return 1;
471 return -1;
472 }
473
474 Statements* If::branch(uint i) const {
475 if (i == 0) return (Statements*) &*ifStatements;
476 if (i == 1) return (elseStatements) ? (Statements*) &*elseStatements : NULL;
477 return NULL;
478 }
479
480 void SelectCase::dump(int level) {
481 printIndents(level);
482 if (select)
483 if (select->isConstExpr())
484 printf("Case select %d\n", select->evalInt());
485 else
486 printf("Case select [runtime expr]\n");
487 else
488 printf("Case select NULL\n");
489 for (int i = 0; i < branches.size(); ++i) {
490 printIndents(level+1);
491 CaseBranch& branch = branches[i];
492 if (branch.from && branch.to)
493 if (branch.from->isConstExpr() && branch.to->isConstExpr())
494 printf("case %d to %d\n", branch.from->evalInt(), branch.to->evalInt());
495 else if (branch.from->isConstExpr() && !branch.to->isConstExpr())
496 printf("case %d to [runtime expr]\n", branch.from->evalInt());
497 else if (!branch.from->isConstExpr() && branch.to->isConstExpr())
498 printf("case [runtime expr] to %d\n", branch.to->evalInt());
499 else
500 printf("case [runtime expr] to [runtime expr]\n");
501 else if (branch.from)
502 if (branch.from->isConstExpr())
503 printf("case %d\n", branch.from->evalInt());
504 else
505 printf("case [runtime expr]\n");
506 else
507 printf("case NULL\n");
508 }
509 }
510
511 int SelectCase::evalBranch() {
512 int value = select->evalInt();
513 for (int i = 0; i < branches.size(); ++i) {
514 if (branches.at(i).from && branches.at(i).to) { // i.e. "case 4 to 7" ...
515 if (branches.at(i).from->evalInt() <= value &&
516 branches.at(i).to->evalInt() >= value) return i;
517 } else { // i.e. "case 5" ...
518 if (branches.at(i).from->evalInt() == value) return i;
519 }
520 }
521 return -1;
522 }
523
524 Statements* SelectCase::branch(uint i) const {
525 if (i < branches.size())
526 return const_cast<Statements*>( &*branches[i].statements );
527 return NULL;
528 }
529
530 // void Case::addBranch(IntExprRef condition, StatementsRef statements) {
531 // CaseBranchRef b = new CaseBranchRef;
532 // b->from = condition;
533 // b->statements = statements;
534 // branches.push_back(b);
535 // }
536 //
537 // void Case::addBranch(IntExprRef from, IntExprRef to, StatementsRef statements) {
538 // CaseBranchRef b = new CaseBranchRef;
539 // b->from = from;
540 // b->to = to;
541 // b->statements = statements;
542 // branches.push_back(b);
543 // }
544 //
545 // void Case::addBranch(CaseBranchRef branch) {
546 // branches.push_back(branch);
547 // }
548
549 void While::dump(int level) {
550 printIndents(level);
551 if (m_condition)
552 if (m_condition->isConstExpr())
553 printf("while (%d) {\n", m_condition->evalInt());
554 else
555 printf("while ([runtime expr]) {\n");
556 else
557 printf("while ([INVALID]) {\n");
558 m_statements->dump(level+1);
559 printIndents(level);
560 printf("}\n");
561 }
562
563 Statements* While::statements() const {
564 return (m_statements) ? const_cast<Statements*>( &*m_statements ) : NULL;
565 }
566
567 bool While::evalLoopStartCondition() {
568 if (!m_condition) return false;
569 return m_condition->evalInt();
570 }
571
572 void Neg::dump(int level) {
573 printIndents(level);
574 printf("Negative Expr\n");
575 }
576
577 String ConcatString::evalStr() {
578 return lhs->evalCastToStr() + rhs->evalCastToStr();
579 }
580
581 void ConcatString::dump(int level) {
582 printIndents(level);
583 printf("ConcatString(\n");
584 lhs->dump(level+1);
585 printIndents(level);
586 printf(",\n");
587 rhs->dump(level+1);
588 printIndents(level);
589 printf(")");
590 }
591
592 bool ConcatString::isConstExpr() const {
593 return lhs->isConstExpr() && rhs->isConstExpr();
594 }
595
596 int Relation::evalInt() {
597 switch (type) {
598 case LESS_THAN:
599 return lhs->evalInt() < rhs->evalInt();
600 case GREATER_THAN:
601 return lhs->evalInt() > rhs->evalInt();
602 case LESS_OR_EQUAL:
603 return lhs->evalInt() <= rhs->evalInt();
604 case GREATER_OR_EQUAL:
605 return lhs->evalInt() >= rhs->evalInt();
606 case EQUAL:
607 if (lhs->exprType() == STRING_EXPR || rhs->exprType() == STRING_EXPR)
608 return lhs->evalCastToStr() == rhs->evalCastToStr();
609 else
610 return lhs->evalInt() == rhs->evalInt();
611 case NOT_EQUAL:
612 if (lhs->exprType() == STRING_EXPR || rhs->exprType() == STRING_EXPR)
613 return lhs->evalCastToStr() != rhs->evalCastToStr();
614 else
615 return lhs->evalInt() != rhs->evalInt();
616 }
617 return 0;
618 }
619
620 void Relation::dump(int level) {
621 printIndents(level);
622 printf("Relation(\n");
623 lhs->dump(level+1);
624 printIndents(level);
625 switch (type) {
626 case LESS_THAN:
627 printf("LESS_THAN\n");
628 break;
629 case GREATER_THAN:
630 printf("GREATER_THAN\n");
631 break;
632 case LESS_OR_EQUAL:
633 printf("LESS_OR_EQUAL\n");
634 break;
635 case GREATER_OR_EQUAL:
636 printf("GREATER_OR_EQUAL\n");
637 break;
638 case EQUAL:
639 printf("EQUAL\n");
640 break;
641 case NOT_EQUAL:
642 printf("NOT_EQUAL\n");
643 break;
644 }
645 rhs->dump(level+1);
646 printIndents(level);
647 printf(")\n");
648 }
649
650 bool Relation::isConstExpr() const {
651 return lhs->isConstExpr() && rhs->isConstExpr();
652 }
653
654 int Or::evalInt() {
655 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
656 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
657 return pLHS->evalInt() || pRHS->evalInt();
658 }
659
660 void Or::dump(int level) {
661 printIndents(level);
662 printf("Or(\n");
663 lhs->dump(level+1);
664 printIndents(level);
665 printf(",\n");
666 rhs->dump(level+1);
667 printIndents(level);
668 printf(")\n");
669 }
670
671 int And::evalInt() {
672 IntExpr* pLHS = dynamic_cast<IntExpr*>(&*lhs);
673 IntExpr* pRHS = dynamic_cast<IntExpr*>(&*rhs);;
674 return pLHS->evalInt() && pRHS->evalInt();
675 }
676
677 void And::dump(int level) {
678 printIndents(level);
679 printf("And(\n");
680 lhs->dump(level+1);
681 printIndents(level);
682 printf(",\n");
683 rhs->dump(level+1);
684 printIndents(level);
685 printf(")\n");
686 }
687
688 void Not::dump(int level) {
689 printIndents(level);
690 printf("Not(\n");
691 expr->dump(level+1);
692 printIndents(level);
693 printf(")\n");
694 }
695
696 VariableRef ParserContext::variableByName(const String& name) {
697 if (!vartable.count(name)) {
698 return VariableRef();
699 }
700 return vartable.find(name)->second;
701 }
702
703 VariableRef ParserContext::globalVar(const String& name) {
704 if (!vartable.count(name)) {
705 //printf("No global var '%s'\n", name.c_str());
706 //for (std::map<String,VariableRef>::const_iterator it = vartable.begin(); it != vartable.end(); ++it)
707 // printf("-> var '%s'\n", it->first.c_str());
708 return VariableRef();
709 }
710 return vartable.find(name)->second;
711 }
712
713 IntVariableRef ParserContext::globalIntVar(const String& name) {
714 return globalVar(name);
715 }
716
717 StringVariableRef ParserContext::globalStrVar(const String& name) {
718 return globalVar(name);
719 }
720
721 void ParserContext::addErr(int line, const char* txt) {
722 ParserIssue e;
723 e.type = PARSER_ERROR;
724 e.txt = txt;
725 e.line = line;
726 errors.push_back(e);
727 issues.push_back(e);
728 }
729
730 void ParserContext::addWrn(int line, const char* txt) {
731 ParserIssue w;
732 w.type = PARSER_WARNING;
733 w.txt = txt;
734 w.line = line;
735 warnings.push_back(w);
736 issues.push_back(w);
737 }
738
739 bool ParserContext::setPreprocessorCondition(const char* name) {
740 if (builtinPreprocessorConditions.count(name)) return false;
741 if (userPreprocessorConditions.count(name)) return false;
742 userPreprocessorConditions.insert(name);
743 return true;
744 }
745
746 bool ParserContext::resetPreprocessorCondition(const char* name) {
747 if (builtinPreprocessorConditions.count(name)) return false;
748 if (!userPreprocessorConditions.count(name)) return false;
749 userPreprocessorConditions.erase(name);
750 return true;
751 }
752
753 bool ParserContext::isPreprocessorConditionSet(const char* name) {
754 if (builtinPreprocessorConditions.count(name)) return true;
755 return userPreprocessorConditions.count(name);
756 }
757
758 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC