Skip to content

Commit

Permalink
Merge branch '6.0' of https://github.com/lucee/Lucee into 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Feb 8, 2024
2 parents b70f26e + 73d90b6 commit 66c6587
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 13 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitAnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitAnd implements Function {
public static double call(PageContext pc, double number, double number2) {
public static double call(PageContext pc, double number, double number2) throws FunctionException {
if (!Decision.isInteger(number)) throw new FunctionException(pc, "bitAnd", 1, "number1", "value [" + number + "] must be between the integer range");
if (!Decision.isInteger(number2)) throw new FunctionException(pc, "bitAnd", 2, "number2", "value [" + number + "] must be between the integer range");
return (int) number & (int) number2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

Expand All @@ -30,8 +31,9 @@ public static double call(PageContext pc, double dnumber, double dstart, double

int number = (int) dnumber, start = (int) dstart, length = (int) dlength;

if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskClear", 2, "start", "must be beetween 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskClear", 3, "length", "must be beetween 0 and 31 now " + length);
if(!Decision.isInteger(dnumber)) throw new FunctionException(pc, "bitMaskClear", 1, "number", "value [" + dnumber + "] must be between the integer range");
if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskClear", 2, "start", "must be between 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskClear", 3, "length", "must be between 0 and 31 now " + length);

return number & ~((1 << length) - 1 << start);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

Expand All @@ -30,9 +31,9 @@ public final class BitMaskRead implements Function {
public static double call(PageContext pc, double dnumber, double dstart, double dlength) throws FunctionException {

int number = (int) dnumber, start = (int) dstart, length = (int) dlength;

if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskRead", 2, "start", "must be beetween 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskRead", 3, "length", "must be beetween 0 and 31 now " + length);
if(!Decision.isInteger(dnumber)) throw new FunctionException(pc, "bitMaskRead", 1, "number", "value [" + dnumber + "] must be between the integer range");
if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskRead", 2, "start", "must be between 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskRead", 3, "length", "must be between 0 and 31 now " + length);

return number >> start & (1 << length) - 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

Expand All @@ -31,8 +32,9 @@ public static double call(PageContext pc, double dnumber, double dmask, double d

int number = (int) dnumber, mask = (int) dmask, start = (int) dstart, length = (int) dlength;

if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskSet", 2, "start", "must be beetween 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskSet", 3, "length", "must be beetween 0 and 31 now " + length);
if(!Decision.isInteger(dnumber)) throw new FunctionException(pc, "bitMaskSet", 1, "number", "value [" + dnumber + "] must be between the integer range");
if (start > 31 || start < 0) throw new FunctionException(pc, "bitMaskSet", 2, "start", "must be between 0 and 31 now " + start);
if (length > 31 || length < 0) throw new FunctionException(pc, "bitMaskSet", 3, "length", "must be between 0 and 31 now " + length);

int tmp = (1 << length) - 1 << start;
mask &= (1 << length) - 1;
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitNot.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitNot implements Function {
public static double call(PageContext pc, double number) {
public static double call(PageContext pc, double number) throws FunctionException {
if (!Decision.isInteger(number)) throw new FunctionException(pc, "bitNot", 1, "number", "value [" + number + "] must be between the integer range");
return ~(int) number;
}
}
6 changes: 5 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitOr.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitOr implements Function {
public static double call(PageContext pc, double number, double number2) {
public static double call(PageContext pc, double number, double number2) throws FunctionException {
if (!Decision.isInteger(number)) throw new FunctionException(pc, "bitOr", 1, "number1", "value [" + number + "] must be between the integer range");
if (!Decision.isInteger(number2)) throw new FunctionException(pc, "bitOr", 2, "number2", "value [" + number + "] must be between the integer range");
return (int) number | (int) number2;
}
}
4 changes: 3 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitSHLN.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitSHLN implements Function {
public static double call(PageContext pc, double dnumber, double dcount) throws FunctionException {
int number = (int) dnumber, count = (int) dcount;
if (count > 31 || count < 0) throw new FunctionException(pc, "bitSHLN", 2, "count", "must be beetween 0 and 31 now " + count);
if(!Decision.isInteger(dnumber)) throw new FunctionException(pc, "bitSHLN", 1, "number", "value [" + dnumber + "] must be between the integer range");
if (count > 31 || count < 0) throw new FunctionException(pc, "bitSHLN", 2, "count", "must be between 0 and 31 now " + count);
// TODO use bigInteger to shift further
return number << count;
}
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitSHRN.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitSHRN implements Function {

public static double call(PageContext pc, double dnumber, double dcount) throws FunctionException {
int number = (int) dnumber, count = (int) dcount;
if (count > 31 || count < 0) throw new FunctionException(pc, "bitSHRN", 2, "count", "must be beetween 0 and 31 now " + count);
if(!Decision.isInteger(dnumber)) throw new FunctionException(pc, "bitSHRN", 1, "number", "value [" + dnumber + "] must be between the integer range");
if (count > 31 || count < 0) throw new FunctionException(pc, "bitSHRN", 2, "count", "must be between 0 and 31 now " + count);

return number >>> count;
}
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/lucee/runtime/functions/math/BitXor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
package lucee.runtime.functions.math;

import lucee.runtime.PageContext;
import lucee.runtime.op.Decision;
import lucee.runtime.exp.FunctionException;
import lucee.runtime.ext.function.Function;

public final class BitXor implements Function {
public static double call(PageContext pc, double number, double number2) {
public static double call(PageContext pc, double number, double number2) throws FunctionException {
if (!Decision.isInteger(number)) throw new FunctionException(pc, "bitXor", 1, "number1", "value [" + number + "] must be between the integer range");
if (!Decision.isInteger(number2)) throw new FunctionException(pc, "bitXor", 1, "number2", "value [" + number + "] must be between the integer range");
return (int) number ^ (int) number2;
}
}

0 comments on commit 66c6587

Please sign in to comment.