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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2945 - (show annotations) (download)
Thu Jul 14 00:22:26 2016 UTC (7 years, 9 months ago) by schoenebeck
File size: 3905 byte(s)
* NKSP: Implemented built-in script function "inc()".
* NKSP: Implemented built-in script function "dec()".
* NKSP language fix: division expressions were evaluated too often.
* NKSP language fix: string concatenation operator was right
  associative instead of left (to right).
* Bumped version (2.0.0.svn15).

1 /*
2 * Copyright (c) 2014-2016 Christian Schoenebeck
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 "common.h"
11 #include <iostream>
12 #include "editor/SourceToken.h"
13
14 namespace LinuxSampler {
15
16 VMIntExpr* VMExpr::asInt() const {
17 return const_cast<VMIntExpr*>( dynamic_cast<const VMIntExpr*>(this) );
18 }
19
20 VMStringExpr* VMExpr::asString() const {
21 return const_cast<VMStringExpr*>( dynamic_cast<const VMStringExpr*>(this) );
22 }
23
24 VMIntArrayExpr* VMExpr::asIntArray() const {
25 return const_cast<VMIntArrayExpr*>( dynamic_cast<const VMIntArrayExpr*>(this) );
26 }
27
28 bool VMExpr::isModifyable() const {
29 const VMVariable* var = dynamic_cast<const VMVariable*>(this);
30 return (!var) ? false : var->isAssignable();
31 }
32
33 void VMFunction::wrnMsg(const String& txt) {
34 std::cout << "[ScriptVM] " << txt << std::endl;
35 }
36
37 void VMFunction::errMsg(const String& txt) {
38 std::cerr << "[ScriptVM] " << txt << std::endl;
39 }
40
41 ///////////////////////////////////////////////////////////////////////
42 // class 'VMSourceToken'
43
44 VMSourceToken::VMSourceToken() : m_token(NULL) {
45 }
46
47 VMSourceToken::VMSourceToken(SourceToken* ct) : m_token(ct) {
48 }
49
50 VMSourceToken::VMSourceToken(const VMSourceToken& other) {
51 if (other.m_token) {
52 m_token = new SourceToken;
53 *m_token = *other.m_token;
54 } else m_token = NULL;
55 }
56
57 VMSourceToken::~VMSourceToken() {
58 if (m_token) {
59 delete m_token;
60 m_token = NULL;
61 }
62 }
63
64 VMSourceToken& VMSourceToken::operator=(const VMSourceToken& other) {
65 if (m_token) delete m_token;
66 if (other.m_token) {
67 m_token = new SourceToken;
68 *m_token = *other.m_token;
69 } else m_token = NULL;
70 return *this;
71 }
72
73 String VMSourceToken::text() const {
74 return (m_token) ? m_token->text() : "";
75 }
76
77 int VMSourceToken::firstLine() const {
78 return (m_token) ? m_token->firstLine() : 0;
79 }
80
81 int VMSourceToken::firstColumn() const {
82 return (m_token) ? m_token->firstColumn() : 0;
83 }
84
85 bool VMSourceToken::isEOF() const {
86 return (m_token) ? m_token->isEOF() : true;
87 }
88
89 bool VMSourceToken::isNewLine() const {
90 return (m_token) ? m_token->isNewLine() : false;
91 }
92
93 bool VMSourceToken::isKeyword() const {
94 return (m_token) ? m_token->isKeyword() : false;
95 }
96
97 bool VMSourceToken::isVariableName() const {
98 return (m_token) ? m_token->isVariableName() : false;
99 }
100
101 bool VMSourceToken::isIdentifier() const {
102 return (m_token) ? m_token->isIdentifier() : false;
103 }
104
105 bool VMSourceToken::isNumberLiteral() const {
106 return (m_token) ? m_token->isNumberLiteral() : false;
107 }
108
109 bool VMSourceToken::isStringLiteral() const {
110 return (m_token) ? m_token->isStringLiteral() : false;
111 }
112
113 bool VMSourceToken::isComment() const {
114 return (m_token) ? m_token->isComment() : false;
115 }
116
117 bool VMSourceToken::isPreprocessor() const {
118 return (m_token) ? m_token->isPreprocessor() : false;
119 }
120
121 bool VMSourceToken::isOther() const {
122 return (m_token) ? m_token->isOther() : true;
123 }
124
125 bool VMSourceToken::isIntegerVariable() const {
126 return (m_token) ? m_token->isIntegerVariable() : false;
127 }
128
129 bool VMSourceToken::isStringVariable() const {
130 return (m_token) ? m_token->isStringVariable() : false;
131 }
132
133 bool VMSourceToken::isArrayVariable() const {
134 return (m_token) ? m_token->isArrayVariable() : false;
135 }
136
137 bool VMSourceToken::isEventHandlerName() const {
138 return (m_token) ? m_token->isEventHandlerName() : false;
139 }
140
141 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC