本文整理汇总了C#中Microsoft.JScript.Context类的典型用法代码示例。如果您正苦于以下问题:C# Context类的具体用法?C# Context怎么用?C# Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于Microsoft.JScript命名空间,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnumDeclaration
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);
}
}
示例2: PostOrPrefixOperator
internal PostOrPrefixOperator(Context context, AST operand, PostOrPrefix operatorTok)
: base(context, operand) {
this.operatorMeth = null;
this.operatorTok = operatorTok;
this.metaData = null;
this.type = null;
}
示例3: If
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();
}
示例4: ColorFromToken
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: StaticInitializer
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();
}
示例6: FunctionObject
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;
}
示例7: GetStateForText
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;
}
示例8: RegExpLiteral
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);
}
}
示例9: JScriptException
internal JScriptException(JSError errorNumber, Context context)
{
this.errorNumber = errorNumber;
this.wrappedException = null;
this.context = context;
this.message = null;
}
示例10: Eval
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;
}
}
示例11: Construct
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;
}
示例12: Try
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;
}
示例13: Call
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;
}
示例14: Close
internal override void Close()
{
base.Close();
this.binaryCode = null;
this.scope = null;
this.codeContext = null;
this.compiledBlock = null;
}
示例15: Import
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;
}