Exemple #1
0
	public MetaRuleBuilder (string name, NamespaceBuilder ns, CodeLinePragma loc, TypeAttributes attr)
	{
	    rb = new RuleBuilder (name, ns, loc, attr);
	    tmpl = new RuleTemplateBuilder (name + "RTemplate", rb, ns, loc, attr);

	    ns.AddMetaRule (this);
	    BaseClass = RuleType;
	}
Exemple #2
0
            public void EmitStatements(CodeMemberMethod list, CodeVariableReferenceExpression sink,
                                       CodeMemberMethod fetch, CodeVariableReferenceExpression source,
                                       CodeMemberMethod clear)
            {
                CodeExpression idexpr = RuleBuilder.BasePlusN(Idx);

                // List

                CodeMethodInvokeExpression invoke = CDH.AddBareInvoke(list, sink, "AddArg");

                invoke.Parameters.Add(idexpr);
                invoke.Parameters.Add(new CodePrimitiveExpression(Name));
                invoke.Parameters.Add(new CodeTypeOfExpression(arg_class.AsCodeDom));
                invoke.Parameters.Add(Flags);

                // Fetch

                invoke        = new CodeMethodInvokeExpression();
                invoke.Method = new CodeMethodReferenceExpression(source, "GetArgValue");
                invoke.Parameters.Add(idexpr);

                CodeMethodReferenceExpression mref = new CodeMethodReferenceExpression();

                mref.TargetObject = TRERule;

                if (conv == RuleArgConversion.None)
                {
                    switch (Count)
                    {
                    case ArgCount.OneOrMore:
                        goto case ArgCount.ZeroOrMore;

                    case ArgCount.ZeroOrMore:
                        mref.MethodName = "AsArray";
                        mref.TypeArguments.Add(Type.AsCodeDom);
                        break;

                    case ArgCount.Optional:
                        mref.MethodName = "AsOptional";
                        mref.TypeArguments.Add(Type.AsCodeDom);
                        break;

                    case ArgCount.Standard:
                        mref.MethodName = "AsSingle";
                        mref.TypeArguments.Add(Type.AsCodeDom);
                        break;
                    }
                }
                else
                {
                    mref.TypeArguments.Add(Type.AsCodeDom);
                    mref.TypeArguments.Add(arg_class.AsCodeDom);

                    switch (Count)
                    {
                    case ArgCount.OneOrMore:
                        goto case ArgCount.ZeroOrMore;

                    case ArgCount.ZeroOrMore:
                        mref.MethodName = "AsArrayConv";
                        break;

                    case ArgCount.Optional:
                        if (conv == RuleArgConversion.ToValueType)
                        {
                            mref.MethodName = "AsOptionalValue";
                        }
                        else
                        {
                            mref.MethodName = "AsOptionalRef";
                        }
                        break;

                    case ArgCount.Standard:
                        mref.MethodName = "AsSingleConv";
                        break;
                    }
                }

                CodeMethodInvokeExpression inv2 = new CodeMethodInvokeExpression();

                inv2.Method = mref;
                inv2.Parameters.Add(invoke);

                CodeAssignStatement assg = new CodeAssignStatement(CDH.ThisDot(Name), inv2);

                fetch.Statements.Add(assg);

                // ClearArgValues. Can't clear standard value types -- eg, 'bool member;'.
                // Those we trust will get set again when FetchArgValues is called next time.

                if (conv != RuleArgConversion.ToValueType || Count != ArgCount.Standard)
                {
                    assg = new CodeAssignStatement(CDH.ThisDot(Name), CDH.Null);
                    clear.Statements.Add(assg);
                }
            }
	public RuleTemplateBuilder (string name, RuleBuilder rb, NamespaceBuilder ns, CodeLinePragma loc,
				    TypeAttributes attr) : base (name, ns, loc, attr)
	{
	    this.rb = rb;
	}
Exemple #4
0
 public RuleTemplateBuilder(string name, RuleBuilder rb, NamespaceBuilder ns, CodeLinePragma loc,
                            TypeAttributes attr) : base(name, ns, loc, attr)
 {
     this.rb = rb;
 }
Exemple #5
0
 protected override void Emit(CodeTypeDeclaration ctd)
 {
     EmitEmptyCtor(ctd);
     fp.EmitGetFingerprint(ctd);
     RuleBuilder.EmitGeneralResult(ctd, ResultType);
 }