public static IWorkshopTree Call(ActionSet actionSet, DefinedMacro macro, MethodCall call)
        {
            MacroBuilder builder = new MacroBuilder(actionSet, macro, call);

            builder.AssignParameters();
            return(builder.ParseInner());
        }
Exemplo n.º 2
0
        /// <summary>Creates a macro from a Define_macroContext.</summary>
        /// <param name="objectScope">The scope of the macro if there is no static attribute.</param>
        /// <param name="staticScope">The scope of the macro if there is a static attribute.</param>
        /// <param name="macroContext">The context of the macro.</param>
        /// <returns>A DefinedMacro if the macro has parameters, a MacroVar if there are no parameters.</returns>
        public DefinedMacro GetMacro(Scope objectScope, Scope staticScope, MacroFunctionContext macroContext)
        {
            // Get the return type.
            CodeType returnType = CodeType.GetCodeTypeFromContext(this, macroContext.Type);

            DefinedMacro newMacro = new DefinedMacro(this, objectScope, staticScope, macroContext, returnType);

            TranslateInfo.ApplyBlock((IApplyBlock)newMacro);
            return(newMacro);
        }
 public static void GetMacro(ParseInfo parseInfo, Scope scope, DeltinScriptParser.Define_macroContext macroContext, List <IApplyBlock> applyMethods)
 {
     if (macroContext.LEFT_PAREN() != null || macroContext.RIGHT_PAREN() != null)
     {
         var newMacro = new DefinedMacro(parseInfo, scope, macroContext);
         scope.AddMethod(newMacro, parseInfo.Script.Diagnostics, DocRange.GetRange(macroContext.name));
         applyMethods.Add(newMacro);
     }
     else
     {
         var newMacro = new MacroVar(parseInfo, scope, macroContext);
         scope.AddVariable(newMacro, parseInfo.Script.Diagnostics, DocRange.GetRange(macroContext.name));
         applyMethods.Add(newMacro);
     }
 }
        public static IScopeable GetMacro(ParseInfo parseInfo, Scope objectScope, Scope staticScope, DeltinScriptParser.Define_macroContext macroContext)
        {
            // If the ; is missing, syntax error.
            if (macroContext.STATEMENT_END() == null)
            {
                parseInfo.Script.Diagnostics.Error("Expected ;", DocRange.GetRange((object)macroContext.TERNARY_ELSE() ?? (object)macroContext.name ?? (object)macroContext).end.ToRange());
            }

            // If the : is missing, syntax error.
            if (macroContext.TERNARY_ELSE() == null)
            {
                parseInfo.Script.Diagnostics.Error("Expected :", DocRange.GetRange(macroContext).end.ToRange());
            }
            else
            {
                // Get the expression that will be parsed.
                if (macroContext.expr() == null)
                {
                    parseInfo.Script.Diagnostics.Error("Expected expression.", DocRange.GetRange(macroContext.TERNARY_ELSE()));
                }
            }

            // Get the return type.
            CodeType returnType = CodeType.GetCodeTypeFromContext(parseInfo, macroContext.code_type());

            IScopeable newMacro;

            if (macroContext.LEFT_PAREN() != null || macroContext.RIGHT_PAREN() != null)
            {
                newMacro = new DefinedMacro(parseInfo, objectScope, staticScope, macroContext, returnType);
            }
            else
            {
                newMacro = new MacroVar(parseInfo, objectScope, staticScope, macroContext, returnType);
            }

            parseInfo.TranslateInfo.ApplyBlock((IApplyBlock)newMacro);
            return(newMacro);
        }
 public ParameterMacroOption(DefinedMacro macro, MethodCall methodCall)
 {
     _macro      = macro;
     _methodCall = methodCall;
 }
 public MacroBuilder(ActionSet actionSet, DefinedMacro macro, MethodCall call) : base(actionSet)
 {
     _macro = macro;
     _call  = call;
 }