public void VisitTemplateType(TemplateType t) { /* * template t(){ void foo() { } } * t!().foo must be offered for completion */ if(t.Base == null) isVariableInstance = true; VisitTemplateIntermediateType(t); }
public void VisitTemplateType(TemplateType t) { VisitDSymbol(t); }
public void VisitTemplateType(TemplateType t) { VisitTemplateIntermediateType(t); }
public void TestParamDeduction9() { var ctxt = CreateDefCtxt(@"module A; const int k = 4; template mxTemp(int i) { static if(i < 0) enum mxTemp = ""int""; else enum mxTemp = ""bool""; } template def(int i,string name) { enum def = mxTemp!(-i) ~ "" ""~name~"";""; } template def2(int i) { enum def2 = i; } mixin(def!(-1,""bar"")); "); IExpression ex; ISymbolValue val; ex = DParser.ParseExpression(@"def!(-2,""someVar"")"); val = Evaluation.EvaluateValue(ex, ctxt); Assert.That(val, Is.TypeOf(typeof(ArrayValue))); Assert.That((val as ArrayValue).IsString,Is.True); Assert.That((val as ArrayValue).StringValue, Is.EqualTo("bool someVar;")); var def = ctxt.ParseCache [0] ["A"]["def"].First () as DClassLike; var defS = new TemplateType (def, null, new[]{ new TemplateParameterSymbol(def.TemplateParameters[0], new PrimitiveValue(DTokens.Int, 2, null)), new TemplateParameterSymbol(def.TemplateParameters[1], new ArrayValue(Evaluation.GetStringType(ctxt), "someVar")) }); ctxt.PushNewScope (def); ctxt.CurrentContext.IntroduceTemplateParameterTypes (defS); ex = DParser.ParseExpression("mxTemp!(-i) ~ \" \"~name~\";\""); val = Evaluation.EvaluateValue(ex, ctxt); Assert.That(val, Is.TypeOf(typeof(ArrayValue))); Assert.That((val as ArrayValue).IsString,Is.True); Assert.That((val as ArrayValue).StringValue, Is.EqualTo("int someVar;")); ctxt.Pop (); ex = DParser.ParseExpression ("def2!5"); val = Evaluation.EvaluateValue (ex, ctxt); Assert.That (val, Is.TypeOf (typeof(PrimitiveValue))); Assert.That ((val as PrimitiveValue).Value, Is.EqualTo(5m)); ex = DParser.ParseExpression ("-k"); val = Evaluation.EvaluateValue (ex, ctxt); Assert.That (val, Is.TypeOf (typeof(PrimitiveValue))); Assert.That ((val as PrimitiveValue).Value, Is.EqualTo(-4m)); ex = DParser.ParseExpression ("mxTemp!(-k)"); val = Evaluation.EvaluateValue (ex, ctxt); Assert.That(val, Is.TypeOf(typeof(ArrayValue))); Assert.That((val as ArrayValue).IsString,Is.True); Assert.That((val as ArrayValue).StringValue, Is.EqualTo("int")); ex = DParser.ParseExpression(@"def!(-5,""foolish"")"); val = Evaluation.EvaluateValue(ex, ctxt); Assert.That(val, Is.TypeOf(typeof(ArrayValue))); Assert.That((val as ArrayValue).IsString,Is.True); Assert.That((val as ArrayValue).StringValue, Is.EqualTo("bool foolish;")); ex=DParser.ParseExpression("bar"); var t = Evaluation.EvaluateType(ex, ctxt); Assert.That(t, Is.TypeOf(typeof(MemberSymbol))); Assert.That((t as MemberSymbol).Base,Is.TypeOf(typeof(PrimitiveType))); Assert.That(((t as MemberSymbol).Base as PrimitiveType).TypeToken,Is.EqualTo(DTokens.Bool)); }
public ITypeDeclaration VisitTemplateType(TemplateType t) { return(VisitDSymbol(t)); }