private RegExpObject ConstructNew(Object[] args) {
String source = args.Length > 0 && args[0] != null ? Convert.ToString(args[0]) : "";
if (args.Length > 0 && args[0] is Regex)
throw new JScriptException(JSError.TypeMismatch);
bool ignoreCase = false;
bool global = false;
bool multiline = false;
if (args.Length >= 2 && args[1] != null) {
String flags = Convert.ToString(args[1]);
for (int i = 0; i < flags.Length; i++) {
switch (flags[i]) {
case 'i':
ignoreCase = true;
continue;
case 'g':
global = true;
continue;
case 'm':
multiline = true;
continue;
}
throw new JScriptException(JSError.RegExpSyntax);
}
}
return new RegExpObject(this.originalPrototype,
source, ignoreCase, global, multiline, this);
}