Sha256: 9c93b5887465e713b1d5dce52913482451c67ebc510db1628a00919b7cd4642d

Contents?: true

Size: 1.35 KB

Versions: 184

Compression:

Stored size: 1.35 KB

Contents

/*
Shiltiumcomp -- the first Shiltolang compiler

Copyright (C) 2010 Gregory Cohen <gregorycohenvideos@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "../global_headers/headers.h"

attr_nonnull Variable* get_variable(ParserState* cr state, const String* cr name) {
	Scope* scope;
	
	assert_comparison(state, !=, NULL, ParserState* cr, void*);
	assert_comparison(name, !=, NULL, const String* cr, void*);
	
	scope = &state->scope;
	
	while (scope) {
		bool in_hash_table;
		Variable* variable;
		
		variable = (Variable*)DEREF(
			hash_table_get_value_from_string_key(
				&scope->variables_in_scope,
				ARROW(name, string),
				ARROW(name, length),
				&in_hash_table
			)
		);
		
		if (in_hash_table) {
			return variable;
		}
		
		scope = ARROW(scope, parent_scope);
	}
	
	return NULL;
}

Version data entries

184 entries across 46 versions & 6 rubygems

Version Path
freespeech-1.0.88 ./other/old_compiler/shiltiumcomp78/portable/get_variable.c
freespeech-1.0.88 ./other/old_compiler/shiltiumcomp76/portable/get_variable.c
freespeech-1.0.88 ./other/old_compiler/shiltiumcomp59/portable/get_variable.c
freespeech-1.0.88 ./other/old_compiler/shiltiumcomp/portable/get_variable.c
elonmusk-1.0.88 ./other/old_compiler/shiltiumcomp59/portable/get_variable.c
elonmusk-1.0.88 ./other/old_compiler/shiltiumcomp/portable/get_variable.c
elonmusk-1.0.88 ./other/old_compiler/shiltiumcomp78/portable/get_variable.c
elonmusk-1.0.88 ./other/old_compiler/shiltiumcomp76/portable/get_variable.c
politics-1.0.88 ./other/old_compiler/shiltiumcomp/portable/get_variable.c
politics-1.0.88 ./other/old_compiler/shiltiumcomp59/portable/get_variable.c
politics-1.0.88 ./other/old_compiler/shiltiumcomp76/portable/get_variable.c
politics-1.0.88 ./other/old_compiler/shiltiumcomp78/portable/get_variable.c
democracy-1.0.86 ./other/old_compiler/shiltiumcomp/portable/get_variable.c
democracy-1.0.86 ./other/old_compiler/shiltiumcomp59/portable/get_variable.c
democracy-1.0.86 ./other/old_compiler/shiltiumcomp76/portable/get_variable.c
democracy-1.0.86 ./other/old_compiler/shiltiumcomp78/portable/get_variable.c
politics-1.0.82 ./other/old_compiler/shiltiumcomp78/portable/get_variable.c
politics-1.0.82 ./other/old_compiler/shiltiumcomp/portable/get_variable.c
politics-1.0.82 ./other/old_compiler/shiltiumcomp59/portable/get_variable.c
politics-1.0.82 ./other/old_compiler/shiltiumcomp76/portable/get_variable.c