internal EnumDeclaration(Context context, IdentifierLiteral id, TypeExpression baseType, Block body, FieldAttributes attributes, CustomAttributeList customAttributes) : base(context, id, new TypeExpression(new ConstantWrapper(Typeob.Enum, null)), new TypeExpression[0], body, attributes, false, false, true, false, customAttributes)
 {
     this.baseType = (baseType != null) ? baseType : new TypeExpression(new ConstantWrapper(Typeob.Int32, null));
     base.needsEngine = false;
     base.attributes &= TypeAttributes.NestedFamORAssem;
     TypeExpression expression = new TypeExpression(new ConstantWrapper(base.classob, base.context));
     AST ast = new ConstantWrapper(-1, null);
     AST ast2 = new ConstantWrapper(1, null);
     JSMemberField[] fields = base.fields;
     for (int i = 0; i < fields.Length; i++)
     {
         FieldInfo info = fields[i];
         JSVariableField field = (JSVariableField) info;
         field.attributeFlags = FieldAttributes.Literal | FieldAttributes.Static | FieldAttributes.Public;
         field.type = expression;
         if (field.value == null)
         {
             field.value = ast = new Plus(ast.context, ast, ast2);
         }
         else
         {
             ast = (AST) field.value;
         }
         field.value = new DeclaredEnumValue(field.value, field.Name, base.classob);
     }
 }
 internal PostOrPrefixOperator(Context context, AST operand, PostOrPrefix operatorTok)
   : base(context, operand) {
   this.operatorMeth = null;
   this.operatorTok = operatorTok;
   this.metaData = null;
   this.type = null;
 }
Пример #3
0
 internal If(Context context, AST condition, AST true_branch, AST false_branch)
   : base(context) {
   this.condition = condition;
   this.operand1 = true_branch;
   this.operand2 = false_branch;
   this.completion = new Completion();
 }
 internal static TokenColor ColorFromToken(Context context)
 {
     JSToken token = context.GetToken();
     if (JSScanner.IsKeyword(token))
     {
         return TokenColor.COLOR_KEYWORD;
     }
     if (JSToken.Identifier == token)
     {
         if (context.Equals("eval"))
         {
             return TokenColor.COLOR_KEYWORD;
         }
         return TokenColor.COLOR_IDENTIFIER;
     }
     if (JSToken.StringLiteral == token)
     {
         return TokenColor.COLOR_STRING;
     }
     if ((JSToken.NumericLiteral == token) || (JSToken.IntegerLiteral == token))
     {
         return TokenColor.COLOR_NUMBER;
     }
     if ((JSToken.Comment == token) || (JSToken.UnterminatedComment == token))
     {
         return TokenColor.COLOR_COMMENT;
     }
     if (JSScanner.IsOperator(token))
     {
         return TokenColor.COLOR_OPERATOR;
     }
     return TokenColor.COLOR_TEXT;
 }
