Esempio n. 1
0
        public override void GatherSymbols(CompileContext context, Model.Scope enclosingScope)
        {
            base.GatherSymbols(context, enclosingScope);
            staticLabel = Intermediate.Label.Make("_STRING");

            var data = new List<Intermediate.Operand>();
            data.Add(Constant((ushort)value.Length));
            foreach (var c in value)
                data.Add(Constant((ushort)c));
            context.AddData(staticLabel, 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);
        }