本文整理汇总了C#中clojure.lang.CljCompiler.Ast.GenContext类的典型用法代码示例。如果您正苦于以下问题:C# GenContext类的具体用法?C# GenContext怎么用?C# GenContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GenContext类属于clojure.lang.CljCompiler.Ast命名空间,在下文中一共展示了GenContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateInterface
public static Type GenerateInterface(string iName, ISeq extends, ISeq methods)
{
GenContext context = new GenContext(iName, CompilerMode.File);
// GenContext context = (GenContext)Compiler.COMPILER_CONTEXT.deref();
// if (context == null)
// {
//#if DEBUG
// context = new GenContext(iName, CompilerMode.File);
//#else
// throw new InvalidOperationException("No compiler context on the stack.");
//#endif
// }
Type[] interfaceTypes = GenClass.CreateTypeArray(extends == null ? null : extends.seq());
TypeBuilder proxyTB = context.ModuleBldr.DefineType(
iName,
TypeAttributes.Interface | TypeAttributes.Public | TypeAttributes.Abstract,
null,
interfaceTypes);
DefineMethods(proxyTB, methods);
Type t = proxyTB.CreateType();
context.AssyBldr.Save(iName + ".dll");
return t;
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:28,代码来源:GenInterface.cs
示例2: 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;
}
开发者ID:jlomax,项目名称:clojure-clr,代码行数:7,代码来源:HostExpr.cs
示例3: GenDlr
public override Expression GenDlr(GenContext context)
{
if (_method != null)
return Compiler.MaybeBox(GenDlrForMethod(context));
else
return GenDlrViaReflection(context);
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:7,代码来源:StaticMethodExpr.cs
示例4: GenCode
public Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
int n = _bindingInits.count();
List<ParameterExpression> parms = new List<ParameterExpression>(n);
List<Expression> forms = new List<Expression>(n);
/// First, set up the environment.
for (int i = 0; i < n; i++)
{
BindingInit bi = (BindingInit)_bindingInits.nth(i);
ParameterExpression parmExpr = Expression.Parameter(typeof(IFn), bi.Binding.Name);
bi.Binding.ParamExpression = parmExpr;
parms.Add(parmExpr);
}
// Then initialize
for (int i = 0; i < n; i++)
{
BindingInit bi = (BindingInit)_bindingInits.nth(i);
ParameterExpression parmExpr = (ParameterExpression)bi.Binding.ParamExpression;
forms.Add(Expression.Assign(parmExpr, bi.Init.GenCode(RHC.Expression,objx,context)));
}
// The work
forms.Add(_body.GenCode(rhc,objx,context));
return Expression.Block(parms,forms);
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:27,代码来源:LetFnExpr.cs
示例5: GenCode
public Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
List<Expression> exprs = new List<Expression>();
ParameterExpression parm = Expression.Parameter(typeof(Var), "v");
Expression varExpr = objx.GenVar(context,_var);
exprs.Add(Expression.Assign(parm, varExpr));
// The Java code does the following in the opposite order (as modified in commit #430dd4f, Jan 19, 2010)
// However, the call to bindRoot sets :macro to False. I'm not sure how it works now in the JVM version.
if (_initProvided )
// Java doesn't Box here, but we have to deal with unboxed bool values
exprs.Add(Expression.Call(parm, Compiler.Method_Var_bindRoot, Compiler.MaybeBox(_init.GenCode(RHC.Expression,objx,context))));
if (_meta != null)
{
if (_initProvided || IncludesExplicitMetadata((MapExpr)_meta))
{
// Java casts to IPersistentMap on the _meta, but Expression.Call can handle that for us.
exprs.Add(Expression.Call(parm, Compiler.Method_Var_setMeta, _meta.GenCode(RHC.Expression,objx,context)));
}
}
exprs.Add(parm);
return Expression.Block(new ParameterExpression[] { parm }, exprs);
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:30,代码来源:DefExpr.cs
示例6: GenDlrForMethod
private Expression GenDlrForMethod(GenContext context)
{
Expression target = _target.GenDlr(context);
Expression[] args = GenTypedArgs(context, _method.GetParameters(), _args);
return AstUtils.SimpleCallHelper(target,_method, args); ;
}
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:7,代码来源:InstanceMethodExpr.cs
示例7: Create
internal static Type Create(GenContext context, Type baseClass)
{
//ModuleBuilder mb = context.ModuleBldr;
string name = baseClass.Name + "_impl";
//TypeBuilder baseTB = context.ModuleBldr.DefineType(name, TypeAttributes.Class | TypeAttributes.Public, baseClass);
TypeBuilder baseTB = context.AssemblyGen.DefinePublicType(name, baseClass, true);
ObjExpr.MarkAsSerializable(baseTB);
baseTB.DefineDefaultConstructor(MethodAttributes.Public);
FieldBuilder metaField = baseTB.DefineField("_meta", typeof(IPersistentMap), FieldAttributes.Public);
MethodBuilder metaMB = baseTB.DefineMethod("meta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IPersistentMap), Type.EmptyTypes);
ILGen gen = new ILGen(metaMB.GetILGenerator());
gen.EmitLoadArg(0);
gen.EmitFieldGet(metaField);
gen.Emit(OpCodes.Ret);
MethodBuilder withMB = baseTB.DefineMethod("withMeta", MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.ReuseSlot, typeof(IObj), new Type[] { typeof(IPersistentMap)});
gen = new ILGen(withMB.GetILGenerator());
gen.EmitLoadArg(0);
gen.EmitCall(Compiler.Method_Object_MemberwiseClone);
gen.Emit(OpCodes.Castclass, baseTB);
gen.Emit(OpCodes.Dup);
gen.EmitLoadArg(1);
gen.EmitFieldSet(metaField);
gen.Emit(OpCodes.Ret);
for (int i = 0; i < 20; i++ )
DefineDelegateFieldAndOverride(baseTB, i);
return baseTB.CreateType();
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:34,代码来源:AFnImplGenerator.cs
示例8: GenDlrUnboxed
public override Expression GenDlrUnboxed(GenContext context)
{
if (_method != null)
return GenDlrForMethod(context);
else
throw new InvalidOperationException("Unboxed emit of unknown member.");
}
开发者ID:jlomax,项目名称:clojure-clr,代码行数:7,代码来源:StaticMethodExpr.cs
示例9: GenCode
public override Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
Expression exc = _excExpr.GenCode(RHC.Expression, objx, context);
Expression exc2 = Expression.Convert(exc, typeof(Exception));
return Expression.Throw(exc2,typeof(object));
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:7,代码来源:ThrowExpr.cs
示例10: GenDlr
public override Expression GenDlr(GenContext context)
{
Expression getTypeExpr = Expression.Call(null, Compiler.Method_RT_classForName, Expression.Constant(_c));
//Expression getNsExpr = Expression.Call(null, Compiler.Method_Compiler_CurrentNamespace);
Expression getNsExpr = Expression.Property(null, Compiler.Method_Compiler_CurrentNamespace);
return Expression.Call(getNsExpr, Compiler.Method_Namespace_importClass1, getTypeExpr);
}
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:7,代码来源:ImportExpr.cs
示例11: GenDlr
public override Expression GenDlr(GenContext context)
{
Expression basicBody = _tryExpr.GenDlr(context);
// Wrap the basic body, a Comma, in a return to a label
LabelTarget target = Expression.Label(basicBody.Type, "ret_label");
//Expression tryBody = Expression.Return(target, basicBody);
Expression tryBody = basicBody;
CatchBlock[] catches = new CatchBlock[_catchExprs.count()];
for ( int i=0; i<_catchExprs.count(); i++ )
{
CatchClause clause = (CatchClause) _catchExprs.nth(i);
ParameterExpression parmExpr = Expression.Parameter(clause.Type, clause.Lb.Name);
clause.Lb.ParamExpression = parmExpr;
catches[i] = Expression.Catch(parmExpr,clause.Handler.GenDlr(context));
}
TryExpression tryStmt = _finallyExpr == null
? Expression.TryCatch(tryBody, catches)
: Expression.TryCatchFinally(tryBody, _finallyExpr.GenDlr(context), catches);
Expression defaultValue = Expression.Default(basicBody.Type);
Expression whole = Expression.Block(tryStmt, Expression.Label(target, defaultValue));
return whole;
}
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:25,代码来源:TryExpr.cs
示例12: GenDlr
public override Expression GenDlr(GenContext context)
{
Expression exc = _excExpr.GenDlr(context);
Expression exc2 = Expression.Convert(exc, typeof(Exception));
return Expression.Throw(exc2);
}
开发者ID:jlomax,项目名称:clojure-clr,代码行数:7,代码来源:ThrowExpr.cs
示例13: GenTypedArg
internal static Expression GenTypedArg(GenContext context, Type type, Expr arg)
{
if (Compiler.MaybePrimitiveType(arg) == type)
return ((MaybePrimitiveExpr)arg).GenDlrUnboxed(context);
else
// Java has emitUnboxArg -- should we do something similar?
return arg.GenDlr(context);
}
开发者ID:jlomax,项目名称:clojure-clr,代码行数:8,代码来源:HostExpr.cs
示例14: GenTypedArg
internal static Expression GenTypedArg(GenContext context, Type type, Expr arg)
{
if (Compiler.MaybePrimitiveType(arg) == type)
return ((MaybePrimitiveExpr)arg).GenDlrUnboxed(context);
else
{
Expression argExpr = arg.GenDlr(context);
return GenMaybeUnboxedArg(type, argExpr);
}
}
开发者ID:starapor,项目名称:clojure-clr,代码行数:10,代码来源:HostExpr.cs
示例15: GenCode
public override Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
Expression call;
if (_method != null)
call = GenDlrForMethod(objx, context);
else
call = GenerateComplexCall(objx, context);
call = Compiler.MaybeAddDebugInfo(call, _spanMap, context.IsDebuggable);
return call;
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:11,代码来源:MethodExpr.cs
示例16: GenCode
public Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
Expression objExpr = _expr.GenCode(RHC.Expression, objx, context);
Expression iobjExpr = Expression.Convert(objExpr, typeof(IObj));
Expression metaExpr = _meta.GenCode(RHC.Expression, objx, context);
metaExpr = Expression.Convert(metaExpr, typeof(IPersistentMap));
Expression ret = Expression.Call(iobjExpr, Compiler.Method_IObj_withMeta, metaExpr);
return ret;
}
开发者ID:richhickey,项目名称:clojure-clr,代码行数:12,代码来源:MetaExpr.cs
示例17: GenCode
public Expression GenCode(RHC rhc, ObjExpr objx, GenContext context)
{
Expression objExpr = _expr.GenCode(RHC.Expression, objx, context);
Expression iobjExpr = Expression.Convert(objExpr, typeof(IObj));
Expression metaExpr = _meta.GenCode(RHC.Expression, objx, context);
// Do we need a conversion here? probably not.
Expression ret = Expression.Call(iobjExpr, Compiler.Method_IObj_withMeta, metaExpr);
return ret;
}
开发者ID:christianblunden,项目名称:clojure-clr,代码行数:12,代码来源:MetaExpr.cs
示例18: Create
internal static Type Create(GenContext context, Type baseClass)
{
ModuleBuilder mb = context.ModuleBldr;
string name = baseClass.Name + "_impl";
TypeBuilder baseTB = context.ModuleBldr.DefineType(name, TypeAttributes.Class | TypeAttributes.Public, baseClass);
baseTB.DefineDefaultConstructor(MethodAttributes.Public);
for (int i = 0; i < 20; i++ )
DefineDelegateFieldAndOverride(baseTB, i);
return baseTB.CreateType();
}
开发者ID:kmartin,项目名称:clojure-contrib,代码行数:13,代码来源:AFnImplGenerator.cs
示例19: GenCodeUnboxed
public Expression GenCodeUnboxed(RHC rhc, ObjExpr objx, GenContext context)
{
Type t = _n.GetType();
if (t == typeof(int))
return Expression.Constant((long)(int)_n, typeof(long));
else if (t == typeof(double))
return Expression.Constant((double)_n, typeof(double));
else if ( t == typeof(long) )
return Expression.Constant((long)_n,typeof(long));
throw new ArgumentException("Unsupported Number type: " + _n.GetType().Name);
}
开发者ID:richhickey,项目名称:clojure-clr,代码行数:13,代码来源:NumberExpr.cs
示例20: GenProxy
GenProxy(string className)
{
if (Compiler.IsCompiling)
{
//string path = (string)Compiler.COMPILE_PATH.deref();
//if (path == null)
// throw new Exception("*compile-path* not set");
////string dir = (string)Compiler.SOURCE_PATH.deref();
//_context = new GenContext(className, ".dll", path, CompilerMode.File);
_context = (GenContext)Compiler.CompilerContextVar.deref();
}
else
_context = GenContext.CreateWithInternalAssembly("proxy" + (++_saveId).ToString(), false);
}
开发者ID:stuman08,项目名称:clojure-clr,代码行数:16,代码来源:GenProxy.cs
注:本文中的clojure.lang.CljCompiler.Ast.GenContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论