Пример #5
0
 internal StaticInitializer(Context context, Block body, FunctionScope own_scope)
   : base(context) {
   this.func = new FunctionObject(null, new ParameterDeclaration[0], null, body, own_scope, Globals.ScopeStack.Peek(), context, MethodAttributes.Private|MethodAttributes.Static);
   this.func.isMethod = true;
   this.func.hasArgumentsObject = false;
   this.completion = new Completion();
 }
 internal FunctionObject(Type t, string name, string method_name, string[] formal_parameters, JSLocalField[] fields, bool must_save_stack_locals, bool hasArgumentsObject, string text, VsaEngine engine) : base(engine.Globals.globalObject.originalFunction.originalPrototype, name, formal_parameters.Length)
 {
     base.engine = engine;
     this.formal_parameters = formal_parameters;
     this.argumentsSlotNumber = 0;
     this.body = null;
     this.method = TypeReflector.GetTypeReflectorFor(Globals.TypeRefs.ToReferenceContext(t)).GetMethod(method_name, BindingFlags.Public | BindingFlags.Static);
     this.parameterInfos = this.method.GetParameters();
     if (!Microsoft.JScript.CustomAttribute.IsDefined(this.method, typeof(JSFunctionAttribute), false))
     {
         this.isMethod = true;
     }
     else
     {
         JSFunctionAttributeEnum attributeValue = ((JSFunctionAttribute) Microsoft.JScript.CustomAttribute.GetCustomAttributes(this.method, typeof(JSFunctionAttribute), false)[0]).attributeValue;
         this.isExpandoMethod = (attributeValue & JSFunctionAttributeEnum.IsExpandoMethod) != JSFunctionAttributeEnum.None;
     }
     this.funcContext = null;
     this.own_scope = null;
     this.fields = fields;
     this.must_save_stack_locals = must_save_stack_locals;
     this.hasArgumentsObject = hasArgumentsObject;
     this.text = text;
     this.attributes = MethodAttributes.Public;
     this.globals = engine.Globals;
     this.superConstructor = null;
     this.superConstructorCall = null;
     this.enclosing_scope = this.globals.ScopeStack.Peek();
     base.noExpando = false;
     this.clsCompliance = CLSComplianceSpec.NotAttributed;
 }
 internal FunctionObject(string name, ParameterDeclaration[] parameter_declarations, TypeExpression return_type_expr, Block body, FunctionScope own_scope, ScriptObject enclosing_scope, Context funcContext, MethodAttributes attributes, CustomAttributeList customAttributes, bool isMethod) : base(body.Globals.globalObject.originalFunction.originalPrototype, name, parameter_declarations.Length)
 {
     this.parameter_declarations = parameter_declarations;
     int length = parameter_declarations.Length;
     this.formal_parameters = new string[length];
     for (int i = 0; i < length; i++)
     {
         this.formal_parameters[i] = parameter_declarations[i].identifier;
     }
     this.argumentsSlotNumber = 0;
     this.return_type_expr = return_type_expr;
     if (this.return_type_expr != null)
     {
         own_scope.AddReturnValueField();
     }
     this.body = body;
     this.method = null;
     this.parameterInfos = null;
     this.funcContext = funcContext;
     this.own_scope = own_scope;
     this.own_scope.owner = this;
     if ((!(enclosing_scope is ActivationObject) || !((ActivationObject) enclosing_scope).fast) && !isMethod)
     {
         this.argumentsSlotNumber = this.own_scope.GetNextSlotNumber();
         JSLocalField field = (JSLocalField) this.own_scope.AddNewField("arguments", null, FieldAttributes.PrivateScope);
         field.type = new TypeExpression(new ConstantWrapper(Typeob.Object, funcContext));
         field.isDefined = true;
         this.hasArgumentsObject = true;
     }
     else
     {
         this.hasArgumentsObject = false;
     }
     this.implementedIface = null;
     this.implementedIfaceMethod = null;
     this.isMethod = isMethod;
     this.isExpandoMethod = (customAttributes != null) && customAttributes.ContainsExpandoAttribute();
     this.isStatic = this.own_scope.isStatic = (attributes & MethodAttributes.Static) != MethodAttributes.PrivateScope;
     this.suppressIL = false;
     this.noVersionSafeAttributeSpecified = true;
     this.fields = this.own_scope.GetLocalFields();
     this.enclosing_scope = enclosing_scope;
     this.must_save_stack_locals = false;
     this.text = null;
     this.mb = null;
     this.cb = null;
     this.attributes = attributes;
     if (!this.isStatic)
     {
         this.attributes |= MethodAttributes.HideBySig;
     }
     this.globals = body.Globals;
     this.superConstructor = null;
     this.superConstructorCall = null;
     this.customAttributes = customAttributes;
     base.noExpando = false;
     this.clsCompliance = CLSComplianceSpec.NotAttributed;
     this.engineLocal = null;
     this.partiallyEvaluated = false;
 }
 public virtual SourceState GetStateForText(string sourceCode, SourceState state)
 {
     if (sourceCode != null)
     {
         this._state = SourceState.STATE_COLOR_NORMAL;
         Context sourceContext = new Context(null, sourceCode);
         this._scanner.SetSource(sourceContext);
         if ((SourceState.STATE_COLOR_COMMENT == state) && (this._scanner.SkipMultiLineComment() > sourceCode.Length))
         {
             this._state = SourceState.STATE_COLOR_COMMENT;
             return this._state;
         }
         this._scanner.GetNextToken();
         JSToken none = JSToken.None;
         while (sourceContext.GetToken() != JSToken.EndOfFile)
         {
             none = sourceContext.GetToken();
             this._scanner.GetNextToken();
         }
         if (JSToken.UnterminatedComment == none)
         {
             this._state = SourceState.STATE_COLOR_COMMENT;
         }
     }
     return this._state;
 }
