Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
a3fea319
Commit
a3fea319
authored
Jul 05, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added min and max script pseudo-functions
parent
202042ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
1 deletion
+25
-1
src/script/context.cpp
src/script/context.cpp
+11
-0
src/script/parser.cpp
src/script/parser.cpp
+12
-1
src/script/script.hpp
src/script/script.hpp
+2
-0
No files found.
src/script/context.cpp
View file @
a3fea319
...
...
@@ -275,6 +275,15 @@ void instrUnary (UnaryInstructionType i, ScriptValueP& a) {
}
\
break
// operator on doubles or ints, defined as a function
#define OPERATOR_FUN_DI(OP) \
if
(
at
==
SCRIPT_DOUBLE
||
bt
==
SCRIPT_DOUBLE
)
{
\
a
=
to_script
(
OP
((
double
)
*
a
,
(
double
)
*
b
));
\
}
else
{
\
a
=
to_script
(
OP
((
int
)
*
a
,
(
int
)
*
b
));
\
}
\
break
// operator on strings or doubles or ints, when in doubt, uses strings
#define OPERATOR_SDI(OP) \
if
(
at
==
SCRIPT_INT
&&
bt
==
SCRIPT_INT
)
{
\
...
...
@@ -349,6 +358,8 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
case
I_GT
:
OPERATOR_DI
(
>
);
case
I_LE
:
OPERATOR_DI
(
<=
);
case
I_GE
:
OPERATOR_DI
(
>=
);
case
I_MIN
:
OPERATOR_FUN_DI
(
min
);
case
I_MAX
:
OPERATOR_FUN_DI
(
max
);
case
I_OR_ELSE
:
if
(
at
==
SCRIPT_ERROR
)
a
=
b
;
break
;
...
...
src/script/parser.cpp
View file @
a3fea319
...
...
@@ -505,9 +505,20 @@ void parseExpr(TokenIterator& input, Script& script, Precedence minPrec) {
parseOper
(
input
,
script
,
PREC_ALL
);
// b
expectToken
(
input
,
_
(
")"
));
script
.
addInstruction
(
I_TERNARY
,
I_RGB
);
}
else
if
(
token
==
_
(
"min"
)
||
token
==
_
(
"max"
))
{
// min(x,y,z,...)
unsigned
int
op
=
token
==
_
(
"min"
)
?
I_MIN
:
I_MAX
;
expectToken
(
input
,
_
(
"("
));
parseOper
(
input
,
script
,
PREC_ALL
);
// first
while
(
input
.
peek
()
==
_
(
","
))
{
expectToken
(
input
,
_
(
","
));
parseOper
(
input
,
script
,
PREC_ALL
);
// second, third, etc.
script
.
addInstruction
(
I_BINARY
,
op
);
}
expectToken
(
input
,
_
(
")"
));
}
else
{
// variable
unsigned
int
var
=
string_to_variable
(
token
.
value
);
Variable
var
=
string_to_variable
(
token
.
value
);
script
.
addInstruction
(
I_GET_VAR
,
var
);
}
}
else
if
(
token
==
TOK_INT
)
{
...
...
src/script/script.hpp
View file @
a3fea319
...
...
@@ -70,6 +70,8 @@ enum BinaryInstructionType
,
I_GT
///< operator >
,
I_LE
///< operator <=
,
I_GE
///< operator >=
,
I_MIN
///< minimum
,
I_MAX
///< maximum
// Error handling
,
I_OR_ELSE
///< if a != error then a else b
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment