本文整理汇总了C#中clojure.lang.Symbol类的典型用法代码示例。如果您正苦于以下问题:C# Symbol类的具体用法?C# Symbol怎么用?C# Symbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Symbol类属于clojure.lang命名空间,在下文中一共展示了Symbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Namespace
/// <summary>
/// Construct a namespace with a given name.
/// </summary>
/// <param name="name">The name.</param>
Namespace(Symbol name)
: base(name.meta())
{
_name = name;
_mappings.Set(RT.DEFAULT_IMPORTS);
_aliases.Set(RT.map());
}
示例2: 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;
}
示例3: intern
public static Keyword intern(Symbol sym)
{
Keyword k = null;
WeakReference existingRef = _symKeyMap.Get(sym);
if (existingRef == null)
{
if (sym.meta() != null)
sym = (Symbol)sym.withMeta(null);
k = new Keyword(sym);
WeakReference wr = new WeakReference(k);
wr.Target = k;
existingRef = _symKeyMap.PutIfAbsent(sym, wr);
}
if (existingRef == null)
return k;
Keyword existingk = (Keyword)existingRef.Target;
if (existingk != null)
return existingk;
// entry died in the interim, do over
// let's not get confused, remove it. (else infinite loop).
_symKeyMap.Remove(sym);
return intern(sym);
}
示例4: DeprecatedWrappingReader
public DeprecatedWrappingReader(Symbol sym, string macro)
{
_sym = sym;
_macro = macro;
}
示例5: ReadRecord
static object ReadRecord(PushbackTextReader r, Symbol recordName)
{
Type recordType = RT.classForName(recordName.ToString());
char endch;
bool shortForm = true;
int ch = r.Read();
// flush whitespace
//while (isWhitespace(ch))
// ch = r.Read();
// A defrecord ctor can take two forms. Check for map->R version first.
if (ch == '{')
{
endch = '}';
shortForm = false;
}
else if (ch == '[')
endch = ']';
else
throw new ArgumentException(String.Format("Unreadable constructor form starting with \"#{0}{1}\"", recordName, (char)ch));
object[] recordEntries = ReadDelimitedList(endch, r, true).ToArray();
object ret = null;
ConstructorInfo[] allCtors = recordType.GetConstructors();
if (shortForm)
{
bool ctorFound = false;
foreach ( ConstructorInfo cinfo in allCtors )
if ( cinfo.GetParameters().Length == recordEntries.Length )
ctorFound = true;
if ( ! ctorFound )
throw new ArgumentException(String.Format("Unexpected number of constructor arguments to {0}: got {1}", recordType.ToString(), recordEntries.Length));
ret = Reflector.InvokeConstructor(recordType,recordEntries);
}
else
{
IPersistentMap vals = RT.map(recordEntries);
for (ISeq s = RT.keys(vals); s != null; s = s.next())
{
if (!(s.first() is Keyword))
throw new ArgumentException(String.Format("Unreadable defrecord form: key must be of type clojure.lang.Keyword, got {0}", s.first().ToString()));
}
ret = Reflector.InvokeStaticMethod(recordType, "create", new Object[] { vals });
}
return ret;
}
示例6: RegisterLocal
internal static LocalBinding RegisterLocal(Symbol sym, Symbol tag, Expr init)
{
int num = GetAndIncLocalNum();
LocalBinding b = new LocalBinding(num,sym, tag, init);
IPersistentMap localsMap = (IPersistentMap)LOCAL_ENV.deref();
LOCAL_ENV.set(RT.assoc(localsMap,b.Symbol, b));
FnMethod method = (FnMethod)METHODS.deref();
method.Locals = (IPersistentMap)RT.assoc(method.Locals,b, b);
method.IndexLocals = (IPersistentMap)RT.assoc(method.IndexLocals, num, b);
return b;
}
示例7: NamesStaticMember
internal static bool NamesStaticMember(Symbol sym)
{
return sym.Namespace != null && NamespaceFor(sym) == null;
}
示例8: resolveSymbol
// TODO: we have duplicate code below.
public static Symbol resolveSymbol(Symbol sym)
{
//already qualified or classname?
if (sym.Name.IndexOf('.') > 0)
return sym;
if (sym.Namespace != null)
{
Namespace ns = namespaceFor(sym);
if (ns == null || ns.Name.Name == sym.Namespace)
return sym;
return Symbol.create(ns.Name.Name, sym.Name);
}
Object o = CurrentNamespace.GetMapping(sym);
if (o == null)
return Symbol.intern(CurrentNamespace.Name.Name, sym.Name);
else if (o is Type)
return Symbol.intern(null, Util.NameForType((Type)o));
else if (o is Var)
{
Var v = (Var)o;
return Symbol.create(v.Namespace.Name.Name, v.Symbol.Name);
}
return null;
}
示例9: Resolve
public static object Resolve(Symbol symbol, bool allowPrivate)
{
return ResolveIn(CurrentNamespace, symbol, allowPrivate);
}
示例10: setTag
public void setTag(Symbol tag)
{
Tag = tag;
}
示例11: intern
public static Var intern(Namespace ns, Symbol sym)
{
return ns.intern(sym);
}
示例12: find
public static Var find(Symbol nsQualifiedSym)
{
if (nsQualifiedSym.Namespace == null)
throw new ArgumentException("Symbol must be namespace-qualified");
Namespace ns = Namespace.find(Symbol.intern(nsQualifiedSym.Namespace));
if (ns == null)
throw new ArgumentException("No such namespace: " + nsQualifiedSym.Namespace);
return ns.FindInternedVar(Symbol.intern(nsQualifiedSym.Name));
}
示例13: NamespaceFor
public static Namespace NamespaceFor(Symbol symbol)
{
return NamespaceFor(CurrentNamespace, symbol);
}
示例14: CreateSuperCall
private static void CreateSuperCall(TypeBuilder proxyTB, Symbol p, MethodInfo mi)
{
Type[] paramTypes = CreateTypeArray(mi.GetParameters());
MethodBuilder mb = proxyTB.DefineMethod(p.Name, MethodAttributes.Public, CallingConventions.HasThis, mi.ReturnType, paramTypes);
ILGen gen = new ILGen(mb.GetILGenerator());
gen.EmitLoadArg(0); // gen.Emit(OpCodes.Ldarg_0);
for (int i = 0; i < paramTypes.Length; i++)
gen.EmitLoadArg(i + 1); // gen.Emit(OpCodes.Ldarg, i + 1);
gen.Emit(OpCodes.Call, mi); // not gen.EmitCall(mi); -- we need call versus callvirt
gen.Emit(OpCodes.Ret);
}
示例15: ReadRecord
static object ReadRecord(object form, Symbol recordName, object opts, object pendingForms)
{
bool readeval = RT.booleanCast(RT.ReadEvalVar.deref());
if (!readeval)
throw new InvalidOperationException("Record construction syntax can only be used when *read-eval* == true ");
Type recordType = RT.classForNameE(recordName.ToString());
IPersistentVector recordEntries;
IPersistentMap vals;
object ret = null;
ConstructorInfo[] allCtors = recordType.GetConstructors();
if ((recordEntries = form as IPersistentVector) != null)
{
// shortForm
bool ctorFound = false;
foreach (ConstructorInfo cinfo in allCtors)
if (cinfo.GetParameters().Length == recordEntries.count())
ctorFound = true;
if (!ctorFound)
throw new ArgumentException(String.Format("Unexpected number of constructor arguments to {0}: got {1}", recordType.ToString(), recordEntries.count()));
ret = Reflector.InvokeConstructor(recordType, RT.toArray(recordEntries));
}
else if ((vals = form as IPersistentMap) != null)
{
for (ISeq s = RT.keys(vals); s != null; s = s.next())
{
if (!(s.first() is Keyword))
throw new ArgumentException(String.Format("Unreadable defrecord form: key must be of type clojure.lang.Keyword, got {0}", s.first().ToString()));
}
ret = Reflector.InvokeStaticMethod(recordType, "create", new Object[] { vals });
}
else
{
throw new ArgumentException("Unreadable constructor form starting with \"#" + recordName + "\"");
}
return ret;
}