Пример #9
0
 internal RegExpLiteral(String source, String flags, Context context)
   : base(context) {
   this.source = source;
   this.ignoreCase = this.global = this.multiline = false;
   if (flags != null)
     for (int i = 0; i < flags.Length; i++)
       switch (flags[i]) {
         case 'i':
           if (this.ignoreCase)
             throw new JScriptException(JSError.RegExpSyntax);
           this.ignoreCase = true;
           break;
         case 'g':
           if (this.global)
             throw new JScriptException(JSError.RegExpSyntax);
           this.global = true;
           break;
         case 'm':
           if (this.multiline)
             throw new JScriptException(JSError.RegExpSyntax);
           this.multiline = true;
           break;
         default:
           throw new JScriptException(JSError.RegExpSyntax);
       }
 }
	internal JScriptException(JSError errorNumber, Context context)
			{
				this.errorNumber = errorNumber;
				this.wrappedException = null;
				this.context = context;
				this.message = null;
			}
 internal Eval(Context context, AST operand, AST unsafeOption) : base(context)
 {
     this.operand = operand;
     this.unsafeOption = unsafeOption;
     ScriptObject obj2 = base.Globals.ScopeStack.Peek();
     ((IActivationObject) obj2).GetGlobalScope().evilScript = true;
     if (obj2 is ActivationObject)
     {
         ((ActivationObject) obj2).isKnownAtCompileTime = base.Engine.doFast;
     }
     if (obj2 is FunctionScope)
     {
         this.enclosingFunctionScope = (FunctionScope) obj2;
         this.enclosingFunctionScope.mustSaveStackLocals = true;
         for (ScriptObject obj3 = this.enclosingFunctionScope.GetParent(); obj3 != null; obj3 = obj3.GetParent())
         {
             FunctionScope scope = obj3 as FunctionScope;
             if (scope != null)
             {
                 scope.mustSaveStackLocals = true;
                 scope.closuresMightEscape = true;
             }
         }
     }
     else
     {
         this.enclosingFunctionScope = null;
     }
 }
 internal ScriptFunction Construct(object[] args, VsaEngine engine)
 {
     ScriptFunction function;
     StringBuilder builder = new StringBuilder("function anonymous(");
     int index = 0;
     int num2 = args.Length - 2;
     while (index < num2)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[index]));
         builder.Append(", ");
         index++;
     }
     if (args.Length > 1)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 2]));
     }
     builder.Append(") {\n");
     if (args.Length > 0)
     {
         builder.Append(Microsoft.JScript.Convert.ToString(args[args.Length - 1]));
     }
     builder.Append("\n}");
     Context context = new Context(new DocumentContext("anonymous", engine), builder.ToString());
     JSParser parser = new JSParser(context);
     engine.PushScriptObject(((IActivationObject) engine.ScriptObjectStackTop()).GetGlobalScope());
     try
     {
         function = (ScriptFunction) parser.ParseFunctionExpression().PartiallyEvaluate().Evaluate();
     }
     finally
     {
         engine.PopScriptObject();
     }
     return function;
 }
