本文整理汇总了C#中clojure.lang.Symbol类的典型用法代码示例。如果您正苦于以下问题:C# Symbol类的具体用法?C# Symbol怎么用?C# Symbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Symbol类属于clojure.lang命名空间,在下文中一共展示了Symbol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:101v,项目名称:clojure-clr,代码行数:11,代码来源:Namespace.cs
示例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;
}
开发者ID:arohner,项目名称:clojure-contrib,代码行数:11,代码来源:ClojureConsole.cs
示例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);
}
开发者ID:TerabyteX,项目名称:clojure-clr,代码行数:24,代码来源:Keyword.cs
示例4: DeprecatedWrappingReader
public DeprecatedWrappingReader(Symbol sym, string macro)
{
_sym = sym;
_macro = macro;
}
开发者ID:vietnt,项目名称:clojure-clr,代码行数:5,代码来源:LispReader.cs
示例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;
}
开发者ID:vietnt,项目名称:clojure-clr,代码行数:54,代码来源:LispReader.cs
示例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;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:13,代码来源:Compiler.cs
示例7: NamesStaticMember
internal static bool NamesStaticMember(Symbol sym)
{
return sym.Namespace != null && NamespaceFor(sym) == null;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:4,代码来源:Compiler.cs
示例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;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:25,代码来源:Compiler.cs
示例9: Resolve
public static object Resolve(Symbol symbol, bool allowPrivate)
{
return ResolveIn(CurrentNamespace, symbol, allowPrivate);
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:4,代码来源:Compiler.cs
示例10: setTag
public void setTag(Symbol tag)
{
Tag = tag;
}
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:4,代码来源:Var.cs
示例11: intern
public static Var intern(Namespace ns, Symbol sym)
{
return ns.intern(sym);
}
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:4,代码来源:Var.cs
示例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));
}
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:9,代码来源:Var.cs
示例13: NamespaceFor
public static Namespace NamespaceFor(Symbol symbol)
{
return NamespaceFor(CurrentNamespace, symbol);
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:4,代码来源:Compiler.cs
示例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);
}
开发者ID:ragnard,项目名称:clojure-clr,代码行数:12,代码来源:GenClass.cs
示例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;
}
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:44,代码来源:LispReader.cs
示例16: LookupVar
internal static Var LookupVar(Symbol sym, bool internNew)
{
Var var = null;
// Note: ns-qualified vars in other namespaces must exist already
if (sym.Namespace != null)
{
Namespace ns = Compiler.NamespaceFor(sym);
if (ns == null)
return null;
Symbol name = Symbol.create(sym.Name);
if (internNew && ns == CurrentNamespace)
var = CurrentNamespace.intern(name);
else
var = ns.FindInternedVar(name);
}
else if (sym.Equals(NS))
var = RT.NS_VAR;
else if (sym.Equals(IN_NS))
var = RT.IN_NS_VAR;
else
{
// is it mapped?
Object o = CurrentNamespace.GetMapping(sym);
if (o == null)
{
// introduce a new var in the current ns
if (internNew)
var = CurrentNamespace.intern(Symbol.create(sym.Name));
}
else if (o is Var)
var = (Var)o;
else
throw new Exception(string.Format("Expecting var, but {0} is mapped to {1}", sym, o));
}
if (var != null)
RegisterVar(var);
return var;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:39,代码来源:Compiler.cs
示例17: ReadTagged
static object ReadTagged(object o, Symbol tag, object opts, object pendingForms)
{
ILookup dataReaders = (ILookup)RT.DataReadersVar.deref();
IFn dataReader = (IFn)RT.get(dataReaders, tag);
if (dataReader == null)
{
dataReaders = (ILookup)RT.DefaultDataReadersVar.deref();
dataReader = (IFn)RT.get(dataReaders, tag);
if (dataReader == null)
{
IFn default_reader = (IFn)RT.DefaultDataReaderFnVar.deref();
if (default_reader != null)
return default_reader.invoke(tag, o);
else
throw new ArgumentException("No reader function for tag " + tag.ToString());
}
}
return dataReader.invoke(o);
}
开发者ID:telefunkenvf14,项目名称:clojure-clr,代码行数:19,代码来源:LispReader.cs
示例18: ReferenceLocal
internal static LocalBinding ReferenceLocal(Symbol symbol)
{
if (!LOCAL_ENV.IsBound)
return null;
LocalBinding b = (LocalBinding)RT.get(LOCAL_ENV.deref(), symbol);
if (b != null)
{
FnMethod method = (FnMethod)METHODS.deref();
CloseOver(b, method);
}
return b;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:14,代码来源:Compiler.cs
示例19: ResolveIn
private static object ResolveIn(Namespace n, Symbol symbol, bool allowPrivate)
{
// note: ns-qualified vars must already exist
if (symbol.Namespace != null)
{
Namespace ns = NamespaceFor(n, symbol);
if (ns == null)
throw new Exception("No such namespace: " + symbol.Namespace);
Var v = ns.FindInternedVar(Symbol.create(symbol.Name));
if (v == null)
throw new Exception("No such var: " + symbol);
else if (v.Namespace != CurrentNamespace && !v.IsPublic && !allowPrivate)
throw new InvalidOperationException(string.Format("var: {0} is not public", symbol));
return v;
}
else if (symbol.Name.IndexOf('.') > 0 || symbol.Name[0] == '[')
return RT.classForName(symbol.Name);
else if (symbol.Equals(NS))
return RT.NS_VAR;
else if (symbol.Equals(IN_NS))
return RT.IN_NS_VAR;
else
{
object o = n.GetMapping(symbol);
if (o == null)
{
if (RT.booleanCast(RT.ALLOW_UNRESOLVED_VARS.deref()))
return symbol;
else
throw new Exception(string.Format("Unable to resolve symbol: {0} in this context", symbol));
}
return o;
}
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:35,代码来源:Compiler.cs
示例20: AnalyzeSymbol
private static Expr AnalyzeSymbol(Symbol symbol)
{
Symbol tag = TagOf(symbol);
if (symbol.Namespace == null)
{
LocalBinding b = ReferenceLocal(symbol);
if (b != null)
return new LocalBindingExpr(b, tag);
}
else
{
if (namespaceFor(symbol) == null)
{
Symbol nsSym = Symbol.create(symbol.Namespace);
Type t = MaybeType(nsSym, false);
if (t != null)
{
FieldInfo finfo;
PropertyInfo pinfo;
if ((finfo = Reflector.GetField(t, symbol.Name, true)) != null)
return new StaticFieldExpr((int)LINE.deref(), t, symbol.Name,finfo);
else if ((pinfo = Reflector.GetProperty(t, symbol.Name, true)) != null)
return new StaticPropertyExpr((int)LINE.deref(), t, symbol.Name,pinfo);
}
throw new Exception(string.Format("Unable to find static field: {0} in {1}", symbol.Name, t));
}
}
object o = Compiler.Resolve(symbol);
if (o is Var)
{
Var v = (Var)o;
if (IsMacro(v) != null)
throw new Exception("Can't take the value of a macro: " + v);
RegisterVar(v);
return new VarExpr(v, tag);
}
else if (o is Type)
return new ConstantExpr(o);
else if (o is Symbol)
return new UnresolvedVarExpr((Symbol)o);
throw new Exception(string.Format("Unable to resolve symbol: {0} in this context", symbol));
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:46,代码来源:Compiler.cs
注:本文中的clojure.lang.Symbol类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论