Declare() public method

public Declare ( string name ) : void
name string
return void
示例#1
0
        public STBlock(Node blockLiteral, Context context, Compiler compiler)
        {
            Compiler = compiler;
            OuterContext = context;
            Context = new LocalContext(context, true);

            BlockLiteral = blockLiteral;
            BlockArgumentNames = new string[0];
            LocalVariableNames = new string[0];

            int i = 1;

            Node blockParams = null;

            if (blockLiteral[i].Name == "block_params")
                blockParams = blockLiteral[i++];

            if (blockLiteral[i].Name == "sequence") {
                Sequence = blockLiteral[i++];

                if (Sequence[0].Name == "var_def") {
                    List<string> varNames = new List<string>();
                    var vardef = Sequence[0];
                    for (int j = 1, max = vardef.Count; j < max; ++j) {
                        if (vardef[j].Name == "VAR_DELIM") break;
                        var varName = (vardef[j] as Token).Image;
                        varNames.Add (varName);
                        Context.Declare(varName);
                    }

                    LocalVariableNames = varNames.ToArray();
                }
            }

            if (blockParams != null) {
                var parms = blockParams;
                List<string> parmNames = new List<string>();
                for (int j = 0, max = parms.Count; j < max; ++j) {
                    var child = parms[j];
                    if (child.Name == "VAR_DELIM")
                        break;
                    var parmName = (parms[++j] as Token).Image;
                    parmNames.Add (parmName);
                    Context.Declare(parmName);
                }

                BlockArgumentNames = parmNames.ToArray();
            }
        }
示例#2
0
 public STObject(STClass @class)
 {
     Class = @class;
     InstanceContext = new LocalContext(GlobalContext.Instance, true);
     InstanceContext.Declare("self");
     InstanceContext.SetVariable("self", this);
 }