本文整理汇总了C#中IPersistentVector类的典型用法代码示例。如果您正苦于以下问题:C# IPersistentVector类的具体用法?C# IPersistentVector怎么用?C# IPersistentVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPersistentVector类属于命名空间,在下文中一共展示了IPersistentVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
public static Expr Parse(ParserContext pcon, IPersistentVector form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector args = PersistentVector.EMPTY;
for (int i = 0; i < form.count(); i++ )
{
Expr v = Compiler.Analyze(pconToUse, form.nth(i));
args = (IPersistentVector)args.cons(v);
if ( !(v is LiteralExpr) )
constant = false;
}
Expr ret = new VectorExpr(args);
if ( form is IObj && ((IObj)form).meta() != null )
return Compiler.OptionallyGenerateMetaInit(pcon,form, ret);
else if ( constant )
{
IPersistentVector rv = PersistentVector.EMPTY;
for ( int i=0; i<args.count(); i++ )
{
LiteralExpr ve = (LiteralExpr)args.nth(i);
rv = (IPersistentVector)rv.cons(ve.Val);
}
return new ConstantExpr(rv);
}
else
return ret;
}
示例2: InvokeExpr
public InvokeExpr(string source, IPersistentMap spanMap, Symbol tag, Expr fexpr, IPersistentVector args)
{
_source = source;
_spanMap = spanMap;
_fexpr = fexpr;
_args = args;
VarExpr varFexpr = fexpr as VarExpr;
if (varFexpr != null)
{
Var fvar = varFexpr.Var;
Var pvar = (Var)RT.get(fvar.meta(), Compiler.ProtocolKeyword);
if (pvar != null && Compiler.ProtocolCallsitesVar.isBound)
{
_isProtocol = true;
_siteIndex = Compiler.RegisterProtocolCallsite(fvar);
Object pon = RT.get(pvar.get(), _onKey);
_protocolOn = HostExpr.MaybeType(pon, false);
if (_protocolOn != null)
{
IPersistentMap mmap = (IPersistentMap)RT.get(pvar.get(), _methodMapKey);
Keyword mmapVal = (Keyword)mmap.valAt(Keyword.intern(fvar.sym));
if (mmapVal == null)
{
throw new ArgumentException(String.Format("No method of interface: {0} found for function: {1} of protocol: {2} (The protocol method may have been defined before and removed.)",
_protocolOn.FullName, fvar.Symbol, pvar.Symbol));
}
String mname = Compiler.munge(mmapVal.Symbol.ToString());
IList<MethodBase> methods = Reflector.GetMethods(_protocolOn, mname, null, args.count() - 1, false);
if (methods.Count != 1)
throw new ArgumentException(String.Format("No single method: {0} of interface: {1} found for function: {2} of protocol: {3}",
mname, _protocolOn.FullName, fvar.Symbol, pvar.Symbol));
_onMethod = (MethodInfo) methods[0];
}
}
}
if (tag != null)
_tag = tag;
else if (varFexpr != null)
{
object arglists = RT.get(RT.meta(varFexpr.Var), Compiler.ArglistsKeyword);
object sigTag = null;
for (ISeq s = RT.seq(arglists); s != null; s = s.next())
{
APersistentVector sig = (APersistentVector)s.first();
int restOffset = sig.IndexOf(Compiler.AmpersandSym);
if (args.count() == sig.count() || (restOffset > -1 && args.count() >= restOffset))
{
sigTag = Compiler.TagOf(sig);
break;
}
}
_tag = sigTag ?? varFexpr.Tag;
}
else
_tag = null;
}
示例3: RecurExpr
public RecurExpr(string source, IPersistentMap spanMap, IPersistentVector loopLocals, IPersistentVector args)
{
_loopLocals = loopLocals;
_args = args;
_source = source;
_spanMap = spanMap;
}
示例4: GenTypedArgs
internal static Expression[] GenTypedArgs(GenContext context, ParameterInfo[] parms, IPersistentVector args)
{
Expression[] exprs = new Expression[parms.Length];
for (int i = 0; i < parms.Length; i++)
exprs[i] = GenTypedArg(context,parms[i].ParameterType, (Expr)args.nth(i));
return exprs;
}
示例5: InvokeExpr
public InvokeExpr(string source, int line, Symbol tag, Expr fexpr, IPersistentVector args)
{
_source = source;
_line = line;
_fexpr = fexpr;
_args = args;
_tag = tag ?? (fexpr is VarExpr ? ((VarExpr)fexpr).Tag : null);
}
示例6: TryExpr
public TryExpr(Expr tryExpr, IPersistentVector catchExprs, Expr finallyExpr, int retLocal, int finallyLocal)
{
_tryExpr = tryExpr;
_catchExprs = catchExprs;
_finallyExpr = finallyExpr;
_retLocal = retLocal;
_finallyLocal = finallyLocal;
}
示例7: InstanceMethodExpr
public InstanceMethodExpr(Expr target, string methodName, IPersistentVector args)
{
_target = target;
_methodName = methodName;
_args = args;
_method = GetMatchingMethod(target, _args, _methodName);
}
示例8: StaticMethodExpr
public StaticMethodExpr(Type type, string methodName, IPersistentVector args)
{
_type = type;
_methodName = methodName;
_args = args;
_method = GetMatchingMethod(_type, _args, _methodName);
}
示例9: DefineMethod
private static void DefineMethod(TypeBuilder proxyTB, IPersistentVector sig)
{
string mname = (string)sig.nth(0);
Type[] paramTypes = GenClass.CreateTypeArray((ISeq)sig.nth(1));
Type retType = (Type)sig.nth(2);
MethodBuilder mb = proxyTB.DefineMethod(mname, MethodAttributes.Abstract | MethodAttributes.Public| MethodAttributes.Virtual, retType, paramTypes);
}
示例10: Parse
public static Expr Parse(IPersistentVector form)
{
IPersistentVector args = PersistentVector.EMPTY;
for (int i = 0; i < form.count(); i++ )
args = (IPersistentVector)args.cons(Compiler.GenerateAST(form.nth(i),false));
Expr ret = new VectorExpr(args);
return Compiler.OptionallyGenerateMetaInit(form, ret);
}
示例11: StaticInvokeExpr
public StaticInvokeExpr(Type target, Type retType, Type[] paramTypes, bool variadic, IPersistentVector args, Symbol tag)
{
_target = target;
_retType = retType;
_paramTypes = paramTypes;
_variadic = variadic;
_args = args;
_tag = tag;
}
示例12: StaticInvokeExpr
public StaticInvokeExpr(Type target, MethodInfo method, bool variadic, IPersistentVector args, object tag)
{
//_target = target;
_method = method;
_retType = method.ReturnType;
_variadic = variadic;
_args = args;
_tag = tag;
}
示例13: StaticMethodExpr
public StaticMethodExpr(string source, int line, Type type, string methodName, IPersistentVector args)
{
_source = source;
_line = line;
_type = type;
_methodName = methodName;
_args = args;
_method = GetMatchingMethod(line, _type, _args, _methodName);
}
示例14: GetMatchingParams
internal static int GetMatchingParams(string methodName, List<ParameterInfo[]> parmlists, IPersistentVector argexprs, List<Type> rets)
{
// Assume matching lengths
int matchIndex = -1;
bool tied = false;
bool foundExact = false;
for (int i = 0; i < parmlists.Count; i++)
{
bool match = true;
ISeq aseq = argexprs.seq();
int exact = 0;
for (int p = 0; match && p < argexprs.count() && aseq != null; ++p, aseq = aseq.next())
{
Expr arg = (Expr)aseq.first();
Type atype = arg.HasClrType ? arg.ClrType : typeof(object);
Type ptype = parmlists[i][p].ParameterType;
if (arg.HasClrType && atype == ptype)
exact++;
else
match = Reflector.ParamArgTypeMatch(ptype, atype);
}
if (exact == argexprs.count())
{
if ( !foundExact || matchIndex == -1 || rets[matchIndex].IsAssignableFrom(rets[i]))
matchIndex = i;
foundExact = true;
}
else if (match && !foundExact)
{
if (matchIndex == -1)
matchIndex = i;
else
{
if (Reflector.Subsumes(parmlists[i], parmlists[matchIndex]))
{
matchIndex = i;
tied = false;
}
else if (Array.Equals(parmlists[i], parmlists[matchIndex]))
if (rets[matchIndex].IsAssignableFrom(rets[i]))
matchIndex = i;
else if (!Reflector.Subsumes(parmlists[matchIndex], parmlists[i]))
tied = true;
}
}
}
if (tied)
throw new ArgumentException("More than one matching method found: " + methodName);
return matchIndex;
}
示例15: GenerateTypedDelegate
public Delegate GenerateTypedDelegate(Type delegateType, Symbol optName, IPersistentVector argList, ISeq body)
{
ScriptSource scriptSource = Engine.CreateScriptSourceFromString("<internal>");
LambdaExpression ast = Generator.GenerateTypedDelegateExpression(GetLanguageContext(), delegateType, optName, argList, body);
return ast.Compile();
//ast = new GlobalLookupRewriter().RewriteLambda(ast); -- doesn't work unless no args
//ScriptCode code = new ScriptCode(ast, GetSourceUnit(scriptSource));
//return code;
}