예제 #1
0
 protected internal virtual bool internalCanGenerate(CDim dim)
 {
     if (dim.Variables.Count != 0 && dim.Variables[0].Attributes.contains("ExecuteOnClient"))
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
 public void VisitDim(CDim dim)
 {
     if (classname == "" && funcname == "" && !canGenerate(dim))
     {
         return;
     }
     visitor.VisitDim(dim);
 }
예제 #3
0
        public bool canGenerate(CDim dim)
        {
            if (dim.Variables.Count != 0 && dim.Variables[0].Attributes.contains("ExecuteAtCompiler"))
            {
                return(false);
            }

            return(internalCanGenerate(dim));
        }
예제 #4
0
        public void VisitFile(CFile file)
        {
            if (!canGenerate(file))
            {
                return;
            }

            visitor.PreVisitFile(file);

            filenamesrc = file.Token;

            new CNewline(null).Accept(visitor);

            if (instrument)
            {
                COption cCodeCoverage =
                    new COption(new CToken(file.Filename, TokenTypes.keyword, "option"),
                                new CToken(file.Filename, TokenTypes.keyword, "include"),
                                new CToken(file.Filename, TokenTypes.str, "cCodeCoverage.asp"));
                cCodeCoverage.Accept(this);
            }

            visitor.VisitFile(file);

            if (file.Attributes.contains("GenerateProcessAjaxFunction"))
            {
                CFunction unicoderequest = CProgram.Global.FindFunction("unicoderequest");
                CFunction intrequest     = CProgram.Global.FindFunction("intrequest");
                CFunction boolrequest    = CProgram.Global.FindFunction("boolrequest");

                CToken    tok         = CreateTokenWithAdditionalInfo("ProcessAjax", "processajax", TokenTypes.identifier);
                CFunction processAjax =
                    new CFunction(tok, tok.RawValue, tok.Value, TokenTypes.visPublic, CFunction.vbSub, null,
                                  new CTypeRef(null, BuiltIns.Void));

                CAccess pivotitem = new CAccess(unicoderequest.Token, unicoderequest.Token);
                pivotitem.ReferenceTarget = unicoderequest;
                CParameters pivotparams = new CParameters();
                pivotparams.Unnamed.Add(
                    new CConstantExpression(CreateTokenWithAdditionalInfo("sFunction", TokenTypes.str)));
                CSelect select =
                    new CSelect(CreateTokenWithAdditionalInfo("select", TokenTypes.controlFlow),
                                new CDefaultAccess(pivotitem.Token, pivotitem, pivotparams));

                IEnumerator      it   = CProgram.Global.Functions.GetEnumerator();
                List <CVariable> vars = new List <CVariable>();
                while (it.MoveNext())
                {
                    CFunction func = (CFunction)it.Current;
                    if (!func.Attributes.contains("ExecuteOnServer"))
                    {
                        continue;
                    }

                    CStatementBlock block      = new CStatementBlock();
                    CParameters     funcParams = new CParameters();
                    for (int ixArg = 0; ixArg < func.Arguments.Count - 3; ixArg++)
                    {
                        CArgument arg = func.Arguments[ixArg];

                        tok =
                            CreateTokenWithAdditionalInfo("vParam" + (ixArg + 1), "vparam" + (ixArg + 1),
                                                          TokenTypes.identifier);
                        if (ixArg >= vars.Count)
                        {
                            vars.Add(new CVariable(tok, false, new CTypeRef(null, BuiltIns.Variant), null, null, null));
                        }

                        CAssignment assign = new CAssignment(tok);

                        CAccess left = new CAccess(tok, tok);
                        left.ReferenceTarget = vars[ixArg];
                        assign.Target        = left;
                        funcParams.Unnamed.Add(left);

                        CFunction rightfunc = intrequest;
                        if (arg.Type.RawName == "Boolean")
                        {
                            rightfunc = boolrequest;
                        }
                        else if (arg.Type.RawName == "String")
                        {
                            rightfunc = unicoderequest;
                        }

                        CParameters parameters = new CParameters();
                        parameters.Unnamed.Add(
                            new CConstantExpression(CreateTokenWithAdditionalInfo(tok.RawValue, TokenTypes.str)));

                        CAccess rightitem = new CAccess(rightfunc.Token, rightfunc.Token);
                        rightitem.ReferenceTarget = rightfunc;

                        assign.Source = new CDefaultAccess(rightfunc.Token, rightitem, parameters);
                        assign.Source.RhsAssignmentSource = true;

                        block.Add(assign);
                    }

                    CAccess        calledItem = new CAccess(func.Token, func.Token);
                    CDefaultAccess called     = new CDefaultAccess(func.Token, calledItem, funcParams);
                    calledItem.ReferenceTarget = calledItem.ReferenceTarget = func;

                    if (func.Attributes.contains("picture") || func.FunctionType == CFunction.vbFunction)
                    {
                        CAccess returnItem = new CAccess(processAjax.Token, processAjax.Token);
                        returnItem.ReferenceTarget = processAjax;

                        CAssignment assign = new CAssignment(processAjax.Token);
                        assign.Target = returnItem;

                        if (func.FunctionType == CFunction.vbFunction)
                        {
                            assign.Source = called;
                        }
                        else
                        {
                            assign.Source = new CPictureOfExpression(tok, called);
                        }

                        block.Add(assign);
                    }
                    else
                    {
                        block.Add(new CExpressionStatement(called));
                    }

                    tok = CreateTokenWithAdditionalInfo("case", TokenTypes.controlFlow);
                    CExpression exp =
                        new CConstantExpression(CreateTokenWithAdditionalInfo(func.RawName, TokenTypes.str));
                    select.Cases.Add(new CCase(tok, exp, block));
                }

                CDim dim = new CDim(CreateTokenWithAdditionalInfo("Dim", TokenTypes.declaration));
                dim.Variables.AddRange(vars);
                processAjax.Statements.Add(dim);
                processAjax.Statements.Add(select);

                CNewline nl = new CNewline(CreateTokenWithAdditionalInfo("\n", TokenTypes.newline));
                nl.Accept(this);
                processAjax.Accept(this);
                nl.Accept(this);
            }
        }