Пример #13
0
 internal Try(Context context, AST body, AST identifier, TypeExpression type, AST handler, AST finally_block, bool finallyHasControlFlowOutOfIt, Context tryEndContext)
   : base(context) {
   this.body = body;
   this.type = type;
   this.handler = handler;
   this.finally_block = finally_block;
   ScriptObject current_scope = (ScriptObject)Globals.ScopeStack.Peek();
   while (current_scope is WithObject) //Can only happen at run time and only if there is an eval
     current_scope = current_scope.GetParent();
   this.handler_scope = null;
   this.field = null;
   if (identifier != null){
     this.fieldName = identifier.ToString();
     this.field = current_scope.GetField(this.fieldName, BindingFlags.Public|BindingFlags.Instance|BindingFlags.Static);
     if (this.field != null){
       if (type == null && (field is JSVariableField && field.IsStatic && ((JSVariableField)field).type == null) && !field.IsLiteral && !field.IsInitOnly)
         return; //preserve legacy semantics by using the existing variable
       if (((IActivationObject)current_scope).GetLocalField(this.fieldName) != null)
         identifier.context.HandleError(JSError.DuplicateName, false);
     }
     this.handler_scope = new BlockScope(current_scope);
     this.handler_scope.catchHanderScope = true;
     JSVariableField f = this.handler_scope.AddNewField(identifier.ToString(), Missing.Value, FieldAttributes.Public); // must be a local 
     this.field = f; f.originalContext = identifier.context;
     if (identifier.context.document.debugOn && this.field is JSLocalField){
       this.handler_scope.AddFieldForLocalScopeDebugInfo((JSLocalField)this.field);
     }
   }
   this.finallyHasControlFlowOutOfIt = finallyHasControlFlowOutOfIt;
   this.tryEndContext = tryEndContext;
 }
 internal Call(Context context, AST func, ASTList args, bool inBrackets) : base(context)
 {
     this.func = func;
     this.args = (args == null) ? new ASTList(context) : args;
     this.argValues = null;
     this.outParameterCount = 0;
     int num = 0;
     int count = this.args.count;
     while (num < count)
     {
         if (this.args[num] is AddressOf)
         {
             this.outParameterCount++;
         }
         num++;
     }
     this.isConstructor = false;
     this.inBrackets = inBrackets;
     this.enclosingFunctionScope = null;
     this.alreadyPartiallyEvaluated = false;
     this.isAssignmentToDefaultIndexedProperty = false;
     ScriptObject parent = base.Globals.ScopeStack.Peek();
     while (!(parent is FunctionScope))
     {
         parent = parent.GetParent();
         if (parent == null)
         {
             return;
         }
     }
     this.enclosingFunctionScope = (FunctionScope) parent;
 }
 internal override void Close()
 {
     base.Close();
     this.binaryCode = null;
     this.scope = null;
     this.codeContext = null;
     this.compiledBlock = null;
 }
Пример #16
0
 internal Import(Context context, AST name)
   : base(context) {
   if (name == null) //could happen if constructed while in error recovery mode
     return;
   WrappedNamespace ns = name.EvaluateAsWrappedNamespace(true);
   this.Engine.SetEnclosingContext(ns);
   this.name = ns.name;
 }
 internal For(Context context, AST initializer, AST condition, AST incrementer, AST body) : base(context)
 {
     this.initializer = initializer;
     this.condition = condition;
     this.incrementer = incrementer;
     this.body = body;
     this.completion = new Completion();
 }
Пример #18
0
 internal RegExpLiteral(String source, bool ignoreCase, bool global, bool multiline, Context context)
   : base(context) {
   this.source     = source;
   this.ignoreCase = ignoreCase;
   this.multiline  = multiline;
   this.global     = global;
   this.regExpVar  = null;
 }
Пример #19
0
 internal BinaryOp(Context context, AST operand1, AST operand2, JSToken operatorTok)
   : base(context) {
   this.operand1 = operand1;
   this.operand2 = operand2;
   this.operatorTok = operatorTok;
   this.type1 = null;
   this.type2 = null;
   this.operatorMeth = null;
 }
