MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / ev

Method ev

src/common/style/CartoCSS.js:3929–4003  ·  view source on GitHub ↗
(env)

Source from the content-addressed store, hash-verified

3927 }
3928
3929 ev(env) {
3930 var a = this.operands[0].ev(env),
3931 b = this.operands[1].ev(env),
3932 temp;
3933
3934 if (a.is === 'undefined' || b.is === 'undefined') {
3935 return {
3936 is: 'undefined',
3937 value: 'undefined'
3938 };
3939 }
3940
3941 if (a instanceof CartoCSS.Tree.Dimension && b instanceof CartoCSS.Tree.Color) {
3942 if (this.op === '*' || this.op === '+') {
3943 temp = b;
3944 b = a;
3945 a = temp;
3946 } else {
3947 env.error({
3948 name: "OperationError",
3949 message: "Can't substract or divide a color from a number",
3950 index: this.index
3951 });
3952 }
3953 }
3954
3955 // Only concatenate plain strings, because this is easily
3956 // pre-processed
3957 if (a instanceof CartoCSS.Tree.Quoted && b instanceof CartoCSS.Tree.Quoted && this.op !== '+') {
3958 env.error({
3959 message: "Can't subtract, divide, or multiply strings.",
3960 index: this.index,
3961 type: 'runtime',
3962 filename: this.filename
3963 });
3964 return {
3965 is: 'undefined',
3966 value: 'undefined'
3967 };
3968 }
3969
3970 // Fields, literals, dimensions, and quoted strings can be combined.
3971 if (a instanceof CartoCSS.Tree.Field || b instanceof CartoCSS.Tree.Field ||
3972 a instanceof CartoCSS.Tree.Literal || b instanceof CartoCSS.Tree.Literal) {
3973 if (a.is === 'color' || b.is === 'color') {
3974 env.error({
3975 message: "Can't subtract, divide, or multiply colors in expressions.",
3976 index: this.index,
3977 type: 'runtime',
3978 filename: this.filename
3979 });
3980 return {
3981 is: 'undefined',
3982 value: 'undefined'
3983 };
3984 } else {
3985 return new CartoCSS.Tree.Literal(a.ev(env).toString(true) + this.op + b.ev(env).toString(true));
3986 }

Callers

nothing calls this directly

Calls 3

evMethod · 0.45
toStringMethod · 0.45
operateMethod · 0.45

Tested by

no test coverage detected