本文整理汇总了C#中IArgs类的典型用法代码示例。如果您正苦于以下问题:C# IArgs类的具体用法?C# IArgs怎么用?C# IArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IArgs类属于命名空间,在下文中一共展示了IArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasOwnProperty
private static IDynamic HasOwnProperty(IEnvironment environment, IArgs args)
{
if (args.IsEmpty) return environment.False;
var obj = environment.Context.ThisBinding.ConvertToObject();
var desc = obj.GetOwnProperty(args[0].ConvertToString().BaseValue);
return environment.CreateBoolean(desc != null);
}
示例2: Call
public virtual IDynamic Call(IEnvironment environment, IDynamic thisBinding, IArgs args)
{
var oldContext = environment.Context;
var newEnvironment = Scope.NewDeclarativeEnvironment();
using (var newContext = environment.EnterContext())
{
newContext.LexicalEnviroment = newEnvironment;
newContext.VariableEnviroment = newEnvironment;
newContext.Strict = ExecutableCode.Strict;
if (ExecutableCode.Strict)
{
newContext.ThisBinding = thisBinding;
}
else
{
switch (thisBinding.TypeCode)
{
case LanguageTypeCode.Undefined:
case LanguageTypeCode.Null:
newContext.ThisBinding = Environment.GlobalObject;
break;
default:
newContext.ThisBinding = thisBinding.ConvertToObject();
break;
}
}
BindFormalParameters(args);
Environment.BindFunctionDeclarations(ExecutableCode.FunctionDeclarations, ExecutableCode.Strict, true);
BindArgumentsObject(args);
Environment.BindVariableDeclarations(ExecutableCode.VariableDeclarations, ExecutableCode.Strict, true);
return ExecutableCode.Code(environment, args);
}
}
示例3: CreateIterator
public override IDynamic CreateIterator(IEnvironment environment, IArgs args)
{
var scope = Scope.NewDeclarativeEnvironment();
var generator = new Generator(new GeneratorSteps(Steps));
var iterator = new HGeneratorIterator(environment, generator, VariableDeclarations, scope);
return iterator;
}
示例4: Stringify
internal static IDynamic Stringify(IEnvironment environment, IArgs args)
{
var value = args[0];
var replacer = args[1];
var space = args[2];
return Machete.Compiler.JsonParser.Stringify(environment, value, replacer, space);
}
示例5: IsArray
internal static IDynamic IsArray(IEnvironment environment, IArgs args)
{
// 15.4.3.2 Array.isArray ( arg )
var arg = args[0] as IObject;
return environment.CreateBoolean(arg != null && arg.Class == "Array");
}
示例6: Call
protected override sealed IDynamic Call(IEnvironment environment, IArgs args)
{
if (args.Count > 0)
{
return args[0].ConvertToString();
}
return environment.CreateString("");
}
示例7: Call
protected override sealed IDynamic Call(IEnvironment environment, IArgs args)
{
if (args.Count > 0)
{
return args[0].ConvertToNumber();
}
return environment.CreateNumber(0.0);
}
示例8: Call
public IDynamic Call(IEnvironment environment, IDynamic thisBinding, IArgs args)
{
using (var newContext = environment.EnterContext())
{
Environment.Context.ThisBinding = thisBinding;
return _code(environment, args);
}
}
示例9: Construct
public override IObject Construct(IEnvironment environment, IArgs args)
{
var func = TargetFunction as NFunction;
if (func == null)
{
throw Environment.CreateTypeError("");
}
return func.Construct(environment, environment.ConcatArgs(BoundArguments, args));
}
示例10: Construct
public override IObject Construct(IEnvironment environment, IArgs args)
{
var obj = new NBoolean(environment);
obj.Class = "Boolean";
obj.Extensible = true;
obj.PrimitiveValue = args[0].ConvertToBoolean();
obj.Prototype = environment.BooleanPrototype;
return obj;
}
示例11: Call
protected override sealed IDynamic Call(IEnvironment environment, IArgs args)
{
var patternObject = args[0] as IObject;
if (patternObject != null && patternObject.Class == "RegExp")
{
return patternObject;
}
return Construct(environment, args);
}
示例12: FromCharCode
internal static IDynamic FromCharCode(IEnvironment environment, IArgs args)
{
var sb = new StringBuilder(args.Count);
foreach (var arg in args)
{
sb.Append((char)arg.ConvertToUInt16().BaseValue);
}
return environment.CreateString(sb.ToString());
}
示例13: Filter
internal static IDynamic Filter(IEnvironment environment, IArgs args)
{
if (args.Count < 2)
throw environment.CreateTypeError("The arguments 'iterable' and 'predicate' are required.");
var iterable = args[1].ConvertToObject();
var predicate = args[0].ConvertToObject() as ICallable;
if (predicate == null)
throw environment.CreateTypeError("The argument 'predicate' must be a callable function.");
return new HFilterIterable(environment, iterable, predicate);
}
示例14: Assert
internal static IDynamic Assert(IEnvironment environment, IArgs args)
{
var condition = args[0].ConvertToBoolean().BaseValue;
if (!condition)
{
var message = args[1].ConvertToString().BaseValue;
throw environment.CreateError(message);
}
return environment.Undefined;
}
示例15: Next
public override IDynamic Next(IEnvironment environment, IArgs args)
{
if (_complete)
return environment.False;
_initialized = true;
if (++_index < _length)
return environment.True;
_complete = true;
return environment.False;
}