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

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

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

revision 3582 by schoenebeck, Fri Aug 30 12:23:40 2019 UTC revision 3590 by schoenebeck, Mon Sep 2 09:03:31 2019 UTC
# Line 19  namespace LinuxSampler { Line 19  namespace LinuxSampler {
19  bool isNoOperation(StatementRef statement) {  bool isNoOperation(StatementRef statement) {
20      return statement->statementType() == STMT_NOOP;      return statement->statementType() == STMT_NOOP;
21  }  }
22    
23    String acceptedArgTypesStr(VMFunction* fn, vmint iArg) {
24        static const ExprType_t allTypes[] = {
25            INT_EXPR,
26            INT_ARR_EXPR,
27            REAL_EXPR,
28            REAL_ARR_EXPR,
29            STRING_EXPR,
30            STRING_ARR_EXPR,
31        };
32        const size_t nTypes = sizeof(allTypes) / sizeof(ExprType_t);
33    
34        std::vector<ExprType_t> supportedTypes;
35        for (int iType = 0; iType < nTypes; ++iType) {
36            const ExprType_t& type = allTypes[iType];
37            if (fn->acceptsArgType(iArg, type))
38                supportedTypes.push_back(type);
39        }
40        assert(!supportedTypes.empty());
41    
42        if (supportedTypes.size() == 1) {
43            return typeStr(*supportedTypes.begin());
44        } else {
45            String s = "either ";
46            for (size_t i = 0; i < supportedTypes.size(); ++i) {
47                const ExprType_t& type = supportedTypes[i];
48                if (i == 0) {
49                    s += typeStr(type);
50                } else if (i == supportedTypes.size() - 1) {
51                    s += " or " + typeStr(type);
52                } else {
53                    s += ", " + typeStr(type);
54                }
55            }
56            return s;
57        }
58    }
59            
60  Node::Node() {  Node::Node() {
61  }  }
# Line 1843  void ParserContext::registerBuiltInConst Line 1880  void ParserContext::registerBuiltInConst
1880              .value = it->second              .value = it->second
1881          });          });
1882          vartable[it->first] = ref;          vartable[it->first] = ref;
1883        }
1884    }
1885    
1886    void ParserContext::registerBuiltInConstRealVariables(const std::map<String,vmfloat>& vars) {
1887        for (std::map<String,vmfloat>::const_iterator it = vars.begin();
1888             it != vars.end(); ++it)
1889        {
1890            ConstRealVariableRef ref = new ConstRealVariable({
1891                .value = it->second
1892            });
1893            vartable[it->first] = ref;
1894      }      }
1895  }  }
1896    

Legend:
Removed from v.3582  
changed lines
  Added in v.3590

  ViewVC Help
Powered by ViewVC