Пример #20
0
 // this is the typical Lookup constructor. The context points to the identifier
 internal Lookup(Context context)
   : base(context, context.GetCode()){
   this.lexLevel = 0;
   this.evalLexLevel = 0;
   this.fieldLoc = null;
   this.refLoc = null;
   this.lateBinding = null;
   this.thereIsAnObjectOnTheStack = false;
 }
 internal ConstantWrapper(object value, Context context) : base(context)
 {
     if (value is ConcatString)
     {
         value = value.ToString();
     }
     this.value = value;
     this.isNumericLiteral = false;
 }
 internal ConstructorCall(Context context, ASTList arguments, bool isSuperConstructorCall)
   : base(context) {
   this.isOK = false;
   this.isSuperConstructorCall = isSuperConstructorCall;
   if (arguments == null)
     this.arguments = new ASTList(context);
   else
     this.arguments = arguments;
 }
 internal Import(Context context, AST name) : base(context)
 {
     if (name != null)
     {
         WrappedNamespace ob = name.EvaluateAsWrappedNamespace(true);
         base.Engine.SetEnclosingContext(ob);
         this.name = ob.name;
     }
 }
 internal VsaScriptCode(VsaEngine engine, string itemName, JSVsaItemType type, IVsaScriptScope scope) : base(engine, itemName, type, JSVsaItemFlag.None)
 {
     this.binaryCode = null;
     this.executed = false;
     this.scope = (VsaScriptScope) scope;
     this.codeContext = new Context(new DocumentContext(this), null);
     this.compiledBlock = null;
     this.compileToIL = true;
     this.optimize = true;
 }
 internal ObjectLiteral(Context context, ASTList propertyList)
   : base(context) {
   int n = propertyList.count;
   this.keys = new AST[n];
   this.values = new AST[n];
   for (int i = 0; i < n; i++){
     ASTList pair = (ASTList)propertyList[i];
     this.keys[i] = pair[0];
     this.values[i] = pair[1];
   }
 }
Пример #26
0
 public JSScanner(Context sourceContext){
   this.IsAuthoring = false;
   this.peekModeOn = false;
   this.keywords = s_Keywords;
   this.preProcessorOn = false;
   this.matchIf = 0;
   this.ppTable = null;
   this.SetSource(sourceContext);
   this.currentDocument = null;
   this.globals = sourceContext.document.engine.Globals;
 }
Пример #27
0
 internal With(Context context, AST obj, AST block)
   : base(context) {
   this.obj = obj;
   this.block = block;
   this.completion = new Completion();
   ScriptObject scope = Globals.ScopeStack.Peek();
   if (scope is FunctionScope)
     this.enclosing_function = (FunctionScope)scope;
   else
     this.enclosing_function = null;
 }
Пример #28
0
 internal Member(Context context, AST rootObject, AST memberName)
   : base(context, memberName.context.GetCode()){
   this.fast = this.Engine.doFast;
   this.isImplicitWrapper = false;
   this.isNonVirtual = rootObject is ThisLiteral && ((ThisLiteral)rootObject).isSuper;
   this.lateBinding = null;
   this.memberNameContext = memberName.context;
   this.rootObject = rootObject;
   this.rootObjectInferredType = null;
   this.refLoc = null;
   this.temp = null;
 }
 internal ObjectLiteral(Context context, ASTList propertyList) : base(context)
 {
     int count = propertyList.count;
     this.keys = new AST[count];
     this.values = new AST[count];
     for (int i = 0; i < count; i++)
     {
         ASTList list = (ASTList) propertyList[i];
         this.keys[i] = list[0];
         this.values[i] = list[1];
     }
 }
Пример #30
0
 internal Switch(Context context, AST expression, ASTList cases)
   : base(context) {
   this.expression = expression;
   this.cases = cases;
   this.default_case = -1;
   for (int i = 0, n = this.cases.count; i < n; i++){
     if (((SwitchCase)(this.cases[i])).IsDefault()){
       this.default_case = i;
       break;
     }
   }
   this.completion = new Completion();
 }