本文整理汇总了C#中IPersistentMap类的典型用法代码示例。如果您正苦于以下问题:C# IPersistentMap类的具体用法?C# IPersistentMap怎么用?C# IPersistentMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPersistentMap类属于命名空间,在下文中一共展示了IPersistentMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewExpr
public NewExpr(Type type, List<HostArg> args, IPersistentMap spanMap)
{
_args = args;
_type = type;
_spanMap = spanMap;
_ctor = ComputeCtor();
}
示例2: Create
public static IPersistentList Create(IList list, IPersistentMap metadata)
{
if (list == null || list.Count == 0)
return EmptyList.Instance;
return new ListObject(list, 0, metadata);
}
示例3: Keyword
private Keyword(string ns, string name, IPersistentMap metadata)
: base(metadata)
{
this.ns = ns;
this.name = name;
this.hash = Utilities.CombineHash(name.GetHashCode(), Utilities.Hash(ns));
}
示例4: Parse
public static Expr Parse(ParserContext pcon, IPersistentMap form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector keyvals = PersistentVector.EMPTY;
for (ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry)s.first();
Expr k = Compiler.Analyze(pconToUse, e.key());
Expr v = Compiler.Analyze(pconToUse, e.val());
keyvals = (IPersistentVector)keyvals.cons(k);
keyvals = (IPersistentVector)keyvals.cons(v);
if (!(k is LiteralExpr && v is LiteralExpr))
constant = false;
}
Expr ret = new MapExpr(keyvals);
if (form is IObj && ((IObj)form).meta() != null)
return Compiler.OptionallyGenerateMetaInit(pcon, form, ret);
else if (constant)
{
IPersistentMap m = PersistentHashMap.EMPTY;
for (int i = 0; i < keyvals.length(); i += 2)
m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
return new ConstantExpr(m);
}
else
return ret;
}
示例5: PersistentList
internal PersistentList(object first, IPersistentList rest, int count, IPersistentMap metadata)
: base(metadata)
{
this.first = first;
this.rest = rest;
this.count = count;
}
示例6: CreateForMetaAlter
internal static IFn CreateForMetaAlter(IPersistentMap meta)
{
AFnImpl fn = new AFnImpl();
fn._fn0 = () => { return meta; };
fn._fn1 = (object x) => { return meta; };
return fn;
}
示例7: IfExpr
public IfExpr( IPersistentMap sourceSpan, Expr testExpr, Expr thenExpr, Expr elseExpr)
{
_sourceSpan = sourceSpan;
_testExpr = testExpr;
_thenExpr = thenExpr;
_elseExpr = elseExpr;
}
示例8: withMeta
/// <summary>
/// Create a copy with new metadata.
/// </summary>
/// <param name="meta">The new metadata.</param>
/// <returns>A copy of the object with new metadata attached.</returns>
public override IObj withMeta(IPersistentMap meta)
{
// Java doesn't make the identity test: return new Cons(meta, _first, _rest);
return (meta == _meta)
? this
: new Cons(meta, _first, _more);
}
示例9: WithMetadata
public override IObject WithMetadata(IPersistentMap metadata)
{
if (this.Metadata == metadata)
return this;
return new Cons(this.first, this.rest, metadata);
}
示例10: Parse
public static Expr Parse(ParserContext pcon, IPersistentMap form)
{
ParserContext pconToUse = pcon.EvEx();
bool constant = true;
IPersistentVector keyvals = PersistentVector.EMPTY;
for (ISeq s = RT.seq(form); s != null; s = s.next())
{
IMapEntry e = (IMapEntry)s.first();
Expr k = Compiler.Analyze(pconToUse, e.key());
Expr v = Compiler.Analyze(pconToUse, e.val());
keyvals = (IPersistentVector)keyvals.cons(k);
keyvals = (IPersistentVector)keyvals.cons(v);
if (!(k is LiteralExpr && v is LiteralExpr))
constant = false;
}
Expr ret = new MapExpr(keyvals);
if (form is IObj && ((IObj)form).meta() != null)
return Compiler.OptionallyGenerateMetaInit(pcon, form, ret);
else if (constant)
{
// This 'optimzation' works, mostly, unless you have nested map values.
// The nested map values do not participate in the constants map, so you end up with the code to create the keys.
// Result: huge duplication of keyword creation. 3X increase in init time to the REPL.
//IPersistentMap m = PersistentHashMap.EMPTY;
//for (int i = 0; i < keyvals.length(); i += 2)
// m = m.assoc(((LiteralExpr)keyvals.nth(i)).Val, ((LiteralExpr)keyvals.nth(i + 1)).Val);
//return new ConstantExpr(m);
return ret;
}
else
return ret;
}
示例11: 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;
}
示例12: RecurExpr
public RecurExpr(string source, IPersistentMap spanMap, IPersistentVector loopLocals, IPersistentVector args)
{
_loopLocals = loopLocals;
_args = args;
_source = source;
_spanMap = spanMap;
}
示例13: PersistentList
/// <summary>
/// Initialize a list with given metadata, first element and rest of list.
/// </summary>
/// <param name="meta">The metadata to attach.</param>
/// <param name="first">The first element in the list.</param>
/// <param name="rest">The rest of the list.</param>
/// <param name="count">The number of elements in the list.</param>
PersistentList(IPersistentMap meta, Object first, IPersistentList rest, int count)
: base(meta)
{
this._first = first;
this._rest = rest;
this._count = count;
}
示例14: Symbol
/// <summary>
/// Construct a symbol from interned namespace name and symbol name, with given metadata.
/// </summary>
/// <param name="meta">The metadata to attach.</param>
/// <param name="ns_interned">The (interned) namespace name.</param>
/// <param name="name_interned">The (interned) symbol name.</param>
private Symbol(IPersistentMap meta, string ns_interned, string name_interned)
: base(meta)
{
this._name = name_interned;
this._ns = ns_interned;
this._hash = ComputeHashCode();
}
示例15: ExtractAttributes
public static IPersistentMap ExtractAttributes(IPersistentMap meta)
{
if (meta != null && EXTRACT_ATTRIBUTES.isBound)
return (IPersistentMap)EXTRACT_ATTRIBUTES.invoke(meta);
return PersistentArrayMap.EMPTY;
}