Esempio n. 1
0
        public static IFunction GetFunction(Model.Variable inputVariable, JObject data, List <Model.VariableMap> mapping = null)
        {
            if (inputVariable.IsFunction)
            {
                switch (inputVariable.FunctionName.ToLower())
                {
                case FUNCTION_COMPARE:
                    return(new CompareFunction(inputVariable, data));

                case FUNCTION_MAP:
                    IFunction fn = new MapFunction(inputVariable, data);
                    ((MapFunction)fn).Mapping = mapping;
                    return(fn);
                }
            }

            return(new NoFunction(inputVariable, data));
        }
Esempio n. 2
0
        public override void GatherSymbols(CompileContext context, Model.Scope enclosingScope)
        {
            (Child(0) as BlockNode).bypass = true;

            function.LabelName = enclosingScope.activeFunction.function.LabelName + "_" + function.name;
            function.label = Intermediate.Label.Make(function.LabelName);
            footerLabel = Intermediate.Label.Make(function.name + "_footer");

            if (enclosingScope.type != Model.ScopeType.Global)
                context.AddWarning(this, "Experimental feature: Function declared within function.");

            enclosingScope.functions.Add(function);
            enclosingScope.activeFunction.function.SubordinateFunctions.Add(function);
            function.localScope.parent = enclosingScope;

            for (int i = parameters.Count - 1; i >= 0; --i)
            {
                var variable = new Model.Variable();
                variable.scope = function.localScope;
                variable.name = parameters[i].Item1;
                variable.typeSpecifier = parameters[i].Item2;
                if (variable.typeSpecifier == null) variable.typeSpecifier = "word";
                function.localScope.variables.Add(variable);
                variable.type = Model.VariableType.Local;

                    variable.stackOffset = i + 2; //Need an extra space for the return pointer and stored frame pointer
                    //function.localScope.variablesOnStack += 1;

            }

            base.GatherSymbols(context, function.localScope);
        }
Esempio n. 3
0
 public NoFunction(Model.Variable inputVariable, JObject data)
 {
     this.Data          = data;
     this.InputVariable = inputVariable;
 }